From b1358ba4fb17713ab9f637dd6e698b8ec788fd92 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 17:43:03 +0500 Subject: [PATCH 01/16] feat: [google-cloud-batch] Add support for opt-in debug logging (#13317) 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 docs: clarify options for logs docs: Clarify the custom instance template needs to be in the same project docs: Rephrase reservation field doc 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= BEGIN_NESTED_COMMIT docs: [google-cloud-batch] clarify options for logs docs: clarify the custom instance template needs to be in the same project PiperOrigin-RevId: 703266926 Source-Link: https://github.com/googleapis/googleapis/commit/3735100771044022d9e57f25fdbf0e67f45a857e Source-Link: https://github.com/googleapis/googleapis-gen/commit/4190d79c5b8e8f62f66db0e1c182308b8037b94a Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI0MTkwZDc5YzViOGU4ZjYyZjY2ZGIwZTFjMTgyMzA4YjgwMzdiOTRhIn0= END_NESTED_COMMIT BEGIN_NESTED_COMMIT docs: [google-cloud-batch] clarify options for logs docs: Clarify the custom instance template needs to be in the same project PiperOrigin-RevId: 702966613 Source-Link: https://github.com/googleapis/googleapis/commit/2cb4e7a6f328b0a017e040e2c6150c17ef6bea61 Source-Link: https://github.com/googleapis/googleapis-gen/commit/14a9205201b8000a2fedda894e105256ceed9075 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIxNGE5MjA1MjAxYjgwMDBhMmZlZGRhODk0ZTEwNTI1NmNlZWQ5MDc1In0= END_NESTED_COMMIT BEGIN_NESTED_COMMIT docs: [google-cloud-batch] Rephrase reservation field doc PiperOrigin-RevId: 702134577 Source-Link: https://github.com/googleapis/googleapis/commit/349841abac6c3e580ccce6e3d6fcc182ed2512c2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/bac26d7e377d9c66f6e4b17678f6438c98720b45 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJiYWMyNmQ3ZTM3N2Q5YzY2ZjZlNGIxNzY3OGY2NDM4Yzk4NzIwYjQ1In0= END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../services/batch_service/async_client.py | 128 +- .../batch_v1/services/batch_service/client.py | 133 +- .../batch_v1/services/batch_service/pagers.py | 32 +- .../services/batch_service/transports/grpc.py | 118 +- .../batch_service/transports/grpc_asyncio.py | 115 +- .../services/batch_service/transports/rest.py | 730 +++++++++- .../google/cloud/batch_v1/types/job.py | 56 +- .../services/batch_service/async_client.py | 184 ++- .../services/batch_service/client.py | 189 ++- .../services/batch_service/pagers.py | 48 +- .../services/batch_service/transports/grpc.py | 132 +- .../batch_service/transports/grpc_asyncio.py | 129 +- .../services/batch_service/transports/rest.py | 1186 +++++++++++++++-- .../google/cloud/batch_v1alpha/types/job.py | 48 +- ...nippet_metadata_google.cloud.batch.v1.json | 24 +- ...t_metadata_google.cloud.batch.v1alpha.json | 52 +- .../unit/gapic/batch_v1/test_batch_service.py | 40 + .../gapic/batch_v1alpha/test_batch_service.py | 75 ++ 18 files changed, 2892 insertions(+), 527 deletions(-) diff --git a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/async_client.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/async_client.py index 9265fccceca5..dbcff5d80053 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/async_client.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, BatchServiceTransport from .transports.grpc_asyncio import BatchServiceGrpcAsyncIOTransport +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 BatchServiceAsyncClient: """Google Batch Service. @@ -267,6 +277,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.batch_v1.BatchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "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.batch.v1.BatchService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[batch.CreateJobRequest, dict]] = None, @@ -276,7 +308,7 @@ async def create_job( job_id: 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]]] = (), ) -> gcb_job.Job: r"""Create a Job. @@ -340,8 +372,10 @@ async def sample_create_job(): 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.batch_v1.types.Job: @@ -404,7 +438,7 @@ async def get_job( 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]]] = (), ) -> job.Job: r"""Get a Job specified by its resource name. @@ -445,8 +479,10 @@ async def sample_get_job(): 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.batch_v1.types.Job: @@ -503,7 +539,7 @@ async def delete_job( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a Job. @@ -547,8 +583,10 @@ async def sample_delete_job(): 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.api_core.operation_async.AsyncOperation: @@ -627,7 +665,7 @@ async def list_jobs( 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.ListJobsAsyncPager: r"""List all Jobs for a project within a region. @@ -668,8 +706,10 @@ async def sample_list_jobs(): 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.batch_v1.services.batch_service.pagers.ListJobsAsyncPager: @@ -744,7 +784,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"""Return a single Task. @@ -785,8 +825,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.batch_v1.types.Task: @@ -843,7 +885,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"""List Tasks associated with a job. @@ -888,8 +930,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.batch_v1.services.batch_service.pagers.ListTasksAsyncPager: @@ -963,7 +1007,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -974,8 +1018,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1016,7 +1062,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1027,8 +1073,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1069,7 +1117,7 @@ async def delete_operation( *, 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 long-running operation. @@ -1085,8 +1133,10 @@ async def delete_operation( 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: None """ @@ -1123,7 +1173,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1138,8 +1188,10 @@ async def cancel_operation( 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: None """ @@ -1176,7 +1228,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. @@ -1187,8 +1239,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. @@ -1229,7 +1283,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. @@ -1240,8 +1294,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-batch/google/cloud/batch_v1/services/batch_service/client.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/client.py index 22a7a7de0cb6..ebc654ce031a 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/client.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -639,6 +649,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( @@ -701,6 +715,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.batch_v1.BatchServiceClient`.", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "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.batch.v1.BatchService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[batch.CreateJobRequest, dict]] = None, @@ -710,7 +747,7 @@ def create_job( job_id: 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]]] = (), ) -> gcb_job.Job: r"""Create a Job. @@ -774,8 +811,10 @@ def sample_create_job(): 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.batch_v1.types.Job: @@ -835,7 +874,7 @@ def get_job( 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]]] = (), ) -> job.Job: r"""Get a Job specified by its resource name. @@ -876,8 +915,10 @@ def sample_get_job(): 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.batch_v1.types.Job: @@ -933,7 +974,7 @@ def delete_job( 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]]] = (), ) -> operation.Operation: r"""Delete a Job. @@ -977,8 +1018,10 @@ def sample_delete_job(): 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.api_core.operation.Operation: @@ -1054,7 +1097,7 @@ def list_jobs( 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.ListJobsPager: r"""List all Jobs for a project within a region. @@ -1095,8 +1138,10 @@ def sample_list_jobs(): 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.batch_v1.services.batch_service.pagers.ListJobsPager: @@ -1168,7 +1213,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"""Return a single Task. @@ -1209,8 +1254,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.batch_v1.types.Task: @@ -1266,7 +1313,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"""List Tasks associated with a job. @@ -1311,8 +1358,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.batch_v1.services.batch_service.pagers.ListTasksPager: @@ -1396,7 +1445,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1407,8 +1456,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1449,7 +1500,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1460,8 +1511,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1502,7 +1555,7 @@ def delete_operation( *, 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 long-running operation. @@ -1518,8 +1571,10 @@ def delete_operation( 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: None """ @@ -1556,7 +1611,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1571,8 +1626,10 @@ def cancel_operation( 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: None """ @@ -1609,7 +1666,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. @@ -1620,8 +1677,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. @@ -1662,7 +1721,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. @@ -1673,8 +1732,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-batch/google/cloud/batch_v1/services/batch_service/pagers.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/pagers.py index a15be60cf686..4f4dc5225bba 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/pagers.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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 = batch.ListJobsRequest(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 = batch.ListJobsRequest(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 = batch.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 = batch.ListTasksRequest(request) diff --git a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/grpc.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/grpc.py index 33a443a9b3c3..394aaf603b5d 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/grpc.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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 @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.batch_v1.types import batch from google.cloud.batch_v1.types import job @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, BatchServiceTransport +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.batch.v1.BatchService", + "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.batch.v1.BatchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BatchServiceGrpcTransport(BatchServiceTransport): """gRPC backend transport for BatchService. @@ -187,7 +268,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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def create_job(self) -> Callable[[batch.CreateJobRequest], gcb_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/CreateJob", request_serializer=batch.CreateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -297,7 +385,7 @@ def get_job(self) -> Callable[[batch.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/GetJob", request_serializer=batch.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -323,7 +411,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/DeleteJob", request_serializer=batch.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -347,7 +435,7 @@ def list_jobs(self) -> Callable[[batch.ListJobsRequest], batch.ListJobsResponse] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/ListJobs", request_serializer=batch.ListJobsRequest.serialize, response_deserializer=batch.ListJobsResponse.deserialize, @@ -371,7 +459,7 @@ def get_task(self) -> Callable[[batch.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.batch.v1.BatchService/GetTask", request_serializer=batch.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -395,7 +483,7 @@ def list_tasks(self) -> Callable[[batch.ListTasksRequest], batch.ListTasksRespon # 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.batch.v1.BatchService/ListTasks", request_serializer=batch.ListTasksRequest.serialize, response_deserializer=batch.ListTasksResponse.deserialize, @@ -403,7 +491,7 @@ def list_tasks(self) -> Callable[[batch.ListTasksRequest], batch.ListTasksRespon return self._stubs["list_tasks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -415,7 +503,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -432,7 +520,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -449,7 +537,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -468,7 +556,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -487,7 +575,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, @@ -504,7 +592,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-batch/google/cloud/batch_v1/services/batch_service/transports/grpc_asyncio.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/grpc_asyncio.py index 2f2ba85a1631..e684e74c794e 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.batch_v1.types import batch from google.cloud.batch_v1.types import job @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, BatchServiceTransport from .grpc import BatchServiceGrpcTransport +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.batch.v1.BatchService", + "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.batch.v1.BatchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BatchServiceGrpcAsyncIOTransport(BatchServiceTransport): """gRPC AsyncIO backend transport for BatchService. @@ -234,10 +316,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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def create_job(self) -> Callable[[batch.CreateJobRequest], Awaitable[gcb_job.Job # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/CreateJob", request_serializer=batch.CreateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -307,7 +392,7 @@ def get_job(self) -> Callable[[batch.GetJobRequest], Awaitable[job.Job]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/GetJob", request_serializer=batch.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -333,7 +418,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/DeleteJob", request_serializer=batch.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -359,7 +444,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1.BatchService/ListJobs", request_serializer=batch.ListJobsRequest.serialize, response_deserializer=batch.ListJobsResponse.deserialize, @@ -383,7 +468,7 @@ def get_task(self) -> Callable[[batch.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.batch.v1.BatchService/GetTask", request_serializer=batch.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -409,7 +494,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.batch.v1.BatchService/ListTasks", request_serializer=batch.ListTasksRequest.serialize, response_deserializer=batch.ListTasksResponse.deserialize, @@ -523,7 +608,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: @@ -539,7 +624,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -556,7 +641,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -573,7 +658,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -592,7 +677,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -611,7 +696,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, @@ -628,7 +713,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-batch/google/cloud/batch_v1/services/batch_service/transports/rest.py b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/rest.py index ca9bf1f0299b..28e9964eee32 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/transports/rest.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/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 @@ -42,6 +42,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, @@ -120,8 +128,10 @@ def post_list_tasks(self, response): """ def pre_create_job( - self, request: batch.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -139,8 +149,10 @@ def post_create_job(self, response: gcb_job.Job) -> gcb_job.Job: return response def pre_delete_job( - self, request: batch.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -160,8 +172,10 @@ def post_delete_job( return response def pre_get_job( - self, request: batch.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -179,8 +193,10 @@ def post_get_job(self, response: job.Job) -> job.Job: return response def pre_get_task( - self, request: batch.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -198,8 +214,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_list_jobs( - self, request: batch.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -219,8 +237,10 @@ def post_list_jobs( return response def pre_list_tasks( - self, request: batch.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -242,8 +262,10 @@ def post_list_tasks( 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 @@ -265,8 +287,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 @@ -288,8 +312,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -309,8 +335,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -330,8 +358,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -353,8 +383,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -551,7 +583,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]]] = (), ) -> gcb_job.Job: r"""Call the create job method over HTTP. @@ -561,8 +593,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: ~.gcb_job.Job: @@ -572,6 +606,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseCreateJob._get_transcoded_request( @@ -590,6 +625,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.batch_v1.BatchServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CreateJob._get_response( self._host, @@ -611,7 +673,29 @@ def __call__( pb_resp = gcb_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_job.Job.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.batch_v1.BatchServiceClient.create_job", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -648,7 +732,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete job method over HTTP. @@ -658,8 +742,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: ~.operations_pb2.Operation: @@ -672,6 +758,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseDeleteJob._get_transcoded_request( @@ -686,6 +773,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.batch_v1.BatchServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._DeleteJob._get_response( self._host, @@ -704,7 +818,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_job(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.batch_v1.BatchServiceClient.delete_job", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "DeleteJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetJob(_BaseBatchServiceRestTransport._BaseGetJob, BatchServiceRestStub): @@ -739,7 +875,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]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -749,8 +885,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: ~.job.Job: @@ -760,6 +898,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -774,6 +913,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.batch_v1.BatchServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetJob._get_response( self._host, @@ -794,7 +960,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.batch_v1.BatchServiceClient.get_job", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask(_BaseBatchServiceRestTransport._BaseGetTask, BatchServiceRestStub): @@ -829,7 +1017,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. @@ -839,8 +1027,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: @@ -850,6 +1040,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetTask._get_http_options() ) + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetTask._get_transcoded_request( @@ -864,6 +1055,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.batch_v1.BatchServiceClient.GetTask", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetTask._get_response( self._host, @@ -884,7 +1102,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.batch_v1.BatchServiceClient.get_task", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs(_BaseBatchServiceRestTransport._BaseListJobs, BatchServiceRestStub): @@ -919,7 +1159,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]]] = (), ) -> batch.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -929,8 +1169,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: ~.batch.ListJobsResponse: @@ -940,6 +1182,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseListJobs._get_transcoded_request( @@ -954,6 +1197,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.batch_v1.BatchServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListJobs._get_response( self._host, @@ -974,7 +1244,29 @@ def __call__( pb_resp = batch.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = batch.ListJobsResponse.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.batch_v1.BatchServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks( @@ -1011,7 +1303,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]]] = (), ) -> batch.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1021,8 +1313,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: ~.batch.ListTasksResponse: @@ -1032,6 +1326,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseListTasks._get_transcoded_request( @@ -1046,6 +1341,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.batch_v1.BatchServiceClient.ListTasks", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListTasks._get_response( self._host, @@ -1066,7 +1388,29 @@ def __call__( pb_resp = batch.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 = batch.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.batch_v1.BatchServiceClient.list_tasks", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1145,7 +1489,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. @@ -1155,8 +1499,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. @@ -1165,6 +1511,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetLocation._get_transcoded_request( @@ -1179,6 +1526,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.batch_v1.BatchServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetLocation._get_response( self._host, @@ -1198,6 +1572,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.batch_v1.BatchServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1238,7 +1633,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. @@ -1248,8 +1643,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. @@ -1258,6 +1655,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1268,6 +1666,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.batch_v1.BatchServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListLocations._get_response( self._host, @@ -1287,6 +1712,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.batch_v1.BatchServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1328,7 +1774,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1338,13 +1784,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 = ( _BaseBatchServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1361,6 +1810,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.batch_v1.BatchServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CancelOperation._get_response( self._host, @@ -1417,7 +1893,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1427,13 +1903,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 = ( _BaseBatchServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1446,6 +1925,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.batch_v1.BatchServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1501,7 +2007,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1511,8 +2017,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: operations_pb2.Operation: Response from GetOperation method. @@ -1521,6 +2029,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1533,6 +2042,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.batch_v1.BatchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetOperation._get_response( self._host, @@ -1552,6 +2088,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.batch_v1.BatchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1592,7 +2149,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1602,8 +2159,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1612,6 +2171,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1622,6 +2182,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.batch_v1.BatchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListOperations._get_response( self._host, @@ -1641,6 +2228,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.batch_v1.BatchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.batch.v1.BatchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-batch/google/cloud/batch_v1/types/job.py b/packages/google-cloud-batch/google/cloud/batch_v1/types/job.py index 0fd45dd52761..64df7c9ddcc1 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1/types/job.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1/types/job.py @@ -141,22 +141,29 @@ class Job(proto.Message): class LogsPolicy(proto.Message): - r"""LogsPolicy describes how outputs from a Job's Tasks - (stdout/stderr) will be preserved. + r"""LogsPolicy describes if and how a job's logs are preserved. Logs + include information that is automatically written by the Batch + service agent and any information that you configured the job's + runnables to write to the ``stdout`` or ``stderr`` streams. Attributes: destination (google.cloud.batch_v1.types.LogsPolicy.Destination): - Where logs should be saved. + If and where logs should be saved. logs_path (str): - The path to which logs are saved when the - destination = PATH. This can be a local file - path on the VM, or under the mount point of a - Persistent Disk or Filestore, or a Cloud Storage - path. + When ``destination`` is set to ``PATH``, you must set this + field to the path where you want logs to be saved. This path + can point to a local directory on the VM or (if congifured) + a directory under the mount path of any Cloud Storage + bucket, network file system (NFS), or writable persistent + disk that is mounted to the job. For example, if the job has + a bucket with ``mountPath`` set to ``/mnt/disks/my-bucket``, + you can write logs to the root directory of the + ``remotePath`` of that bucket by setting this field to + ``/mnt/disks/my-bucket/``. cloud_logging_option (google.cloud.batch_v1.types.LogsPolicy.CloudLoggingOption): - Optional. Additional settings for Cloud Logging. It will - only take effect when the destination of ``LogsPolicy`` is - set to ``CLOUD_LOGGING``. + Optional. When ``destination`` is set to ``CLOUD_LOGGING``, + you can optionally set this field to configure additional + settings for Cloud Logging. """ class Destination(proto.Enum): @@ -164,11 +171,14 @@ class Destination(proto.Enum): Values: DESTINATION_UNSPECIFIED (0): - Logs are not preserved. + (Default) Logs are not preserved. CLOUD_LOGGING (1): - Logs are streamed to Cloud Logging. + Logs are streamed to Cloud Logging. Optionally, you can + configure additional settings in the ``cloudLoggingOption`` + field. PATH (2): - Logs are saved to a file path. + Logs are saved to the file path specified in the + ``logsPath`` field. """ DESTINATION_UNSPECIFIED = 0 CLOUD_LOGGING = 1 @@ -180,8 +190,8 @@ class CloudLoggingOption(proto.Message): Attributes: use_generic_task_monitored_resource (bool): - Optional. Set this flag to true to change the `monitored - resource + Optional. Set this field to ``true`` to change the + `monitored resource type `__ for Cloud Logging logs generated by this Batch job from the ```batch.googleapis.com/Job`` `__ @@ -739,10 +749,10 @@ class InstancePolicy(proto.Message): file system or a raw storage drive that is not ready for data storage and accessing. reservation (str): - Optional. If specified, VMs will consume only the specified - reservation. If not specified (default), VMs will consume - any applicable reservation. Additionally, VMs will not - consume any reservation if "NO_RESERVATION" is specified. + Optional. If not specified (default), VMs will consume any + applicable reservation. If "NO_RESERVATION" is specified, + VMs will not consume any reservation. Otherwise, if + specified, VMs will consume only the specified reservation. """ machine_type: str = proto.Field( @@ -804,9 +814,9 @@ class InstancePolicyOrTemplate(proto.Message): field as 'instance_template' instead of 'template' to avoid C++ keyword conflict. - Batch only supports global instance templates. You can - specify the global instance template as a full or partial - URL. + Batch only supports global instance templates from the same + project as the job. You can specify the global instance + template as a full or partial URL. This field is a member of `oneof`_ ``policy_template``. install_gpu_drivers (bool): diff --git a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/async_client.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/async_client.py index 72842b65808a..5be36827accf 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/async_client.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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, @@ -65,6 +66,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, BatchServiceTransport from .transports.grpc_asyncio import BatchServiceGrpcAsyncIOTransport +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 BatchServiceAsyncClient: """Google Batch Service. @@ -277,6 +287,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.batch_v1alpha.BatchServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "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.batch.v1alpha.BatchService", + "credentialsType": None, + }, + ) + async def create_job( self, request: Optional[Union[batch.CreateJobRequest, dict]] = None, @@ -286,7 +318,7 @@ async def create_job( job_id: 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]]] = (), ) -> gcb_job.Job: r"""Create a Job. @@ -350,8 +382,10 @@ async def sample_create_job(): 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.batch_v1alpha.types.Job: @@ -414,7 +448,7 @@ async def get_job( 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]]] = (), ) -> job.Job: r"""Get a Job specified by its resource name. @@ -455,8 +489,10 @@ async def sample_get_job(): 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.batch_v1alpha.types.Job: @@ -513,7 +549,7 @@ async def delete_job( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a Job. @@ -557,8 +593,10 @@ async def sample_delete_job(): 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.api_core.operation_async.AsyncOperation: @@ -637,7 +675,7 @@ async def cancel_job( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Cancel a Job. @@ -682,8 +720,10 @@ async def sample_cancel_job(): 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.api_core.operation_async.AsyncOperation: @@ -756,7 +796,7 @@ async def update_job( 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]]] = (), ) -> gcb_job.Job: r"""Update a Job. @@ -824,8 +864,10 @@ async def sample_update_job(): 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.batch_v1alpha.types.Job: @@ -886,7 +928,7 @@ async def list_jobs( 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.ListJobsAsyncPager: r"""List all Jobs for a project within a region. @@ -927,8 +969,10 @@ async def sample_list_jobs(): 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.batch_v1alpha.services.batch_service.pagers.ListJobsAsyncPager: @@ -1003,7 +1047,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"""Return a single Task. @@ -1044,8 +1088,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.batch_v1alpha.types.Task: @@ -1102,7 +1148,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"""List Tasks associated with a job. @@ -1147,8 +1193,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.batch_v1alpha.services.batch_service.pagers.ListTasksAsyncPager: @@ -1225,7 +1273,7 @@ async def create_resource_allowance( resource_allowance_id: 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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Create a Resource Allowance. @@ -1299,8 +1347,10 @@ async def sample_create_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -1367,7 +1417,7 @@ async def get_resource_allowance( 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]]] = (), ) -> resource_allowance.ResourceAllowance: r"""Get a ResourceAllowance specified by its resource name. @@ -1409,8 +1459,10 @@ async def sample_get_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -1473,7 +1525,7 @@ async def delete_resource_allowance( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Delete a ResourceAllowance. @@ -1518,8 +1570,10 @@ async def sample_delete_resource_allowance(): 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.api_core.operation_async.AsyncOperation: @@ -1598,7 +1652,7 @@ async def list_resource_allowances( 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.ListResourceAllowancesAsyncPager: r"""List all ResourceAllowances for a project within a region. @@ -1641,8 +1695,10 @@ async def sample_list_resource_allowances(): 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.batch_v1alpha.services.batch_service.pagers.ListResourceAllowancesAsyncPager: @@ -1718,7 +1774,7 @@ async def update_resource_allowance( 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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Update a Resource Allowance. @@ -1783,8 +1839,10 @@ async def sample_update_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -1850,7 +1908,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1861,8 +1919,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1903,7 +1963,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1914,8 +1974,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1956,7 +2018,7 @@ async def delete_operation( *, 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 long-running operation. @@ -1972,8 +2034,10 @@ async def delete_operation( 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: None """ @@ -2010,7 +2074,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2025,8 +2089,10 @@ async def cancel_operation( 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: None """ @@ -2063,7 +2129,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. @@ -2074,8 +2140,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. @@ -2116,7 +2184,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. @@ -2127,8 +2195,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-batch/google/cloud/batch_v1alpha/services/batch_service/client.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/client.py index b8db242b68b7..00e0a1b408c5 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/client.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -667,6 +677,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( @@ -729,6 +743,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.batch_v1alpha.BatchServiceClient`.", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "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.batch.v1alpha.BatchService", + "credentialsType": None, + }, + ) + def create_job( self, request: Optional[Union[batch.CreateJobRequest, dict]] = None, @@ -738,7 +775,7 @@ def create_job( job_id: 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]]] = (), ) -> gcb_job.Job: r"""Create a Job. @@ -802,8 +839,10 @@ def sample_create_job(): 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.batch_v1alpha.types.Job: @@ -863,7 +902,7 @@ def get_job( 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]]] = (), ) -> job.Job: r"""Get a Job specified by its resource name. @@ -904,8 +943,10 @@ def sample_get_job(): 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.batch_v1alpha.types.Job: @@ -961,7 +1002,7 @@ def delete_job( 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]]] = (), ) -> operation.Operation: r"""Delete a Job. @@ -1005,8 +1046,10 @@ def sample_delete_job(): 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.api_core.operation.Operation: @@ -1082,7 +1125,7 @@ def cancel_job( 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]]] = (), ) -> operation.Operation: r"""Cancel a Job. @@ -1127,8 +1170,10 @@ def sample_cancel_job(): 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.api_core.operation.Operation: @@ -1198,7 +1243,7 @@ def update_job( 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]]] = (), ) -> gcb_job.Job: r"""Update a Job. @@ -1266,8 +1311,10 @@ def sample_update_job(): 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.batch_v1alpha.types.Job: @@ -1325,7 +1372,7 @@ def list_jobs( 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.ListJobsPager: r"""List all Jobs for a project within a region. @@ -1366,8 +1413,10 @@ def sample_list_jobs(): 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.batch_v1alpha.services.batch_service.pagers.ListJobsPager: @@ -1439,7 +1488,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"""Return a single Task. @@ -1480,8 +1529,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.batch_v1alpha.types.Task: @@ -1537,7 +1588,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"""List Tasks associated with a job. @@ -1582,8 +1633,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.batch_v1alpha.services.batch_service.pagers.ListTasksPager: @@ -1657,7 +1710,7 @@ def create_resource_allowance( resource_allowance_id: 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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Create a Resource Allowance. @@ -1731,8 +1784,10 @@ def sample_create_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -1798,7 +1853,7 @@ def get_resource_allowance( 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]]] = (), ) -> resource_allowance.ResourceAllowance: r"""Get a ResourceAllowance specified by its resource name. @@ -1840,8 +1895,10 @@ def sample_get_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -1901,7 +1958,7 @@ def delete_resource_allowance( 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]]] = (), ) -> operation.Operation: r"""Delete a ResourceAllowance. @@ -1946,8 +2003,10 @@ def sample_delete_resource_allowance(): 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.api_core.operation.Operation: @@ -2025,7 +2084,7 @@ def list_resource_allowances( 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.ListResourceAllowancesPager: r"""List all ResourceAllowances for a project within a region. @@ -2068,8 +2127,10 @@ def sample_list_resource_allowances(): 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.batch_v1alpha.services.batch_service.pagers.ListResourceAllowancesPager: @@ -2142,7 +2203,7 @@ def update_resource_allowance( 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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Update a Resource Allowance. @@ -2207,8 +2268,10 @@ def sample_update_resource_allowance(): 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.batch_v1alpha.types.ResourceAllowance: @@ -2286,7 +2349,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2297,8 +2360,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2339,7 +2404,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2350,8 +2415,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2392,7 +2459,7 @@ def delete_operation( *, 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 long-running operation. @@ -2408,8 +2475,10 @@ def delete_operation( 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: None """ @@ -2446,7 +2515,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2461,8 +2530,10 @@ def cancel_operation( 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: None """ @@ -2499,7 +2570,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. @@ -2510,8 +2581,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. @@ -2552,7 +2625,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. @@ -2563,8 +2636,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-batch/google/cloud/batch_v1alpha/services/batch_service/pagers.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/pagers.py index 4d01baed6669..b6d76a2a7a30 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/pagers.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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 = batch.ListJobsRequest(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 = batch.ListJobsRequest(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 = batch.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 = batch.ListTasksRequest(request) @@ -371,7 +379,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. @@ -385,8 +393,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 = batch.ListResourceAllowancesRequest(request) @@ -445,7 +455,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. @@ -459,8 +469,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 = batch.ListResourceAllowancesRequest(request) diff --git a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc.py index b723e9d7f161..8d356b9a1189 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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 @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.batch_v1alpha.types import ( resource_allowance as gcb_resource_allowance, @@ -35,6 +41,81 @@ from .base import DEFAULT_CLIENT_INFO, BatchServiceTransport +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.batch.v1alpha.BatchService", + "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.batch.v1alpha.BatchService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BatchServiceGrpcTransport(BatchServiceTransport): """gRPC backend transport for BatchService. @@ -191,7 +272,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 @@ -255,7 +341,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def create_job(self) -> Callable[[batch.CreateJobRequest], gcb_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CreateJob", request_serializer=batch.CreateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -301,7 +389,7 @@ def get_job(self) -> Callable[[batch.GetJobRequest], job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/GetJob", request_serializer=batch.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -327,7 +415,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/DeleteJob", request_serializer=batch.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def cancel_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_job" not in self._stubs: - self._stubs["cancel_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CancelJob", request_serializer=batch.CancelJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +465,7 @@ def update_job(self) -> Callable[[batch.UpdateJobRequest], gcb_job.Job]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/UpdateJob", request_serializer=batch.UpdateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -401,7 +489,7 @@ def list_jobs(self) -> Callable[[batch.ListJobsRequest], batch.ListJobsResponse] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/ListJobs", request_serializer=batch.ListJobsRequest.serialize, response_deserializer=batch.ListJobsResponse.deserialize, @@ -425,7 +513,7 @@ def get_task(self) -> Callable[[batch.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.batch.v1alpha.BatchService/GetTask", request_serializer=batch.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -449,7 +537,7 @@ def list_tasks(self) -> Callable[[batch.ListTasksRequest], batch.ListTasksRespon # 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.batch.v1alpha.BatchService/ListTasks", request_serializer=batch.ListTasksRequest.serialize, response_deserializer=batch.ListTasksResponse.deserialize, @@ -477,7 +565,7 @@ def create_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_resource_allowance" not in self._stubs: - self._stubs["create_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["create_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CreateResourceAllowance", request_serializer=batch.CreateResourceAllowanceRequest.serialize, response_deserializer=gcb_resource_allowance.ResourceAllowance.deserialize, @@ -506,7 +594,7 @@ def get_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_allowance" not in self._stubs: - self._stubs["get_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/GetResourceAllowance", request_serializer=batch.GetResourceAllowanceRequest.serialize, response_deserializer=resource_allowance.ResourceAllowance.deserialize, @@ -532,7 +620,7 @@ def delete_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_allowance" not in self._stubs: - self._stubs["delete_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["delete_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/DeleteResourceAllowance", request_serializer=batch.DeleteResourceAllowanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -561,7 +649,7 @@ def list_resource_allowances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_allowances" not in self._stubs: - self._stubs["list_resource_allowances"] = self.grpc_channel.unary_unary( + self._stubs["list_resource_allowances"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/ListResourceAllowances", request_serializer=batch.ListResourceAllowancesRequest.serialize, response_deserializer=batch.ListResourceAllowancesResponse.deserialize, @@ -589,7 +677,7 @@ def update_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_allowance" not in self._stubs: - self._stubs["update_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["update_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/UpdateResourceAllowance", request_serializer=batch.UpdateResourceAllowanceRequest.serialize, response_deserializer=gcb_resource_allowance.ResourceAllowance.deserialize, @@ -597,7 +685,7 @@ def update_resource_allowance( return self._stubs["update_resource_allowance"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -609,7 +697,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -626,7 +714,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -643,7 +731,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -662,7 +750,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -681,7 +769,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, @@ -698,7 +786,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-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc_asyncio.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc_asyncio.py index af20c6190656..e6194dd430c5 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.batch_v1alpha.types import ( resource_allowance as gcb_resource_allowance, @@ -39,6 +45,82 @@ from .base import DEFAULT_CLIENT_INFO, BatchServiceTransport from .grpc import BatchServiceGrpcTransport +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.batch.v1alpha.BatchService", + "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.batch.v1alpha.BatchService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BatchServiceGrpcAsyncIOTransport(BatchServiceTransport): """gRPC AsyncIO backend transport for BatchService. @@ -238,10 +320,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 @@ -264,7 +349,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def create_job(self) -> Callable[[batch.CreateJobRequest], Awaitable[gcb_job.Job # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_job" not in self._stubs: - self._stubs["create_job"] = self.grpc_channel.unary_unary( + self._stubs["create_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CreateJob", request_serializer=batch.CreateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -311,7 +396,7 @@ def get_job(self) -> Callable[[batch.GetJobRequest], Awaitable[job.Job]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_job" not in self._stubs: - self._stubs["get_job"] = self.grpc_channel.unary_unary( + self._stubs["get_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/GetJob", request_serializer=batch.GetJobRequest.serialize, response_deserializer=job.Job.deserialize, @@ -337,7 +422,7 @@ def delete_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_job" not in self._stubs: - self._stubs["delete_job"] = self.grpc_channel.unary_unary( + self._stubs["delete_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/DeleteJob", request_serializer=batch.DeleteJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -363,7 +448,7 @@ def cancel_job( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_job" not in self._stubs: - self._stubs["cancel_job"] = self.grpc_channel.unary_unary( + self._stubs["cancel_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CancelJob", request_serializer=batch.CancelJobRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +472,7 @@ def update_job(self) -> Callable[[batch.UpdateJobRequest], Awaitable[gcb_job.Job # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_job" not in self._stubs: - self._stubs["update_job"] = self.grpc_channel.unary_unary( + self._stubs["update_job"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/UpdateJob", request_serializer=batch.UpdateJobRequest.serialize, response_deserializer=gcb_job.Job.deserialize, @@ -413,7 +498,7 @@ def list_jobs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_jobs" not in self._stubs: - self._stubs["list_jobs"] = self.grpc_channel.unary_unary( + self._stubs["list_jobs"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/ListJobs", request_serializer=batch.ListJobsRequest.serialize, response_deserializer=batch.ListJobsResponse.deserialize, @@ -437,7 +522,7 @@ def get_task(self) -> Callable[[batch.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.batch.v1alpha.BatchService/GetTask", request_serializer=batch.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -463,7 +548,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.batch.v1alpha.BatchService/ListTasks", request_serializer=batch.ListTasksRequest.serialize, response_deserializer=batch.ListTasksResponse.deserialize, @@ -492,7 +577,7 @@ def create_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_resource_allowance" not in self._stubs: - self._stubs["create_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["create_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/CreateResourceAllowance", request_serializer=batch.CreateResourceAllowanceRequest.serialize, response_deserializer=gcb_resource_allowance.ResourceAllowance.deserialize, @@ -522,7 +607,7 @@ def get_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource_allowance" not in self._stubs: - self._stubs["get_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["get_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/GetResourceAllowance", request_serializer=batch.GetResourceAllowanceRequest.serialize, response_deserializer=resource_allowance.ResourceAllowance.deserialize, @@ -550,7 +635,7 @@ def delete_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_resource_allowance" not in self._stubs: - self._stubs["delete_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["delete_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/DeleteResourceAllowance", request_serializer=batch.DeleteResourceAllowanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -580,7 +665,7 @@ def list_resource_allowances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resource_allowances" not in self._stubs: - self._stubs["list_resource_allowances"] = self.grpc_channel.unary_unary( + self._stubs["list_resource_allowances"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/ListResourceAllowances", request_serializer=batch.ListResourceAllowancesRequest.serialize, response_deserializer=batch.ListResourceAllowancesResponse.deserialize, @@ -609,7 +694,7 @@ def update_resource_allowance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_resource_allowance" not in self._stubs: - self._stubs["update_resource_allowance"] = self.grpc_channel.unary_unary( + self._stubs["update_resource_allowance"] = self._logged_channel.unary_unary( "/google.cloud.batch.v1alpha.BatchService/UpdateResourceAllowance", request_serializer=batch.UpdateResourceAllowanceRequest.serialize, response_deserializer=gcb_resource_allowance.ResourceAllowance.deserialize, @@ -776,7 +861,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: @@ -792,7 +877,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -809,7 +894,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -826,7 +911,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -845,7 +930,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -864,7 +949,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, @@ -881,7 +966,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-batch/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py index 0dde09cd9956..14751deec0bf 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/rest.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/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 @@ -46,6 +46,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, @@ -180,8 +188,10 @@ def post_update_resource_allowance(self, response): """ def pre_cancel_job( - self, request: batch.CancelJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.CancelJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.CancelJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.CancelJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for cancel_job Override in a subclass to manipulate the request or metadata @@ -201,8 +211,10 @@ def post_cancel_job( return response def pre_create_job( - self, request: batch.CreateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.CreateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.CreateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_job Override in a subclass to manipulate the request or metadata @@ -222,8 +234,10 @@ def post_create_job(self, response: gcb_job.Job) -> gcb_job.Job: def pre_create_resource_allowance( self, request: batch.CreateResourceAllowanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[batch.CreateResourceAllowanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + batch.CreateResourceAllowanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_resource_allowance Override in a subclass to manipulate the request or metadata @@ -243,8 +257,10 @@ def post_create_resource_allowance( return response def pre_delete_job( - self, request: batch.DeleteJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.DeleteJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.DeleteJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_job Override in a subclass to manipulate the request or metadata @@ -266,8 +282,10 @@ def post_delete_job( def pre_delete_resource_allowance( self, request: batch.DeleteResourceAllowanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[batch.DeleteResourceAllowanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + batch.DeleteResourceAllowanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_resource_allowance Override in a subclass to manipulate the request or metadata @@ -287,8 +305,10 @@ def post_delete_resource_allowance( return response def pre_get_job( - self, request: batch.GetJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.GetJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.GetJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_job Override in a subclass to manipulate the request or metadata @@ -308,8 +328,10 @@ def post_get_job(self, response: job.Job) -> job.Job: def pre_get_resource_allowance( self, request: batch.GetResourceAllowanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[batch.GetResourceAllowanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + batch.GetResourceAllowanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_resource_allowance Override in a subclass to manipulate the request or metadata @@ -329,8 +351,10 @@ def post_get_resource_allowance( return response def pre_get_task( - self, request: batch.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -348,8 +372,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_list_jobs( - self, request: batch.ListJobsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.ListJobsRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.ListJobsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_jobs Override in a subclass to manipulate the request or metadata @@ -371,8 +397,10 @@ def post_list_jobs( def pre_list_resource_allowances( self, request: batch.ListResourceAllowancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[batch.ListResourceAllowancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + batch.ListResourceAllowancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_resource_allowances Override in a subclass to manipulate the request or metadata @@ -392,8 +420,10 @@ def post_list_resource_allowances( return response def pre_list_tasks( - self, request: batch.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -413,8 +443,10 @@ def post_list_tasks( return response def pre_update_job( - self, request: batch.UpdateJobRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[batch.UpdateJobRequest, Sequence[Tuple[str, str]]]: + self, + request: batch.UpdateJobRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[batch.UpdateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_job Override in a subclass to manipulate the request or metadata @@ -434,8 +466,10 @@ def post_update_job(self, response: gcb_job.Job) -> gcb_job.Job: def pre_update_resource_allowance( self, request: batch.UpdateResourceAllowanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[batch.UpdateResourceAllowanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + batch.UpdateResourceAllowanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_resource_allowance Override in a subclass to manipulate the request or metadata @@ -457,8 +491,10 @@ def post_update_resource_allowance( 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 @@ -480,8 +516,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 @@ -503,8 +541,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -524,8 +564,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -545,8 +587,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -568,8 +612,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -766,7 +812,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]]] = (), ) -> operations_pb2.Operation: r"""Call the cancel job method over HTTP. @@ -776,8 +822,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: ~.operations_pb2.Operation: @@ -790,6 +838,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseCancelJob._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseCancelJob._get_transcoded_request( @@ -808,6 +857,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.batch_v1alpha.BatchServiceClient.CancelJob", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CancelJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CancelJob._get_response( self._host, @@ -827,7 +903,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_job(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.batch_v1alpha.BatchServiceClient.cancel_job", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CancelJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateJob( @@ -865,7 +963,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]]] = (), ) -> gcb_job.Job: r"""Call the create job method over HTTP. @@ -875,8 +973,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: ~.gcb_job.Job: @@ -886,6 +986,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseCreateJob._get_http_options() ) + request, metadata = self._interceptor.pre_create_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseCreateJob._get_transcoded_request( @@ -904,6 +1005,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.batch_v1alpha.BatchServiceClient.CreateJob", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CreateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CreateJob._get_response( self._host, @@ -925,7 +1053,29 @@ def __call__( pb_resp = gcb_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_job.Job.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.batch_v1alpha.BatchServiceClient.create_job", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CreateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateResourceAllowance( @@ -964,7 +1114,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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Call the create resource allowance method over HTTP. @@ -974,8 +1124,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: ~.gcb_resource_allowance.ResourceAllowance: @@ -989,6 +1141,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseCreateResourceAllowance._get_http_options() ) + request, metadata = self._interceptor.pre_create_resource_allowance( request, metadata ) @@ -1005,6 +1158,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 = 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.batch_v1alpha.BatchServiceClient.CreateResourceAllowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CreateResourceAllowance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CreateResourceAllowance._get_response( self._host, @@ -1026,7 +1206,31 @@ def __call__( pb_resp = gcb_resource_allowance.ResourceAllowance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_resource_allowance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_resource_allowance.ResourceAllowance.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.batch_v1alpha.BatchServiceClient.create_resource_allowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CreateResourceAllowance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteJob( @@ -1063,7 +1267,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete job method over HTTP. @@ -1073,8 +1277,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: ~.operations_pb2.Operation: @@ -1087,6 +1293,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseDeleteJob._get_http_options() ) + request, metadata = self._interceptor.pre_delete_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseDeleteJob._get_transcoded_request( @@ -1101,6 +1308,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.batch_v1alpha.BatchServiceClient.DeleteJob", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "DeleteJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._DeleteJob._get_response( self._host, @@ -1119,7 +1353,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_job(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.batch_v1alpha.BatchServiceClient.delete_job", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "DeleteJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteResourceAllowance( @@ -1157,7 +1413,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete resource allowance method over HTTP. @@ -1167,8 +1423,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: ~.operations_pb2.Operation: @@ -1181,6 +1439,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseDeleteResourceAllowance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_resource_allowance( request, metadata ) @@ -1193,6 +1452,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.batch_v1alpha.BatchServiceClient.DeleteResourceAllowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "DeleteResourceAllowance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._DeleteResourceAllowance._get_response( self._host, @@ -1211,7 +1497,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_resource_allowance(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.batch_v1alpha.BatchServiceClient.delete_resource_allowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "DeleteResourceAllowance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetJob(_BaseBatchServiceRestTransport._BaseGetJob, BatchServiceRestStub): @@ -1246,7 +1554,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]]] = (), ) -> job.Job: r"""Call the get job method over HTTP. @@ -1256,8 +1564,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: ~.job.Job: @@ -1267,6 +1577,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetJob._get_http_options() ) + request, metadata = self._interceptor.pre_get_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetJob._get_transcoded_request( @@ -1281,6 +1592,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.batch_v1alpha.BatchServiceClient.GetJob", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetJob._get_response( self._host, @@ -1301,7 +1639,29 @@ def __call__( pb_resp = job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = job.Job.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.batch_v1alpha.BatchServiceClient.get_job", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetResourceAllowance( @@ -1338,7 +1698,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]]] = (), ) -> resource_allowance.ResourceAllowance: r"""Call the get resource allowance method over HTTP. @@ -1348,8 +1708,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: ~.resource_allowance.ResourceAllowance: @@ -1363,6 +1725,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetResourceAllowance._get_http_options() ) + request, metadata = self._interceptor.pre_get_resource_allowance( request, metadata ) @@ -1375,6 +1738,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 = 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.batch_v1alpha.BatchServiceClient.GetResourceAllowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetResourceAllowance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetResourceAllowance._get_response( self._host, @@ -1395,7 +1785,31 @@ def __call__( pb_resp = resource_allowance.ResourceAllowance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_resource_allowance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource_allowance.ResourceAllowance.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.batch_v1alpha.BatchServiceClient.get_resource_allowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetResourceAllowance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask(_BaseBatchServiceRestTransport._BaseGetTask, BatchServiceRestStub): @@ -1430,7 +1844,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. @@ -1440,8 +1854,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: @@ -1451,6 +1867,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetTask._get_http_options() ) + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetTask._get_transcoded_request( @@ -1465,6 +1882,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.batch_v1alpha.BatchServiceClient.GetTask", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetTask._get_response( self._host, @@ -1485,7 +1929,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.batch_v1alpha.BatchServiceClient.get_task", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListJobs(_BaseBatchServiceRestTransport._BaseListJobs, BatchServiceRestStub): @@ -1520,7 +1986,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]]] = (), ) -> batch.ListJobsResponse: r"""Call the list jobs method over HTTP. @@ -1530,8 +1996,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: ~.batch.ListJobsResponse: @@ -1541,6 +2009,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListJobs._get_http_options() ) + request, metadata = self._interceptor.pre_list_jobs(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseListJobs._get_transcoded_request( @@ -1555,6 +2024,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.batch_v1alpha.BatchServiceClient.ListJobs", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListJobs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListJobs._get_response( self._host, @@ -1575,7 +2071,29 @@ def __call__( pb_resp = batch.ListJobsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_jobs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = batch.ListJobsResponse.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.batch_v1alpha.BatchServiceClient.list_jobs", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListJobs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListResourceAllowances( @@ -1612,7 +2130,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]]] = (), ) -> batch.ListResourceAllowancesResponse: r"""Call the list resource allowances method over HTTP. @@ -1622,8 +2140,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: ~.batch.ListResourceAllowancesResponse: @@ -1633,6 +2153,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListResourceAllowances._get_http_options() ) + request, metadata = self._interceptor.pre_list_resource_allowances( request, metadata ) @@ -1645,6 +2166,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 = 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.batch_v1alpha.BatchServiceClient.ListResourceAllowances", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListResourceAllowances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListResourceAllowances._get_response( self._host, @@ -1665,7 +2213,31 @@ def __call__( pb_resp = batch.ListResourceAllowancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_resource_allowances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = batch.ListResourceAllowancesResponse.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.batch_v1alpha.BatchServiceClient.list_resource_allowances", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListResourceAllowances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks( @@ -1702,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]]] = (), ) -> batch.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1712,8 +2284,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: ~.batch.ListTasksResponse: @@ -1723,6 +2297,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseListTasks._get_transcoded_request( @@ -1737,6 +2312,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.batch_v1alpha.BatchServiceClient.ListTasks", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListTasks._get_response( self._host, @@ -1757,7 +2359,29 @@ def __call__( pb_resp = batch.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 = batch.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.batch_v1alpha.BatchServiceClient.list_tasks", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateJob( @@ -1795,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]]] = (), ) -> gcb_job.Job: r"""Call the update job method over HTTP. @@ -1805,8 +2429,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: ~.gcb_job.Job: @@ -1816,6 +2442,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseUpdateJob._get_http_options() ) + request, metadata = self._interceptor.pre_update_job(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseUpdateJob._get_transcoded_request( @@ -1834,6 +2461,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.batch_v1alpha.BatchServiceClient.UpdateJob", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "UpdateJob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._UpdateJob._get_response( self._host, @@ -1855,7 +2509,29 @@ def __call__( pb_resp = gcb_job.Job.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_job(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_job.Job.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.batch_v1alpha.BatchServiceClient.update_job", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "UpdateJob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateResourceAllowance( @@ -1894,7 +2570,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]]] = (), ) -> gcb_resource_allowance.ResourceAllowance: r"""Call the update resource allowance method over HTTP. @@ -1904,8 +2580,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: ~.gcb_resource_allowance.ResourceAllowance: @@ -1919,6 +2597,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseUpdateResourceAllowance._get_http_options() ) + request, metadata = self._interceptor.pre_update_resource_allowance( request, metadata ) @@ -1935,6 +2614,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 = 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.batch_v1alpha.BatchServiceClient.UpdateResourceAllowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "UpdateResourceAllowance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._UpdateResourceAllowance._get_response( self._host, @@ -1956,7 +2662,31 @@ def __call__( pb_resp = gcb_resource_allowance.ResourceAllowance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_resource_allowance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_resource_allowance.ResourceAllowance.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.batch_v1alpha.BatchServiceClient.update_resource_allowance", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "UpdateResourceAllowance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2097,7 +2827,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. @@ -2107,8 +2837,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. @@ -2117,6 +2849,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseBatchServiceRestTransport._BaseGetLocation._get_transcoded_request( @@ -2131,6 +2864,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.batch_v1alpha.BatchServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetLocation._get_response( self._host, @@ -2150,6 +2910,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.batch_v1alpha.BatchServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2190,7 +2971,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. @@ -2200,8 +2981,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. @@ -2210,6 +2993,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2220,6 +3004,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.batch_v1alpha.BatchServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListLocations._get_response( self._host, @@ -2239,6 +3050,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.batch_v1alpha.BatchServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2280,7 +3112,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2290,13 +3122,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 = ( _BaseBatchServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2313,6 +3148,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.batch_v1alpha.BatchServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._CancelOperation._get_response( self._host, @@ -2369,7 +3231,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2379,13 +3241,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 = ( _BaseBatchServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2398,6 +3263,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.batch_v1alpha.BatchServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._DeleteOperation._get_response( self._host, @@ -2453,7 +3345,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2463,8 +3355,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: operations_pb2.Operation: Response from GetOperation method. @@ -2473,6 +3367,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2485,6 +3380,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.batch_v1alpha.BatchServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._GetOperation._get_response( self._host, @@ -2504,6 +3426,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.batch_v1alpha.BatchServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2544,7 +3487,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2554,8 +3497,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2564,6 +3509,7 @@ def __call__( http_options = ( _BaseBatchServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseBatchServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2574,6 +3520,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.batch_v1alpha.BatchServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BatchServiceRestTransport._ListOperations._get_response( self._host, @@ -2593,6 +3566,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.batch_v1alpha.BatchServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.batch.v1alpha.BatchService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-batch/google/cloud/batch_v1alpha/types/job.py b/packages/google-cloud-batch/google/cloud/batch_v1alpha/types/job.py index c0604d90ceec..35a7daa6bb5b 100644 --- a/packages/google-cloud-batch/google/cloud/batch_v1alpha/types/job.py +++ b/packages/google-cloud-batch/google/cloud/batch_v1alpha/types/job.py @@ -181,22 +181,29 @@ class SchedulingPolicy(proto.Enum): class LogsPolicy(proto.Message): - r"""LogsPolicy describes how outputs from a Job's Tasks - (stdout/stderr) will be preserved. + r"""LogsPolicy describes if and how a job's logs are preserved. Logs + include information that is automatically written by the Batch + service agent and any information that you configured the job's + runnables to write to the ``stdout`` or ``stderr`` streams. Attributes: destination (google.cloud.batch_v1alpha.types.LogsPolicy.Destination): - Where logs should be saved. + If and where logs should be saved. logs_path (str): - The path to which logs are saved when the - destination = PATH. This can be a local file - path on the VM, or under the mount point of a - Persistent Disk or Filestore, or a Cloud Storage - path. + When ``destination`` is set to ``PATH``, you must set this + field to the path where you want logs to be saved. This path + can point to a local directory on the VM or (if congifured) + a directory under the mount path of any Cloud Storage + bucket, network file system (NFS), or writable persistent + disk that is mounted to the job. For example, if the job has + a bucket with ``mountPath`` set to ``/mnt/disks/my-bucket``, + you can write logs to the root directory of the + ``remotePath`` of that bucket by setting this field to + ``/mnt/disks/my-bucket/``. cloud_logging_option (google.cloud.batch_v1alpha.types.LogsPolicy.CloudLoggingOption): - Optional. Additional settings for Cloud Logging. It will - only take effect when the destination of ``LogsPolicy`` is - set to ``CLOUD_LOGGING``. + Optional. When ``destination`` is set to ``CLOUD_LOGGING``, + you can optionally set this field to configure additional + settings for Cloud Logging. """ class Destination(proto.Enum): @@ -204,11 +211,14 @@ class Destination(proto.Enum): Values: DESTINATION_UNSPECIFIED (0): - Logs are not preserved. + (Default) Logs are not preserved. CLOUD_LOGGING (1): - Logs are streamed to Cloud Logging. + Logs are streamed to Cloud Logging. Optionally, you can + configure additional settings in the ``cloudLoggingOption`` + field. PATH (2): - Logs are saved to a file path. + Logs are saved to the file path specified in the + ``logsPath`` field. """ DESTINATION_UNSPECIFIED = 0 CLOUD_LOGGING = 1 @@ -220,8 +230,8 @@ class CloudLoggingOption(proto.Message): Attributes: use_generic_task_monitored_resource (bool): - Optional. Set this flag to true to change the `monitored - resource + Optional. Set this field to ``true`` to change the + `monitored resource type `__ for Cloud Logging logs generated by this Batch job from the ```batch.googleapis.com/Job`` `__ @@ -940,9 +950,9 @@ class InstancePolicyOrTemplate(proto.Message): field as 'instance_template' instead of 'template' to avoid C++ keyword conflict. - Batch only supports global instance templates. You can - specify the global instance template as a full or partial - URL. + Batch only supports global instance templates from the same + project as the job. You can specify the global instance + template as a full or partial URL. This field is a member of `oneof`_ ``policy_template``. install_gpu_drivers (bool): diff --git a/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json b/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json index e2df1067e4dd..4e0fce836f45 100644 --- a/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json +++ b/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Job", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Job", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Job", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Job", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Task", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.types.Task", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.services.batch_service.pagers.ListJobsAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.services.batch_service.pagers.ListJobsPager", @@ -868,7 +868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.services.batch_service.pagers.ListTasksAsyncPager", @@ -948,7 +948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1.services.batch_service.pagers.ListTasksPager", diff --git a/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json b/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json index 7f67670b100c..981b9c62ced1 100644 --- a/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json +++ b/packages/google-cloud-batch/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -1045,7 +1045,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Task", @@ -1286,7 +1286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Task", @@ -1367,7 +1367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListJobsAsyncPager", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListJobsPager", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListResourceAllowancesAsyncPager", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListResourceAllowancesPager", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListTasksAsyncPager", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.services.batch_service.pagers.ListTasksPager", @@ -1854,7 +1854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.Job", @@ -2023,7 +2023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", @@ -2107,7 +2107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.batch_v1alpha.types.ResourceAllowance", diff --git a/packages/google-cloud-batch/tests/unit/gapic/batch_v1/test_batch_service.py b/packages/google-cloud-batch/tests/unit/gapic/batch_v1/test_batch_service.py index 6f372d5128c2..e39ed8710d54 100644 --- a/packages/google-cloud-batch/tests/unit/gapic/batch_v1/test_batch_service.py +++ b/packages/google-cloud-batch/tests/unit/gapic/batch_v1/test_batch_service.py @@ -3530,6 +3530,7 @@ def test_create_job_rest_required_fields(request_type=batch.CreateJobRequest): 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_job(request) @@ -3590,6 +3591,7 @@ def test_create_job_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_job(**mock_args) @@ -3720,6 +3722,7 @@ def test_get_job_rest_required_fields(request_type=batch.GetJobRequest): 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_job(request) @@ -3765,6 +3768,7 @@ def test_get_job_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_job(**mock_args) @@ -3859,6 +3863,7 @@ def test_delete_job_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.delete_job(**mock_args) @@ -3951,6 +3956,7 @@ def test_list_jobs_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_jobs(**mock_args) @@ -4140,6 +4146,7 @@ def test_get_task_rest_required_fields(request_type=batch.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) @@ -4187,6 +4194,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) @@ -4324,6 +4332,7 @@ def test_list_tasks_rest_required_fields(request_type=batch.ListTasksRequest): 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) @@ -4380,6 +4389,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) @@ -4910,6 +4920,7 @@ def test_create_job_rest_bad_request(request_type=batch.CreateJobRequest): 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_job(request) @@ -5180,6 +5191,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_job(request) # Establish that the response is the type that we expect. @@ -5220,6 +5232,7 @@ def test_create_job_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 = gcb_job.Job.to_json(gcb_job.Job()) req.return_value.content = return_value @@ -5262,6 +5275,7 @@ def test_get_job_rest_bad_request(request_type=batch.GetJobRequest): 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_job(request) @@ -5299,6 +5313,7 @@ def test_get_job_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_job(request) # Establish that the response is the type that we expect. @@ -5339,6 +5354,7 @@ def test_get_job_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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -5381,6 +5397,7 @@ def test_delete_job_rest_bad_request(request_type=batch.DeleteJobRequest): 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_job(request) @@ -5411,6 +5428,7 @@ def test_delete_job_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.delete_job(request) # Establish that the response is the type that we expect. @@ -5450,6 +5468,7 @@ def test_delete_job_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5492,6 +5511,7 @@ def test_list_jobs_rest_bad_request(request_type=batch.ListJobsRequest): 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_jobs(request) @@ -5528,6 +5548,7 @@ def test_list_jobs_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_jobs(request) # Establish that the response is the type that we expect. @@ -5567,6 +5588,7 @@ def test_list_jobs_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 = batch.ListJobsResponse.to_json(batch.ListJobsResponse()) req.return_value.content = return_value @@ -5611,6 +5633,7 @@ def test_get_task_rest_bad_request(request_type=batch.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) @@ -5648,6 +5671,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. @@ -5686,6 +5710,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 @@ -5730,6 +5755,7 @@ def test_list_tasks_rest_bad_request(request_type=batch.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) @@ -5768,6 +5794,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. @@ -5807,6 +5834,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 = batch.ListTasksResponse.to_json(batch.ListTasksResponse()) req.return_value.content = return_value @@ -5851,6 +5879,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) @@ -5881,6 +5910,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) @@ -5909,6 +5939,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) @@ -5939,6 +5970,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) @@ -5969,6 +6001,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5999,6 +6032,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6029,6 +6063,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6059,6 +6094,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6089,6 +6125,7 @@ def test_get_operation_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.get_operation(request) @@ -6119,6 +6156,7 @@ def test_get_operation_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_operation(request) @@ -6149,6 +6187,7 @@ def test_list_operations_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_operations(request) @@ -6179,6 +6218,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-batch/tests/unit/gapic/batch_v1alpha/test_batch_service.py b/packages/google-cloud-batch/tests/unit/gapic/batch_v1alpha/test_batch_service.py index d978de4f7fba..204a7506d590 100644 --- a/packages/google-cloud-batch/tests/unit/gapic/batch_v1alpha/test_batch_service.py +++ b/packages/google-cloud-batch/tests/unit/gapic/batch_v1alpha/test_batch_service.py @@ -6255,6 +6255,7 @@ def test_create_job_rest_required_fields(request_type=batch.CreateJobRequest): 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_job(request) @@ -6315,6 +6316,7 @@ def test_create_job_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_job(**mock_args) @@ -6445,6 +6447,7 @@ def test_get_job_rest_required_fields(request_type=batch.GetJobRequest): 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_job(request) @@ -6490,6 +6493,7 @@ def test_get_job_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_job(**mock_args) @@ -6584,6 +6588,7 @@ def test_delete_job_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.delete_job(**mock_args) @@ -6714,6 +6719,7 @@ def test_cancel_job_rest_required_fields(request_type=batch.CancelJobRequest): 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_job(request) @@ -6757,6 +6763,7 @@ def test_cancel_job_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_job(**mock_args) @@ -6889,6 +6896,7 @@ def test_update_job_rest_required_fields(request_type=batch.UpdateJobRequest): 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_job(request) @@ -6950,6 +6958,7 @@ def test_update_job_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_job(**mock_args) @@ -7044,6 +7053,7 @@ def test_list_jobs_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_jobs(**mock_args) @@ -7233,6 +7243,7 @@ def test_get_task_rest_required_fields(request_type=batch.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) @@ -7280,6 +7291,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) @@ -7418,6 +7430,7 @@ def test_list_tasks_rest_required_fields(request_type=batch.ListTasksRequest): 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) @@ -7475,6 +7488,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) @@ -7682,6 +7696,7 @@ def test_create_resource_allowance_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.create_resource_allowance(request) @@ -7748,6 +7763,7 @@ def test_create_resource_allowance_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_resource_allowance(**mock_args) @@ -7892,6 +7908,7 @@ def test_get_resource_allowance_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_resource_allowance(request) @@ -7939,6 +7956,7 @@ def test_get_resource_allowance_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_resource_allowance(**mock_args) @@ -8083,6 +8101,7 @@ def test_delete_resource_allowance_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.delete_resource_allowance(request) @@ -8136,6 +8155,7 @@ def test_delete_resource_allowance_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.delete_resource_allowance(**mock_args) @@ -8279,6 +8299,7 @@ def test_list_resource_allowances_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.list_resource_allowances(request) @@ -8332,6 +8353,7 @@ def test_list_resource_allowances_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_resource_allowances(**mock_args) @@ -8534,6 +8556,7 @@ def test_update_resource_allowance_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.update_resource_allowance(request) @@ -8603,6 +8626,7 @@ def test_update_resource_allowance_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_resource_allowance(**mock_args) @@ -9438,6 +9462,7 @@ def test_create_job_rest_bad_request(request_type=batch.CreateJobRequest): 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_job(request) @@ -9741,6 +9766,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_job(request) # Establish that the response is the type that we expect. @@ -9784,6 +9810,7 @@ def test_create_job_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 = gcb_job.Job.to_json(gcb_job.Job()) req.return_value.content = return_value @@ -9826,6 +9853,7 @@ def test_get_job_rest_bad_request(request_type=batch.GetJobRequest): 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_job(request) @@ -9864,6 +9892,7 @@ def test_get_job_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_job(request) # Establish that the response is the type that we expect. @@ -9905,6 +9934,7 @@ def test_get_job_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 = job.Job.to_json(job.Job()) req.return_value.content = return_value @@ -9947,6 +9977,7 @@ def test_delete_job_rest_bad_request(request_type=batch.DeleteJobRequest): 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_job(request) @@ -9977,6 +10008,7 @@ def test_delete_job_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.delete_job(request) # Establish that the response is the type that we expect. @@ -10016,6 +10048,7 @@ def test_delete_job_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10058,6 +10091,7 @@ def test_cancel_job_rest_bad_request(request_type=batch.CancelJobRequest): 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_job(request) @@ -10088,6 +10122,7 @@ def test_cancel_job_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_job(request) # Establish that the response is the type that we expect. @@ -10127,6 +10162,7 @@ def test_cancel_job_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10169,6 +10205,7 @@ def test_update_job_rest_bad_request(request_type=batch.UpdateJobRequest): 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_job(request) @@ -10472,6 +10509,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_job(request) # Establish that the response is the type that we expect. @@ -10515,6 +10553,7 @@ def test_update_job_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 = gcb_job.Job.to_json(gcb_job.Job()) req.return_value.content = return_value @@ -10557,6 +10596,7 @@ def test_list_jobs_rest_bad_request(request_type=batch.ListJobsRequest): 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_jobs(request) @@ -10593,6 +10633,7 @@ def test_list_jobs_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_jobs(request) # Establish that the response is the type that we expect. @@ -10632,6 +10673,7 @@ def test_list_jobs_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 = batch.ListJobsResponse.to_json(batch.ListJobsResponse()) req.return_value.content = return_value @@ -10676,6 +10718,7 @@ def test_get_task_rest_bad_request(request_type=batch.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) @@ -10713,6 +10756,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. @@ -10751,6 +10795,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 @@ -10795,6 +10840,7 @@ def test_list_tasks_rest_bad_request(request_type=batch.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) @@ -10833,6 +10879,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. @@ -10872,6 +10919,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 = batch.ListTasksResponse.to_json(batch.ListTasksResponse()) req.return_value.content = return_value @@ -10916,6 +10964,7 @@ def test_create_resource_allowance_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.create_resource_allowance(request) @@ -11044,6 +11093,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_resource_allowance(request) # Establish that the response is the type that we expect. @@ -11085,6 +11135,7 @@ def test_create_resource_allowance_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 = gcb_resource_allowance.ResourceAllowance.to_json( gcb_resource_allowance.ResourceAllowance() ) @@ -11133,6 +11184,7 @@ def test_get_resource_allowance_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_resource_allowance(request) @@ -11171,6 +11223,7 @@ def test_get_resource_allowance_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_resource_allowance(request) # Establish that the response is the type that we expect. @@ -11212,6 +11265,7 @@ def test_get_resource_allowance_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 = resource_allowance.ResourceAllowance.to_json( resource_allowance.ResourceAllowance() ) @@ -11260,6 +11314,7 @@ def test_delete_resource_allowance_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.delete_resource_allowance(request) @@ -11292,6 +11347,7 @@ def test_delete_resource_allowance_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.delete_resource_allowance(request) # Establish that the response is the type that we expect. @@ -11333,6 +11389,7 @@ def test_delete_resource_allowance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -11377,6 +11434,7 @@ def test_list_resource_allowances_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.list_resource_allowances(request) @@ -11413,6 +11471,7 @@ def test_list_resource_allowances_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_resource_allowances(request) # Establish that the response is the type that we expect. @@ -11454,6 +11513,7 @@ def test_list_resource_allowances_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 = batch.ListResourceAllowancesResponse.to_json( batch.ListResourceAllowancesResponse() ) @@ -11504,6 +11564,7 @@ def test_update_resource_allowance_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.update_resource_allowance(request) @@ -11636,6 +11697,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_resource_allowance(request) # Establish that the response is the type that we expect. @@ -11677,6 +11739,7 @@ def test_update_resource_allowance_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 = gcb_resource_allowance.ResourceAllowance.to_json( gcb_resource_allowance.ResourceAllowance() ) @@ -11723,6 +11786,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) @@ -11753,6 +11817,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) @@ -11781,6 +11846,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) @@ -11811,6 +11877,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) @@ -11841,6 +11908,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -11871,6 +11939,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -11901,6 +11970,7 @@ def test_delete_operation_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.delete_operation(request) @@ -11931,6 +12001,7 @@ def test_delete_operation_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.delete_operation(request) @@ -11961,6 +12032,7 @@ def test_get_operation_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.get_operation(request) @@ -11991,6 +12063,7 @@ def test_get_operation_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_operation(request) @@ -12021,6 +12094,7 @@ def test_list_operations_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_operations(request) @@ -12051,6 +12125,7 @@ def test_list_operations_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_operations(request) From e188f1ab6108b67d7a8bb538cb6601d7fa8944cf 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 17:47:20 +0500 Subject: [PATCH 02/16] feat: [google-cloud-network-connectivity] Add support for opt-in debug logging (#13323) 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 feat: add Network Connectivity Center APIs for PSC connection propagation through NCC feat: add Network Connectivity Center APIs for star topology feat: add Network Connectivity Center APIs for producer VPC spokes feat: add Network Connectivity Center APIs for dynamic route exchange feat: add Network Connectivity Center APIs for include export filters feat: add Network Connectivity Center APIs for include import ranges on hybrid spokes docs: update comment for `ListRoutes` method in service `HubService` to clarify that it lists routes in a route table docs: update comment for `ListRouteTables` method in service `HubService` to clarify that it lists route tables in a hub docs: update comment for field `location` in message `.google.cloud.networkconnectivity.v1.Route` to clarify that it's the origin location 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmstY29ubmVjdGl2aXR5Ly5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= BEGIN_NESTED_COMMIT feat: [google-cloud-network-connectivity] add Network Connectivity Center APIs for PSC connection propagation through NCC feat: add Network Connectivity Center APIs for star topology feat: add Network Connectivity Center APIs for producer VPC spokes feat: add Network Connectivity Center APIs for dynamic route exchange feat: add Network Connectivity Center APIs for include export filters feat: add Network Connectivity Center APIs for include import ranges on hybrid spokes docs: update comment for `ListRoutes` method in service `HubService` to clarify that it lists routes in a route table docs: update comment for `ListRouteTables` method in service `HubService` to clarify that it lists route tables in a hub docs: update comment for field `location` in message `.google.cloud.networkconnectivity.v1.Route` to clarify that it's the origin location PiperOrigin-RevId: 702422268 Source-Link: https://github.com/googleapis/googleapis/commit/59254b411ac63bbb9bcd4a54cec10540ceaa5154 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f199480d334002ada53c387fdb1175de3c550f7b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmstY29ubmVjdGl2aXR5Ly5Pd2xCb3QueWFtbCIsImgiOiJmMTk5NDgwZDMzNDAwMmFkYTUzYzM4N2ZkYjExNzVkZTNjNTUwZjdiIn0= END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../cloud/networkconnectivity/__init__.py | 24 + .../networkconnectivity/gapic_version.py | 2 +- .../cloud/networkconnectivity_v1/__init__.py | 24 + .../gapic_metadata.json | 20 + .../networkconnectivity_v1/gapic_version.py | 2 +- .../services/hub_service/async_client.py | 522 +- .../services/hub_service/client.py | 521 +- .../services/hub_service/pagers.py | 252 +- .../services/hub_service/transports/base.py | 28 + .../services/hub_service/transports/grpc.py | 208 +- .../hub_service/transports/grpc_asyncio.py | 215 +- .../async_client.py | 136 +- .../policy_based_routing_service/client.py | 141 +- .../policy_based_routing_service/pagers.py | 16 +- .../transports/grpc.py | 120 +- .../transports/grpc_asyncio.py | 117 +- .../networkconnectivity_v1/types/__init__.py | 24 + .../cloud/networkconnectivity_v1/types/hub.py | 655 ++- .../gapic_version.py | 2 +- .../services/hub_service/async_client.py | 112 +- .../services/hub_service/client.py | 117 +- .../services/hub_service/pagers.py | 32 +- .../services/hub_service/transports/grpc.py | 114 +- .../hub_service/transports/grpc_asyncio.py | 111 +- ...ated_hub_service_query_hub_status_async.py | 53 + ...rated_hub_service_query_hub_status_sync.py | 53 + ...enerated_hub_service_update_group_async.py | 55 + ...generated_hub_service_update_group_sync.py | 55 + ...a_google.cloud.networkconnectivity.v1.json | 424 +- ...le.cloud.networkconnectivity.v1alpha1.json | 42 +- .../fixup_networkconnectivity_v1_keywords.py | 2 + .../test_hub_service.py | 4361 ++++++++++------- 32 files changed, 6311 insertions(+), 2249 deletions(-) create mode 100644 packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_async.py create mode 100644 packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py create mode 100644 packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_async.py create mode 100644 packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_sync.py diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/__init__.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/__init__.py index 061fbf571873..752d8ed4d28f 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/__init__.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/__init__.py @@ -34,6 +34,7 @@ from google.cloud.networkconnectivity_v1.types.hub import ( AcceptHubSpokeRequest, AcceptHubSpokeResponse, + AutoAccept, CreateHubRequest, CreateSpokeRequest, DeleteHubRequest, @@ -45,7 +46,9 @@ GetSpokeRequest, Group, Hub, + HubStatusEntry, LinkedInterconnectAttachments, + LinkedProducerVpcNetwork, LinkedRouterApplianceInstances, LinkedVpcNetwork, LinkedVpnTunnels, @@ -63,7 +66,15 @@ ListSpokesResponse, LocationFeature, LocationMetadata, + NextHopInterconnectAttachment, + NextHopRouterApplianceInstance, NextHopVpcNetwork, + NextHopVPNTunnel, + PolicyMode, + PresetTopology, + PscPropagationStatus, + QueryHubStatusRequest, + QueryHubStatusResponse, RejectHubSpokeRequest, RejectHubSpokeResponse, Route, @@ -75,6 +86,7 @@ SpokeSummary, SpokeType, State, + UpdateGroupRequest, UpdateHubRequest, UpdateSpokeRequest, ) @@ -95,6 +107,7 @@ "OperationMetadata", "AcceptHubSpokeRequest", "AcceptHubSpokeResponse", + "AutoAccept", "CreateHubRequest", "CreateSpokeRequest", "DeleteHubRequest", @@ -106,7 +119,9 @@ "GetSpokeRequest", "Group", "Hub", + "HubStatusEntry", "LinkedInterconnectAttachments", + "LinkedProducerVpcNetwork", "LinkedRouterApplianceInstances", "LinkedVpcNetwork", "LinkedVpnTunnels", @@ -123,7 +138,13 @@ "ListSpokesRequest", "ListSpokesResponse", "LocationMetadata", + "NextHopInterconnectAttachment", + "NextHopRouterApplianceInstance", "NextHopVpcNetwork", + "NextHopVPNTunnel", + "PscPropagationStatus", + "QueryHubStatusRequest", + "QueryHubStatusResponse", "RejectHubSpokeRequest", "RejectHubSpokeResponse", "Route", @@ -132,9 +153,12 @@ "RoutingVPC", "Spoke", "SpokeSummary", + "UpdateGroupRequest", "UpdateHubRequest", "UpdateSpokeRequest", "LocationFeature", + "PolicyMode", + "PresetTopology", "RouteType", "SpokeType", "State", diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/gapic_version.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/gapic_version.py index 4ed306c1cb52..558c8aab67c5 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/gapic_version.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/__init__.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/__init__.py index fb6ea24a5748..b06dd8a15c8d 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/__init__.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/__init__.py @@ -27,6 +27,7 @@ from .types.hub import ( AcceptHubSpokeRequest, AcceptHubSpokeResponse, + AutoAccept, CreateHubRequest, CreateSpokeRequest, DeleteHubRequest, @@ -38,7 +39,9 @@ GetSpokeRequest, Group, Hub, + HubStatusEntry, LinkedInterconnectAttachments, + LinkedProducerVpcNetwork, LinkedRouterApplianceInstances, LinkedVpcNetwork, LinkedVpnTunnels, @@ -56,7 +59,15 @@ ListSpokesResponse, LocationFeature, LocationMetadata, + NextHopInterconnectAttachment, + NextHopRouterApplianceInstance, NextHopVpcNetwork, + NextHopVPNTunnel, + PolicyMode, + PresetTopology, + PscPropagationStatus, + QueryHubStatusRequest, + QueryHubStatusResponse, RejectHubSpokeRequest, RejectHubSpokeResponse, Route, @@ -68,6 +79,7 @@ SpokeSummary, SpokeType, State, + UpdateGroupRequest, UpdateHubRequest, UpdateSpokeRequest, ) @@ -85,6 +97,7 @@ "PolicyBasedRoutingServiceAsyncClient", "AcceptHubSpokeRequest", "AcceptHubSpokeResponse", + "AutoAccept", "CreateHubRequest", "CreatePolicyBasedRouteRequest", "CreateSpokeRequest", @@ -100,7 +113,9 @@ "Group", "Hub", "HubServiceClient", + "HubStatusEntry", "LinkedInterconnectAttachments", + "LinkedProducerVpcNetwork", "LinkedRouterApplianceInstances", "LinkedVpcNetwork", "LinkedVpnTunnels", @@ -120,10 +135,18 @@ "ListSpokesResponse", "LocationFeature", "LocationMetadata", + "NextHopInterconnectAttachment", + "NextHopRouterApplianceInstance", + "NextHopVPNTunnel", "NextHopVpcNetwork", "OperationMetadata", "PolicyBasedRoute", "PolicyBasedRoutingServiceClient", + "PolicyMode", + "PresetTopology", + "PscPropagationStatus", + "QueryHubStatusRequest", + "QueryHubStatusResponse", "RejectHubSpokeRequest", "RejectHubSpokeResponse", "Route", @@ -135,6 +158,7 @@ "SpokeSummary", "SpokeType", "State", + "UpdateGroupRequest", "UpdateHubRequest", "UpdateSpokeRequest", ) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_metadata.json b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_metadata.json index 913e687b84bb..c8e2a896e08a 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_metadata.json +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_metadata.json @@ -90,11 +90,21 @@ "list_spokes" ] }, + "QueryHubStatus": { + "methods": [ + "query_hub_status" + ] + }, "RejectHubSpoke": { "methods": [ "reject_hub_spoke" ] }, + "UpdateGroup": { + "methods": [ + "update_group" + ] + }, "UpdateHub": { "methods": [ "update_hub" @@ -190,11 +200,21 @@ "list_spokes" ] }, + "QueryHubStatus": { + "methods": [ + "query_hub_status" + ] + }, "RejectHubSpoke": { "methods": [ "reject_hub_spoke" ] }, + "UpdateGroup": { + "methods": [ + "update_group" + ] + }, "UpdateHub": { "methods": [ "update_hub" diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_version.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_version.py index 4ed306c1cb52..558c8aab67c5 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_version.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py index 8ecd4850da3a..f9997f1929da 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/async_client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/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, HubServiceTransport from .transports.grpc_asyncio import HubServiceGrpcAsyncIOTransport +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 HubServiceAsyncClient: """Network Connectivity Center is a hub-and-spoke abstraction @@ -284,6 +294,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.networkconnectivity_v1.HubServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1.HubService", + "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.networkconnectivity.v1.HubService", + "credentialsType": None, + }, + ) + async def list_hubs( self, request: Optional[Union[hub.ListHubsRequest, dict]] = None, @@ -291,7 +323,7 @@ async def list_hubs( 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.ListHubsAsyncPager: r"""Lists the Network Connectivity Center hubs associated with a given project. @@ -336,8 +368,10 @@ async def sample_list_hubs(): 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.networkconnectivity_v1.services.hub_service.pagers.ListHubsAsyncPager: @@ -413,7 +447,7 @@ async def get_hub( 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]]] = (), ) -> hub.Hub: r"""Gets details about a Network Connectivity Center hub. @@ -458,8 +492,10 @@ async def sample_get_hub(): 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.networkconnectivity_v1.types.Hub: @@ -530,7 +566,7 @@ async def create_hub( hub_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Network Connectivity Center hub in the specified project. @@ -593,8 +629,10 @@ async def sample_create_hub(): 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.api_core.operation_async.AsyncOperation: @@ -676,7 +714,7 @@ async def update_hub( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the description and/or labels of a Network Connectivity Center hub. @@ -736,8 +774,10 @@ async def sample_update_hub(): 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.api_core.operation_async.AsyncOperation: @@ -816,7 +856,7 @@ async def delete_hub( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Network Connectivity Center hub. @@ -864,8 +904,10 @@ async def sample_delete_hub(): 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.api_core.operation_async.AsyncOperation: @@ -944,7 +986,7 @@ async def list_hub_spokes( 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]]] = (), ) -> pagers.ListHubSpokesAsyncPager: r"""Lists the Network Connectivity Center spokes associated with a specified hub and location. The list @@ -990,8 +1032,10 @@ async def sample_list_hub_spokes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListHubSpokesAsyncPager: @@ -1059,6 +1103,128 @@ async def sample_list_hub_spokes(): # Done; return the response. return response + async def query_hub_status( + self, + request: Optional[Union[hub.QueryHubStatusRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.QueryHubStatusAsyncPager: + r"""Query the Private Service Connect propagation status + of a Network Connectivity Center hub. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import networkconnectivity_v1 + + async def sample_query_hub_status(): + # Create a client + client = networkconnectivity_v1.HubServiceAsyncClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.QueryHubStatusRequest( + name="name_value", + ) + + # Make the request + page_result = client.query_hub_status(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest, dict]]): + The request object. The request for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + name (:class:`str`): + Required. The name of the hub. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.networkconnectivity_v1.services.hub_service.pagers.QueryHubStatusAsyncPager: + The response for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, hub.QueryHubStatusRequest): + request = hub.QueryHubStatusRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.query_hub_status + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.QueryHubStatusAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def list_spokes( self, request: Optional[Union[hub.ListSpokesRequest, dict]] = None, @@ -1066,7 +1232,7 @@ async def list_spokes( 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.ListSpokesAsyncPager: r"""Lists the Network Connectivity Center spokes in a specified project and location. @@ -1110,8 +1276,10 @@ async def sample_list_spokes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListSpokesAsyncPager: @@ -1186,7 +1354,7 @@ async def get_spoke( 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]]] = (), ) -> hub.Spoke: r"""Gets details about a Network Connectivity Center spoke. @@ -1231,8 +1399,10 @@ async def sample_get_spoke(): 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.networkconnectivity_v1.types.Spoke: @@ -1304,7 +1474,7 @@ async def create_spoke( spoke_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Network Connectivity Center spoke. @@ -1365,8 +1535,10 @@ async def sample_create_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1451,7 +1623,7 @@ async def update_spoke( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a Network Connectivity Center spoke. @@ -1511,8 +1683,10 @@ async def sample_update_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1597,7 +1771,7 @@ async def reject_hub_spoke( spoke_uri: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Rejects a Network Connectivity Center spoke from being attached to a hub. If the spoke was previously in the ``ACTIVE`` state, @@ -1656,8 +1830,10 @@ async def sample_reject_hub_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1731,7 +1907,7 @@ async def accept_hub_spoke( spoke_uri: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Accepts a proposal to attach a Network Connectivity Center spoke to a hub. @@ -1788,8 +1964,10 @@ async def sample_accept_hub_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1862,7 +2040,7 @@ async def delete_spoke( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Network Connectivity Center spoke. @@ -1910,8 +2088,10 @@ async def sample_delete_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1990,7 +2170,7 @@ async def get_route_table( 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]]] = (), ) -> hub.RouteTable: r"""Gets details about a Network Connectivity Center route table. @@ -2035,8 +2215,10 @@ async def sample_get_route_table(): 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.networkconnectivity_v1.types.RouteTable: @@ -2095,7 +2277,7 @@ async def get_route( 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]]] = (), ) -> hub.Route: r"""Gets details about the specified route. @@ -2139,8 +2321,10 @@ async def sample_get_route(): 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.networkconnectivity_v1.types.Route: @@ -2203,9 +2387,9 @@ async def list_routes( 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.ListRoutesAsyncPager: - r"""Lists routes in a given project. + r"""Lists routes in a given route table. .. code-block:: python @@ -2247,8 +2431,10 @@ async def sample_list_routes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListRoutesAsyncPager: @@ -2324,9 +2510,9 @@ async def list_route_tables( 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.ListRouteTablesAsyncPager: - r"""Lists route tables in a given project. + r"""Lists route tables in a given hub. .. code-block:: python @@ -2368,8 +2554,10 @@ async def sample_list_route_tables(): 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.networkconnectivity_v1.services.hub_service.pagers.ListRouteTablesAsyncPager: @@ -2445,7 +2633,7 @@ async def get_group( 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]]] = (), ) -> hub.Group: r"""Gets details about a Network Connectivity Center group. @@ -2490,8 +2678,10 @@ async def sample_get_group(): 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.networkconnectivity_v1.types.Group: @@ -2552,7 +2742,7 @@ async def list_groups( 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.ListGroupsAsyncPager: r"""Lists groups in a given hub. @@ -2596,8 +2786,10 @@ async def sample_list_groups(): 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.networkconnectivity_v1.services.hub_service.pagers.ListGroupsAsyncPager: @@ -2666,13 +2858,153 @@ async def sample_list_groups(): # Done; return the response. return response + async def update_group( + self, + request: Optional[Union[hub.UpdateGroupRequest, dict]] = None, + *, + group: Optional[hub.Group] = None, + 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the parameters of a Network Connectivity + Center group. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import networkconnectivity_v1 + + async def sample_update_group(): + # Create a client + client = networkconnectivity_v1.HubServiceAsyncClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.UpdateGroupRequest( + ) + + # Make the request + operation = client.update_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.networkconnectivity_v1.types.UpdateGroupRequest, dict]]): + The request object. Request for + [HubService.UpdateGroup][google.cloud.networkconnectivity.v1.HubService.UpdateGroup] + method. + group (:class:`google.cloud.networkconnectivity_v1.types.Group`): + Required. The state that the group + should be in after the update. + + This corresponds to the ``group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. In the case of an update to an existing group, + field mask is used to specify the fields to be + overwritten. The fields specified in the update_mask are + relative to the resource, not the full request. A field + is overwritten if it is in the mask. If the user does + not provide a mask, then all fields are overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.networkconnectivity_v1.types.Group` + A group represents a subset of spokes attached to a hub. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([group, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, hub.UpdateGroupRequest): + request = hub.UpdateGroupRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if group is not None: + request.group = group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_group + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("group.name", request.group.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + hub.Group, + metadata_type=common.OperationMetadata, + ) + + # Done; return the response. + return response + async def list_operations( self, request: Optional[operations_pb2.ListOperationsRequest] = 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2683,8 +3015,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2725,7 +3059,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2736,8 +3070,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2778,7 +3114,7 @@ async def delete_operation( *, 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 long-running operation. @@ -2794,8 +3130,10 @@ async def delete_operation( 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: None """ @@ -2832,7 +3170,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2847,8 +3185,10 @@ async def cancel_operation( 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: None """ @@ -2885,7 +3225,7 @@ async def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -2898,8 +3238,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3004,7 +3346,7 @@ async def get_iam_policy( *, 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 IAM access control policy for a function. @@ -3018,8 +3360,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3124,7 +3468,7 @@ async def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3139,8 +3483,10 @@ async def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3184,7 +3530,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. @@ -3195,8 +3541,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. @@ -3237,7 +3585,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. @@ -3248,8 +3596,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-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/client.py index 9f479e833101..b2011b6f4c1f 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -762,6 +772,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( @@ -824,6 +838,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.networkconnectivity_v1.HubServiceClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1.HubService", + "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.networkconnectivity.v1.HubService", + "credentialsType": None, + }, + ) + def list_hubs( self, request: Optional[Union[hub.ListHubsRequest, dict]] = None, @@ -831,7 +868,7 @@ def list_hubs( 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.ListHubsPager: r"""Lists the Network Connectivity Center hubs associated with a given project. @@ -876,8 +913,10 @@ def sample_list_hubs(): 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.networkconnectivity_v1.services.hub_service.pagers.ListHubsPager: @@ -950,7 +989,7 @@ def get_hub( 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]]] = (), ) -> hub.Hub: r"""Gets details about a Network Connectivity Center hub. @@ -995,8 +1034,10 @@ def sample_get_hub(): 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.networkconnectivity_v1.types.Hub: @@ -1066,7 +1107,7 @@ def create_hub( hub_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new Network Connectivity Center hub in the specified project. @@ -1129,8 +1170,10 @@ def sample_create_hub(): 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.api_core.operation.Operation: @@ -1209,7 +1252,7 @@ def update_hub( 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]]] = (), ) -> operation.Operation: r"""Updates the description and/or labels of a Network Connectivity Center hub. @@ -1269,8 +1312,10 @@ def sample_update_hub(): 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.api_core.operation.Operation: @@ -1346,7 +1391,7 @@ def delete_hub( 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]]] = (), ) -> operation.Operation: r"""Deletes a Network Connectivity Center hub. @@ -1394,8 +1439,10 @@ def sample_delete_hub(): 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.api_core.operation.Operation: @@ -1471,7 +1518,7 @@ def list_hub_spokes( 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]]] = (), ) -> pagers.ListHubSpokesPager: r"""Lists the Network Connectivity Center spokes associated with a specified hub and location. The list @@ -1517,8 +1564,10 @@ def sample_list_hub_spokes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListHubSpokesPager: @@ -1583,6 +1632,125 @@ def sample_list_hub_spokes(): # Done; return the response. return response + def query_hub_status( + self, + request: Optional[Union[hub.QueryHubStatusRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.QueryHubStatusPager: + r"""Query the Private Service Connect propagation status + of a Network Connectivity Center hub. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import networkconnectivity_v1 + + def sample_query_hub_status(): + # Create a client + client = networkconnectivity_v1.HubServiceClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.QueryHubStatusRequest( + name="name_value", + ) + + # Make the request + page_result = client.query_hub_status(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest, dict]): + The request object. The request for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + name (str): + Required. The name of the hub. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.networkconnectivity_v1.services.hub_service.pagers.QueryHubStatusPager: + The response for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, hub.QueryHubStatusRequest): + request = hub.QueryHubStatusRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.query_hub_status] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.QueryHubStatusPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def list_spokes( self, request: Optional[Union[hub.ListSpokesRequest, dict]] = None, @@ -1590,7 +1758,7 @@ def list_spokes( 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.ListSpokesPager: r"""Lists the Network Connectivity Center spokes in a specified project and location. @@ -1634,8 +1802,10 @@ def sample_list_spokes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListSpokesPager: @@ -1707,7 +1877,7 @@ def get_spoke( 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]]] = (), ) -> hub.Spoke: r"""Gets details about a Network Connectivity Center spoke. @@ -1752,8 +1922,10 @@ def sample_get_spoke(): 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.networkconnectivity_v1.types.Spoke: @@ -1822,7 +1994,7 @@ def create_spoke( spoke_id: 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]]] = (), ) -> operation.Operation: r"""Creates a Network Connectivity Center spoke. @@ -1883,8 +2055,10 @@ def sample_create_spoke(): 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.api_core.operation.Operation: @@ -1966,7 +2140,7 @@ def update_spoke( 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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a Network Connectivity Center spoke. @@ -2026,8 +2200,10 @@ def sample_update_spoke(): 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.api_core.operation.Operation: @@ -2109,7 +2285,7 @@ def reject_hub_spoke( spoke_uri: 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]]] = (), ) -> operation.Operation: r"""Rejects a Network Connectivity Center spoke from being attached to a hub. If the spoke was previously in the ``ACTIVE`` state, @@ -2168,8 +2344,10 @@ def sample_reject_hub_spoke(): 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.api_core.operation.Operation: @@ -2240,7 +2418,7 @@ def accept_hub_spoke( spoke_uri: 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]]] = (), ) -> operation.Operation: r"""Accepts a proposal to attach a Network Connectivity Center spoke to a hub. @@ -2297,8 +2475,10 @@ def sample_accept_hub_spoke(): 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.api_core.operation.Operation: @@ -2368,7 +2548,7 @@ def delete_spoke( 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]]] = (), ) -> operation.Operation: r"""Deletes a Network Connectivity Center spoke. @@ -2416,8 +2596,10 @@ def sample_delete_spoke(): 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.api_core.operation.Operation: @@ -2493,7 +2675,7 @@ def get_route_table( 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]]] = (), ) -> hub.RouteTable: r"""Gets details about a Network Connectivity Center route table. @@ -2538,8 +2720,10 @@ def sample_get_route_table(): 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.networkconnectivity_v1.types.RouteTable: @@ -2595,7 +2779,7 @@ def get_route( 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]]] = (), ) -> hub.Route: r"""Gets details about the specified route. @@ -2639,8 +2823,10 @@ def sample_get_route(): 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.networkconnectivity_v1.types.Route: @@ -2700,9 +2886,9 @@ def list_routes( 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.ListRoutesPager: - r"""Lists routes in a given project. + r"""Lists routes in a given route table. .. code-block:: python @@ -2744,8 +2930,10 @@ def sample_list_routes(): 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.networkconnectivity_v1.services.hub_service.pagers.ListRoutesPager: @@ -2818,9 +3006,9 @@ def list_route_tables( 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.ListRouteTablesPager: - r"""Lists route tables in a given project. + r"""Lists route tables in a given hub. .. code-block:: python @@ -2862,8 +3050,10 @@ def sample_list_route_tables(): 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.networkconnectivity_v1.services.hub_service.pagers.ListRouteTablesPager: @@ -2936,7 +3126,7 @@ def get_group( 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]]] = (), ) -> hub.Group: r"""Gets details about a Network Connectivity Center group. @@ -2981,8 +3171,10 @@ def sample_get_group(): 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.networkconnectivity_v1.types.Group: @@ -3040,7 +3232,7 @@ def list_groups( 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.ListGroupsPager: r"""Lists groups in a given hub. @@ -3084,8 +3276,10 @@ def sample_list_groups(): 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.networkconnectivity_v1.services.hub_service.pagers.ListGroupsPager: @@ -3151,6 +3345,143 @@ def sample_list_groups(): # Done; return the response. return response + def update_group( + self, + request: Optional[Union[hub.UpdateGroupRequest, dict]] = None, + *, + group: Optional[hub.Group] = None, + 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the parameters of a Network Connectivity + Center group. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import networkconnectivity_v1 + + def sample_update_group(): + # Create a client + client = networkconnectivity_v1.HubServiceClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.UpdateGroupRequest( + ) + + # Make the request + operation = client.update_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.networkconnectivity_v1.types.UpdateGroupRequest, dict]): + The request object. Request for + [HubService.UpdateGroup][google.cloud.networkconnectivity.v1.HubService.UpdateGroup] + method. + group (google.cloud.networkconnectivity_v1.types.Group): + Required. The state that the group + should be in after the update. + + This corresponds to the ``group`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. In the case of an update to an existing group, + field mask is used to specify the fields to be + overwritten. The fields specified in the update_mask are + relative to the resource, not the full request. A field + is overwritten if it is in the mask. If the user does + not provide a mask, then all fields are overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.networkconnectivity_v1.types.Group` + A group represents a subset of spokes attached to a hub. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([group, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, hub.UpdateGroupRequest): + request = hub.UpdateGroupRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if group is not None: + request.group = group + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_group] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("group.name", request.group.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + hub.Group, + metadata_type=common.OperationMetadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "HubServiceClient": return self @@ -3170,7 +3501,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3181,8 +3512,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3223,7 +3556,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3234,8 +3567,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3276,7 +3611,7 @@ def delete_operation( *, 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 long-running operation. @@ -3292,8 +3627,10 @@ def delete_operation( 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: None """ @@ -3330,7 +3667,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -3345,8 +3682,10 @@ def cancel_operation( 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: None """ @@ -3383,7 +3722,7 @@ def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -3396,8 +3735,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3502,7 +3843,7 @@ def get_iam_policy( *, 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 IAM access control policy for a function. @@ -3516,8 +3857,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3622,7 +3965,7 @@ def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3637,8 +3980,10 @@ def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3680,7 +4025,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. @@ -3691,8 +4036,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. @@ -3733,7 +4080,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. @@ -3744,8 +4091,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-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/pagers.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/pagers.py index 116c428e2b1a..d6219312fe2a 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/pagers.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/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 = hub.ListHubsRequest(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 = hub.ListHubsRequest(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 = hub.ListHubSpokesRequest(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 = hub.ListHubSpokesRequest(request) @@ -345,6 +353,162 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class QueryHubStatusPager: + """A pager for iterating through ``query_hub_status`` requests. + + This class thinly wraps an initial + :class:`google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse` object, and + provides an ``__iter__`` method to iterate through its + ``hub_status_entries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``QueryHubStatus`` requests and continue to iterate + through the ``hub_status_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., hub.QueryHubStatusResponse], + request: hub.QueryHubStatusRequest, + response: hub.QueryHubStatusResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest): + The initial request object. + response (google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse): + The initial response object. + 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, 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 = hub.QueryHubStatusRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[hub.QueryHubStatusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[hub.HubStatusEntry]: + for page in self.pages: + yield from page.hub_status_entries + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class QueryHubStatusAsyncPager: + """A pager for iterating through ``query_hub_status`` requests. + + This class thinly wraps an initial + :class:`google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``hub_status_entries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``QueryHubStatus`` requests and continue to iterate + through the ``hub_status_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[hub.QueryHubStatusResponse]], + request: hub.QueryHubStatusRequest, + response: hub.QueryHubStatusResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest): + The initial request object. + response (google.cloud.networkconnectivity_v1.types.QueryHubStatusResponse): + The initial response object. + 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, 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 = hub.QueryHubStatusRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[hub.QueryHubStatusResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[hub.HubStatusEntry]: + async def async_generator(): + async for page in self.pages: + for response in page.hub_status_entries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListSpokesPager: """A pager for iterating through ``list_spokes`` requests. @@ -371,7 +535,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. @@ -385,8 +549,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 = hub.ListSpokesRequest(request) @@ -445,7 +611,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. @@ -459,8 +625,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 = hub.ListSpokesRequest(request) @@ -523,7 +691,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. @@ -537,8 +705,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 = hub.ListRoutesRequest(request) @@ -597,7 +767,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. @@ -611,8 +781,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 = hub.ListRoutesRequest(request) @@ -675,7 +847,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. @@ -689,8 +861,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 = hub.ListRouteTablesRequest(request) @@ -749,7 +923,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. @@ -763,8 +937,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 = hub.ListRouteTablesRequest(request) @@ -827,7 +1003,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. @@ -841,8 +1017,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 = hub.ListGroupsRequest(request) @@ -901,7 +1079,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. @@ -915,8 +1093,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 = hub.ListGroupsRequest(request) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py index d0a25a79d57e..0e341fb9dadd 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py @@ -163,6 +163,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.query_hub_status: gapic_v1.method.wrap_method( + self.query_hub_status, + default_timeout=None, + client_info=client_info, + ), self.list_spokes: gapic_v1.method.wrap_method( self.list_spokes, default_timeout=None, @@ -228,6 +233,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_group: gapic_v1.method.wrap_method( + self.update_group, + default_timeout=None, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -340,6 +350,15 @@ def list_hub_spokes( ]: raise NotImplementedError() + @property + def query_hub_status( + self, + ) -> Callable[ + [hub.QueryHubStatusRequest], + Union[hub.QueryHubStatusResponse, Awaitable[hub.QueryHubStatusResponse]], + ]: + raise NotImplementedError() + @property def list_spokes( self, @@ -447,6 +466,15 @@ def list_groups( ]: raise NotImplementedError() + @property + def update_group( + self, + ) -> Callable[ + [hub.UpdateGroupRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py index 096f0c3b2daa..c886bad6b110 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/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,13 +27,91 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.networkconnectivity_v1.types import hub from google.cloud.networkconnectivity_v1.types import hub as gcn_hub from .base import DEFAULT_CLIENT_INFO, HubServiceTransport +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.networkconnectivity.v1.HubService", + "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.networkconnectivity.v1.HubService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HubServiceGrpcTransport(HubServiceTransport): """gRPC backend transport for HubService. @@ -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 @@ -252,7 +338,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def list_hubs(self) -> Callable[[hub.ListHubsRequest], hub.ListHubsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hubs" not in self._stubs: - self._stubs["list_hubs"] = self.grpc_channel.unary_unary( + self._stubs["list_hubs"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListHubs", request_serializer=hub.ListHubsRequest.serialize, response_deserializer=hub.ListHubsResponse.deserialize, @@ -299,7 +387,7 @@ def get_hub(self) -> Callable[[hub.GetHubRequest], hub.Hub]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hub" not in self._stubs: - self._stubs["get_hub"] = self.grpc_channel.unary_unary( + self._stubs["get_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetHub", request_serializer=hub.GetHubRequest.serialize, response_deserializer=hub.Hub.deserialize, @@ -326,7 +414,7 @@ def create_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hub" not in self._stubs: - self._stubs["create_hub"] = self.grpc_channel.unary_unary( + self._stubs["create_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/CreateHub", request_serializer=gcn_hub.CreateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hub" not in self._stubs: - self._stubs["update_hub"] = self.grpc_channel.unary_unary( + self._stubs["update_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/UpdateHub", request_serializer=gcn_hub.UpdateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +465,7 @@ def delete_hub(self) -> Callable[[hub.DeleteHubRequest], operations_pb2.Operatio # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_hub" not in self._stubs: - self._stubs["delete_hub"] = self.grpc_channel.unary_unary( + self._stubs["delete_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/DeleteHub", request_serializer=hub.DeleteHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -406,13 +494,40 @@ def list_hub_spokes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hub_spokes" not in self._stubs: - self._stubs["list_hub_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_hub_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListHubSpokes", request_serializer=hub.ListHubSpokesRequest.serialize, response_deserializer=hub.ListHubSpokesResponse.deserialize, ) return self._stubs["list_hub_spokes"] + @property + def query_hub_status( + self, + ) -> Callable[[hub.QueryHubStatusRequest], hub.QueryHubStatusResponse]: + r"""Return a callable for the query hub status method over gRPC. + + Query the Private Service Connect propagation status + of a Network Connectivity Center hub. + + Returns: + Callable[[~.QueryHubStatusRequest], + ~.QueryHubStatusResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "query_hub_status" not in self._stubs: + self._stubs["query_hub_status"] = self._logged_channel.unary_unary( + "/google.cloud.networkconnectivity.v1.HubService/QueryHubStatus", + request_serializer=hub.QueryHubStatusRequest.serialize, + response_deserializer=hub.QueryHubStatusResponse.deserialize, + ) + return self._stubs["query_hub_status"] + @property def list_spokes(self) -> Callable[[hub.ListSpokesRequest], hub.ListSpokesResponse]: r"""Return a callable for the list spokes method over gRPC. @@ -431,7 +546,7 @@ def list_spokes(self) -> Callable[[hub.ListSpokesRequest], hub.ListSpokesRespons # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spokes" not in self._stubs: - self._stubs["list_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListSpokes", request_serializer=hub.ListSpokesRequest.serialize, response_deserializer=hub.ListSpokesResponse.deserialize, @@ -456,7 +571,7 @@ def get_spoke(self) -> Callable[[hub.GetSpokeRequest], hub.Spoke]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_spoke" not in self._stubs: - self._stubs["get_spoke"] = self.grpc_channel.unary_unary( + self._stubs["get_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetSpoke", request_serializer=hub.GetSpokeRequest.serialize, response_deserializer=hub.Spoke.deserialize, @@ -482,7 +597,7 @@ def create_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_spoke" not in self._stubs: - self._stubs["create_spoke"] = self.grpc_channel.unary_unary( + self._stubs["create_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/CreateSpoke", request_serializer=hub.CreateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -509,7 +624,7 @@ def update_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_spoke" not in self._stubs: - self._stubs["update_spoke"] = self.grpc_channel.unary_unary( + self._stubs["update_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/UpdateSpoke", request_serializer=hub.UpdateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -538,7 +653,7 @@ def reject_hub_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_hub_spoke" not in self._stubs: - self._stubs["reject_hub_spoke"] = self.grpc_channel.unary_unary( + self._stubs["reject_hub_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/RejectHubSpoke", request_serializer=hub.RejectHubSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -565,7 +680,7 @@ def accept_hub_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "accept_hub_spoke" not in self._stubs: - self._stubs["accept_hub_spoke"] = self.grpc_channel.unary_unary( + self._stubs["accept_hub_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/AcceptHubSpoke", request_serializer=hub.AcceptHubSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -591,7 +706,7 @@ def delete_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_spoke" not in self._stubs: - self._stubs["delete_spoke"] = self.grpc_channel.unary_unary( + self._stubs["delete_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/DeleteSpoke", request_serializer=hub.DeleteSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -616,7 +731,7 @@ def get_route_table(self) -> Callable[[hub.GetRouteTableRequest], hub.RouteTable # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_route_table" not in self._stubs: - self._stubs["get_route_table"] = self.grpc_channel.unary_unary( + self._stubs["get_route_table"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetRouteTable", request_serializer=hub.GetRouteTableRequest.serialize, response_deserializer=hub.RouteTable.deserialize, @@ -640,7 +755,7 @@ def get_route(self) -> Callable[[hub.GetRouteRequest], hub.Route]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_route" not in self._stubs: - self._stubs["get_route"] = self.grpc_channel.unary_unary( + self._stubs["get_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetRoute", request_serializer=hub.GetRouteRequest.serialize, response_deserializer=hub.Route.deserialize, @@ -651,7 +766,7 @@ def get_route(self) -> Callable[[hub.GetRouteRequest], hub.Route]: def list_routes(self) -> Callable[[hub.ListRoutesRequest], hub.ListRoutesResponse]: r"""Return a callable for the list routes method over gRPC. - Lists routes in a given project. + Lists routes in a given route table. Returns: Callable[[~.ListRoutesRequest], @@ -664,7 +779,7 @@ def list_routes(self) -> Callable[[hub.ListRoutesRequest], hub.ListRoutesRespons # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_routes" not in self._stubs: - self._stubs["list_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_routes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListRoutes", request_serializer=hub.ListRoutesRequest.serialize, response_deserializer=hub.ListRoutesResponse.deserialize, @@ -677,7 +792,7 @@ def list_route_tables( ) -> Callable[[hub.ListRouteTablesRequest], hub.ListRouteTablesResponse]: r"""Return a callable for the list route tables method over gRPC. - Lists route tables in a given project. + Lists route tables in a given hub. Returns: Callable[[~.ListRouteTablesRequest], @@ -690,7 +805,7 @@ def list_route_tables( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_route_tables" not in self._stubs: - self._stubs["list_route_tables"] = self.grpc_channel.unary_unary( + self._stubs["list_route_tables"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListRouteTables", request_serializer=hub.ListRouteTablesRequest.serialize, response_deserializer=hub.ListRouteTablesResponse.deserialize, @@ -715,7 +830,7 @@ def get_group(self) -> Callable[[hub.GetGroupRequest], hub.Group]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_group" not in self._stubs: - self._stubs["get_group"] = self.grpc_channel.unary_unary( + self._stubs["get_group"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetGroup", request_serializer=hub.GetGroupRequest.serialize, response_deserializer=hub.Group.deserialize, @@ -739,15 +854,42 @@ def list_groups(self) -> Callable[[hub.ListGroupsRequest], hub.ListGroupsRespons # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_groups" not in self._stubs: - self._stubs["list_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_groups"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListGroups", request_serializer=hub.ListGroupsRequest.serialize, response_deserializer=hub.ListGroupsResponse.deserialize, ) return self._stubs["list_groups"] + @property + def update_group( + self, + ) -> Callable[[hub.UpdateGroupRequest], operations_pb2.Operation]: + r"""Return a callable for the update group method over gRPC. + + Updates the parameters of a Network Connectivity + Center group. + + Returns: + Callable[[~.UpdateGroupRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_group" not in self._stubs: + self._stubs["update_group"] = self._logged_channel.unary_unary( + "/google.cloud.networkconnectivity.v1.HubService/UpdateGroup", + request_serializer=hub.UpdateGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_group"] + def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -759,7 +901,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -776,7 +918,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -793,7 +935,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -812,7 +954,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -831,7 +973,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, @@ -848,7 +990,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, @@ -873,7 +1015,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -899,7 +1041,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -928,7 +1070,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py index ad8c771f98c4..954ad96c2f3f 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/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.longrunning import operations_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.networkconnectivity_v1.types import hub from google.cloud.networkconnectivity_v1.types import hub as gcn_hub @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, HubServiceTransport from .grpc import HubServiceGrpcTransport +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.networkconnectivity.v1.HubService", + "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.networkconnectivity.v1.HubService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HubServiceGrpcAsyncIOTransport(HubServiceTransport): """gRPC AsyncIO backend transport for HubService. @@ -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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def list_hubs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hubs" not in self._stubs: - self._stubs["list_hubs"] = self.grpc_channel.unary_unary( + self._stubs["list_hubs"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListHubs", request_serializer=hub.ListHubsRequest.serialize, response_deserializer=hub.ListHubsResponse.deserialize, @@ -311,7 +396,7 @@ def get_hub(self) -> Callable[[hub.GetHubRequest], Awaitable[hub.Hub]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hub" not in self._stubs: - self._stubs["get_hub"] = self.grpc_channel.unary_unary( + self._stubs["get_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetHub", request_serializer=hub.GetHubRequest.serialize, response_deserializer=hub.Hub.deserialize, @@ -338,7 +423,7 @@ def create_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hub" not in self._stubs: - self._stubs["create_hub"] = self.grpc_channel.unary_unary( + self._stubs["create_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/CreateHub", request_serializer=gcn_hub.CreateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +450,7 @@ def update_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hub" not in self._stubs: - self._stubs["update_hub"] = self.grpc_channel.unary_unary( + self._stubs["update_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/UpdateHub", request_serializer=gcn_hub.UpdateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +476,7 @@ def delete_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_hub" not in self._stubs: - self._stubs["delete_hub"] = self.grpc_channel.unary_unary( + self._stubs["delete_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/DeleteHub", request_serializer=hub.DeleteHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -420,13 +505,40 @@ def list_hub_spokes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hub_spokes" not in self._stubs: - self._stubs["list_hub_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_hub_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListHubSpokes", request_serializer=hub.ListHubSpokesRequest.serialize, response_deserializer=hub.ListHubSpokesResponse.deserialize, ) return self._stubs["list_hub_spokes"] + @property + def query_hub_status( + self, + ) -> Callable[[hub.QueryHubStatusRequest], Awaitable[hub.QueryHubStatusResponse]]: + r"""Return a callable for the query hub status method over gRPC. + + Query the Private Service Connect propagation status + of a Network Connectivity Center hub. + + Returns: + Callable[[~.QueryHubStatusRequest], + Awaitable[~.QueryHubStatusResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "query_hub_status" not in self._stubs: + self._stubs["query_hub_status"] = self._logged_channel.unary_unary( + "/google.cloud.networkconnectivity.v1.HubService/QueryHubStatus", + request_serializer=hub.QueryHubStatusRequest.serialize, + response_deserializer=hub.QueryHubStatusResponse.deserialize, + ) + return self._stubs["query_hub_status"] + @property def list_spokes( self, @@ -447,7 +559,7 @@ def list_spokes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spokes" not in self._stubs: - self._stubs["list_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListSpokes", request_serializer=hub.ListSpokesRequest.serialize, response_deserializer=hub.ListSpokesResponse.deserialize, @@ -472,7 +584,7 @@ def get_spoke(self) -> Callable[[hub.GetSpokeRequest], Awaitable[hub.Spoke]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_spoke" not in self._stubs: - self._stubs["get_spoke"] = self.grpc_channel.unary_unary( + self._stubs["get_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetSpoke", request_serializer=hub.GetSpokeRequest.serialize, response_deserializer=hub.Spoke.deserialize, @@ -498,7 +610,7 @@ def create_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_spoke" not in self._stubs: - self._stubs["create_spoke"] = self.grpc_channel.unary_unary( + self._stubs["create_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/CreateSpoke", request_serializer=hub.CreateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -525,7 +637,7 @@ def update_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_spoke" not in self._stubs: - self._stubs["update_spoke"] = self.grpc_channel.unary_unary( + self._stubs["update_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/UpdateSpoke", request_serializer=hub.UpdateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -554,7 +666,7 @@ def reject_hub_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reject_hub_spoke" not in self._stubs: - self._stubs["reject_hub_spoke"] = self.grpc_channel.unary_unary( + self._stubs["reject_hub_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/RejectHubSpoke", request_serializer=hub.RejectHubSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -581,7 +693,7 @@ def accept_hub_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "accept_hub_spoke" not in self._stubs: - self._stubs["accept_hub_spoke"] = self.grpc_channel.unary_unary( + self._stubs["accept_hub_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/AcceptHubSpoke", request_serializer=hub.AcceptHubSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -607,7 +719,7 @@ def delete_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_spoke" not in self._stubs: - self._stubs["delete_spoke"] = self.grpc_channel.unary_unary( + self._stubs["delete_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/DeleteSpoke", request_serializer=hub.DeleteSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -634,7 +746,7 @@ def get_route_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_route_table" not in self._stubs: - self._stubs["get_route_table"] = self.grpc_channel.unary_unary( + self._stubs["get_route_table"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetRouteTable", request_serializer=hub.GetRouteTableRequest.serialize, response_deserializer=hub.RouteTable.deserialize, @@ -658,7 +770,7 @@ def get_route(self) -> Callable[[hub.GetRouteRequest], Awaitable[hub.Route]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_route" not in self._stubs: - self._stubs["get_route"] = self.grpc_channel.unary_unary( + self._stubs["get_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetRoute", request_serializer=hub.GetRouteRequest.serialize, response_deserializer=hub.Route.deserialize, @@ -671,7 +783,7 @@ def list_routes( ) -> Callable[[hub.ListRoutesRequest], Awaitable[hub.ListRoutesResponse]]: r"""Return a callable for the list routes method over gRPC. - Lists routes in a given project. + Lists routes in a given route table. Returns: Callable[[~.ListRoutesRequest], @@ -684,7 +796,7 @@ def list_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_routes" not in self._stubs: - self._stubs["list_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_routes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListRoutes", request_serializer=hub.ListRoutesRequest.serialize, response_deserializer=hub.ListRoutesResponse.deserialize, @@ -697,7 +809,7 @@ def list_route_tables( ) -> Callable[[hub.ListRouteTablesRequest], Awaitable[hub.ListRouteTablesResponse]]: r"""Return a callable for the list route tables method over gRPC. - Lists route tables in a given project. + Lists route tables in a given hub. Returns: Callable[[~.ListRouteTablesRequest], @@ -710,7 +822,7 @@ def list_route_tables( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_route_tables" not in self._stubs: - self._stubs["list_route_tables"] = self.grpc_channel.unary_unary( + self._stubs["list_route_tables"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListRouteTables", request_serializer=hub.ListRouteTablesRequest.serialize, response_deserializer=hub.ListRouteTablesResponse.deserialize, @@ -735,7 +847,7 @@ def get_group(self) -> Callable[[hub.GetGroupRequest], Awaitable[hub.Group]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_group" not in self._stubs: - self._stubs["get_group"] = self.grpc_channel.unary_unary( + self._stubs["get_group"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/GetGroup", request_serializer=hub.GetGroupRequest.serialize, response_deserializer=hub.Group.deserialize, @@ -761,13 +873,40 @@ def list_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_groups" not in self._stubs: - self._stubs["list_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_groups"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.HubService/ListGroups", request_serializer=hub.ListGroupsRequest.serialize, response_deserializer=hub.ListGroupsResponse.deserialize, ) return self._stubs["list_groups"] + @property + def update_group( + self, + ) -> Callable[[hub.UpdateGroupRequest], Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update group method over gRPC. + + Updates the parameters of a Network Connectivity + Center group. + + Returns: + Callable[[~.UpdateGroupRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_group" not in self._stubs: + self._stubs["update_group"] = self._logged_channel.unary_unary( + "/google.cloud.networkconnectivity.v1.HubService/UpdateGroup", + request_serializer=hub.UpdateGroupRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_group"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -801,6 +940,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.query_hub_status: self._wrap_method( + self.query_hub_status, + default_timeout=None, + client_info=client_info, + ), self.list_spokes: self._wrap_method( self.list_spokes, default_timeout=None, @@ -866,6 +1010,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_group: self._wrap_method( + self.update_group, + default_timeout=None, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, @@ -919,7 +1068,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: @@ -935,7 +1084,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -952,7 +1101,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -969,7 +1118,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -988,7 +1137,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -1007,7 +1156,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, @@ -1024,7 +1173,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, @@ -1049,7 +1198,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1075,7 +1224,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1104,7 +1253,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/async_client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/async_client.py index dd7c08de9d78..bf577f05a8d9 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/async_client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/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, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PolicyBasedRoutingServiceTransport from .transports.grpc_asyncio import PolicyBasedRoutingServiceGrpcAsyncIOTransport +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 PolicyBasedRoutingServiceAsyncClient: """Policy-Based Routing allows GCP customers to specify @@ -288,6 +298,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.networkconnectivity_v1.PolicyBasedRoutingServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "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.networkconnectivity.v1.PolicyBasedRoutingService", + "credentialsType": None, + }, + ) + async def list_policy_based_routes( self, request: Optional[ @@ -297,7 +329,7 @@ async def list_policy_based_routes( 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.ListPolicyBasedRoutesAsyncPager: r"""Lists PolicyBasedRoutes in a given project and location. @@ -341,8 +373,10 @@ async def sample_list_policy_based_routes(): 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.networkconnectivity_v1.services.policy_based_routing_service.pagers.ListPolicyBasedRoutesAsyncPager: @@ -419,7 +453,7 @@ async def get_policy_based_route( 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]]] = (), ) -> policy_based_routing.PolicyBasedRoute: r"""Gets details of a single PolicyBasedRoute. @@ -463,8 +497,10 @@ async def sample_get_policy_based_route(): 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.networkconnectivity_v1.types.PolicyBasedRoute: @@ -535,7 +571,7 @@ async def create_policy_based_route( policy_based_route_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new PolicyBasedRoute in a given project and location. @@ -605,8 +641,10 @@ async def sample_create_policy_based_route(): 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.api_core.operation_async.AsyncOperation: @@ -686,7 +724,7 @@ async def delete_policy_based_route( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single PolicyBasedRoute. @@ -734,8 +772,10 @@ async def sample_delete_policy_based_route(): 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.api_core.operation_async.AsyncOperation: @@ -813,7 +853,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -824,8 +864,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -866,7 +908,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -877,8 +919,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -919,7 +963,7 @@ async def delete_operation( *, 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 long-running operation. @@ -935,8 +979,10 @@ async def delete_operation( 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: None """ @@ -973,7 +1019,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -988,8 +1034,10 @@ async def cancel_operation( 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: None """ @@ -1026,7 +1074,7 @@ async def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -1039,8 +1087,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1145,7 +1195,7 @@ async def get_iam_policy( *, 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 IAM access control policy for a function. @@ -1159,8 +1209,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1265,7 +1317,7 @@ async def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1280,8 +1332,10 @@ async def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1325,7 +1379,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. @@ -1336,8 +1390,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. @@ -1378,7 +1434,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. @@ -1389,8 +1445,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-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/client.py index f1424833d4be..aa384598515b 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -615,6 +625,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( @@ -681,6 +695,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.networkconnectivity_v1.PolicyBasedRoutingServiceClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "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.networkconnectivity.v1.PolicyBasedRoutingService", + "credentialsType": None, + }, + ) + def list_policy_based_routes( self, request: Optional[ @@ -690,7 +727,7 @@ def list_policy_based_routes( 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.ListPolicyBasedRoutesPager: r"""Lists PolicyBasedRoutes in a given project and location. @@ -734,8 +771,10 @@ def sample_list_policy_based_routes(): 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.networkconnectivity_v1.services.policy_based_routing_service.pagers.ListPolicyBasedRoutesPager: @@ -809,7 +848,7 @@ def get_policy_based_route( 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]]] = (), ) -> policy_based_routing.PolicyBasedRoute: r"""Gets details of a single PolicyBasedRoute. @@ -853,8 +892,10 @@ def sample_get_policy_based_route(): 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.networkconnectivity_v1.types.PolicyBasedRoute: @@ -922,7 +963,7 @@ def create_policy_based_route( policy_based_route_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new PolicyBasedRoute in a given project and location. @@ -992,8 +1033,10 @@ def sample_create_policy_based_route(): 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.api_core.operation.Operation: @@ -1072,7 +1115,7 @@ def delete_policy_based_route( 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]]] = (), ) -> operation.Operation: r"""Deletes a single PolicyBasedRoute. @@ -1120,8 +1163,10 @@ def sample_delete_policy_based_route(): 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.api_core.operation.Operation: @@ -1211,7 +1256,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1222,8 +1267,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1264,7 +1311,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1275,8 +1322,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1317,7 +1366,7 @@ def delete_operation( *, 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 long-running operation. @@ -1333,8 +1382,10 @@ def delete_operation( 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: None """ @@ -1371,7 +1422,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1386,8 +1437,10 @@ def cancel_operation( 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: None """ @@ -1424,7 +1477,7 @@ def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -1437,8 +1490,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1543,7 +1598,7 @@ def get_iam_policy( *, 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 IAM access control policy for a function. @@ -1557,8 +1612,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -1663,7 +1720,7 @@ def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -1678,8 +1735,10 @@ def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -1721,7 +1780,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. @@ -1732,8 +1791,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. @@ -1774,7 +1835,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. @@ -1785,8 +1846,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-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/pagers.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/pagers.py index af85273d31df..80bebfada557 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/pagers.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/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 = policy_based_routing.ListPolicyBasedRoutesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = policy_based_routing.ListPolicyBasedRoutesRequest(request) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py index 99f3bae667cb..3c995081cd3d 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/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,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.networkconnectivity_v1.types import policy_based_routing from .base import DEFAULT_CLIENT_INFO, PolicyBasedRoutingServiceTransport +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.networkconnectivity.v1.PolicyBasedRoutingService", + "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.networkconnectivity.v1.PolicyBasedRoutingService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PolicyBasedRoutingServiceGrpcTransport(PolicyBasedRoutingServiceTransport): """gRPC backend transport for PolicyBasedRoutingService. @@ -186,7 +267,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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -278,7 +366,7 @@ def list_policy_based_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_policy_based_routes" not in self._stubs: - self._stubs["list_policy_based_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_policy_based_routes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes", request_serializer=policy_based_routing.ListPolicyBasedRoutesRequest.serialize, response_deserializer=policy_based_routing.ListPolicyBasedRoutesResponse.deserialize, @@ -307,7 +395,7 @@ def get_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy_based_route" not in self._stubs: - self._stubs["get_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["get_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute", request_serializer=policy_based_routing.GetPolicyBasedRouteRequest.serialize, response_deserializer=policy_based_routing.PolicyBasedRoute.deserialize, @@ -336,7 +424,7 @@ def create_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_policy_based_route" not in self._stubs: - self._stubs["create_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["create_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute", request_serializer=policy_based_routing.CreatePolicyBasedRouteRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -364,7 +452,7 @@ def delete_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_policy_based_route" not in self._stubs: - self._stubs["delete_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["delete_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute", request_serializer=policy_based_routing.DeletePolicyBasedRouteRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +460,7 @@ def delete_policy_based_route( return self._stubs["delete_policy_based_route"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -384,7 +472,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -401,7 +489,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -418,7 +506,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -437,7 +525,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -456,7 +544,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, @@ -473,7 +561,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, @@ -498,7 +586,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -524,7 +612,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -553,7 +641,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py index d89fad4aba5d..52e31b476a00 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/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,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.networkconnectivity_v1.types import policy_based_routing from .base import DEFAULT_CLIENT_INFO, PolicyBasedRoutingServiceTransport from .grpc import PolicyBasedRoutingServiceGrpcTransport +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.networkconnectivity.v1.PolicyBasedRoutingService", + "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.networkconnectivity.v1.PolicyBasedRoutingService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PolicyBasedRoutingServiceGrpcAsyncIOTransport(PolicyBasedRoutingServiceTransport): """gRPC AsyncIO backend transport for PolicyBasedRoutingService. @@ -233,10 +315,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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def list_policy_based_routes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_policy_based_routes" not in self._stubs: - self._stubs["list_policy_based_routes"] = self.grpc_channel.unary_unary( + self._stubs["list_policy_based_routes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/ListPolicyBasedRoutes", request_serializer=policy_based_routing.ListPolicyBasedRoutesRequest.serialize, response_deserializer=policy_based_routing.ListPolicyBasedRoutesResponse.deserialize, @@ -317,7 +402,7 @@ def get_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy_based_route" not in self._stubs: - self._stubs["get_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["get_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/GetPolicyBasedRoute", request_serializer=policy_based_routing.GetPolicyBasedRouteRequest.serialize, response_deserializer=policy_based_routing.PolicyBasedRoute.deserialize, @@ -347,7 +432,7 @@ def create_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_policy_based_route" not in self._stubs: - self._stubs["create_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["create_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/CreatePolicyBasedRoute", request_serializer=policy_based_routing.CreatePolicyBasedRouteRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +461,7 @@ def delete_policy_based_route( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_policy_based_route" not in self._stubs: - self._stubs["delete_policy_based_route"] = self.grpc_channel.unary_unary( + self._stubs["delete_policy_based_route"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1.PolicyBasedRoutingService/DeletePolicyBasedRoute", request_serializer=policy_based_routing.DeletePolicyBasedRouteRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -459,7 +544,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: @@ -475,7 +560,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -492,7 +577,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -509,7 +594,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -528,7 +613,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -547,7 +632,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, @@ -564,7 +649,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, @@ -589,7 +674,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -615,7 +700,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -644,7 +729,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/__init__.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/__init__.py index 2ab2e13f31ab..496e17bdcda8 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/__init__.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/__init__.py @@ -17,6 +17,7 @@ from .hub import ( AcceptHubSpokeRequest, AcceptHubSpokeResponse, + AutoAccept, CreateHubRequest, CreateSpokeRequest, DeleteHubRequest, @@ -28,7 +29,9 @@ GetSpokeRequest, Group, Hub, + HubStatusEntry, LinkedInterconnectAttachments, + LinkedProducerVpcNetwork, LinkedRouterApplianceInstances, LinkedVpcNetwork, LinkedVpnTunnels, @@ -46,7 +49,15 @@ ListSpokesResponse, LocationFeature, LocationMetadata, + NextHopInterconnectAttachment, + NextHopRouterApplianceInstance, NextHopVpcNetwork, + NextHopVPNTunnel, + PolicyMode, + PresetTopology, + PscPropagationStatus, + QueryHubStatusRequest, + QueryHubStatusResponse, RejectHubSpokeRequest, RejectHubSpokeResponse, Route, @@ -58,6 +69,7 @@ SpokeSummary, SpokeType, State, + UpdateGroupRequest, UpdateHubRequest, UpdateSpokeRequest, ) @@ -74,6 +86,7 @@ "OperationMetadata", "AcceptHubSpokeRequest", "AcceptHubSpokeResponse", + "AutoAccept", "CreateHubRequest", "CreateSpokeRequest", "DeleteHubRequest", @@ -85,7 +98,9 @@ "GetSpokeRequest", "Group", "Hub", + "HubStatusEntry", "LinkedInterconnectAttachments", + "LinkedProducerVpcNetwork", "LinkedRouterApplianceInstances", "LinkedVpcNetwork", "LinkedVpnTunnels", @@ -102,7 +117,13 @@ "ListSpokesRequest", "ListSpokesResponse", "LocationMetadata", + "NextHopInterconnectAttachment", + "NextHopRouterApplianceInstance", "NextHopVpcNetwork", + "NextHopVPNTunnel", + "PscPropagationStatus", + "QueryHubStatusRequest", + "QueryHubStatusResponse", "RejectHubSpokeRequest", "RejectHubSpokeResponse", "Route", @@ -111,9 +132,12 @@ "RoutingVPC", "Spoke", "SpokeSummary", + "UpdateGroupRequest", "UpdateHubRequest", "UpdateSpokeRequest", "LocationFeature", + "PolicyMode", + "PresetTopology", "RouteType", "SpokeType", "State", diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/hub.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/hub.py index df0c73e0e169..fa6538e4605b 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/hub.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/types/hub.py @@ -28,12 +28,15 @@ "RouteType", "State", "SpokeType", + "PolicyMode", + "PresetTopology", "Hub", "RoutingVPC", "Spoke", "RouteTable", "Route", "Group", + "AutoAccept", "ListHubsRequest", "ListHubsResponse", "GetHubRequest", @@ -42,6 +45,10 @@ "DeleteHubRequest", "ListHubSpokesRequest", "ListHubSpokesResponse", + "QueryHubStatusRequest", + "QueryHubStatusResponse", + "HubStatusEntry", + "PscPropagationStatus", "ListSpokesRequest", "ListSpokesResponse", "GetSpokeRequest", @@ -64,11 +71,16 @@ "LinkedInterconnectAttachments", "LinkedRouterApplianceInstances", "LinkedVpcNetwork", + "LinkedProducerVpcNetwork", "RouterApplianceInstance", "LocationMetadata", "NextHopVpcNetwork", + "NextHopVPNTunnel", + "NextHopRouterApplianceInstance", + "NextHopInterconnectAttachment", "SpokeSummary", "GetGroupRequest", + "UpdateGroupRequest", }, ) @@ -106,10 +118,16 @@ class RouteType(proto.Enum): The route leads to a destination within the secondary address range of the VPC network's subnet. + DYNAMIC_ROUTE (3): + The route leads to a destination in a dynamic + route. Dynamic routes are derived from Border + Gateway Protocol (BGP) advertisements received + from an NCC hybrid spoke. """ ROUTE_TYPE_UNSPECIFIED = 0 VPC_PRIMARY_SUBNET = 1 VPC_SECONDARY_SUBNET = 2 + DYNAMIC_ROUTE = 3 class State(proto.Enum): @@ -170,12 +188,51 @@ class SpokeType(proto.Enum): instances. VPC_NETWORK (4): Spokes associated with VPC networks. + PRODUCER_VPC_NETWORK (7): + Spokes that are backed by a producer VPC + network. """ SPOKE_TYPE_UNSPECIFIED = 0 VPN_TUNNEL = 1 INTERCONNECT_ATTACHMENT = 2 ROUTER_APPLIANCE = 3 VPC_NETWORK = 4 + PRODUCER_VPC_NETWORK = 7 + + +class PolicyMode(proto.Enum): + r"""This enum controls the policy mode used in a hub. + + Values: + POLICY_MODE_UNSPECIFIED (0): + Policy mode is unspecified. It defaults to PRESET with + preset_topology = MESH. + PRESET (1): + Hub uses one of the preset topologies. + """ + POLICY_MODE_UNSPECIFIED = 0 + PRESET = 1 + + +class PresetTopology(proto.Enum): + r"""The list of available preset topologies. + + Values: + PRESET_TOPOLOGY_UNSPECIFIED (0): + Preset topology is unspecified. When policy_mode = PRESET, + it defaults to MESH. + MESH (2): + Mesh topology is implemented. Group ``default`` is + automatically created. All spokes in the hub are added to + group ``default``. + STAR (3): + Star topology is implemented. Two groups, ``center`` and + ``edge``, are automatically created along with hub creation. + Spokes have to join one of the groups during creation. + """ + PRESET_TOPOLOGY_UNSPECIFIED = 0 + MESH = 2 + STAR = 3 class Hub(proto.Message): @@ -187,6 +244,9 @@ class Hub(proto.Message): network. Spokes that do not use site-to-site data transfer can be associated with any VPC network in your project. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Immutable. The name of the hub. Hub names must be unique. @@ -232,6 +292,26 @@ class Hub(proto.Message): to state. If any spokes are inactive, the summary also lists the reasons they are inactive, including a count for each reason. + policy_mode (google.cloud.networkconnectivity_v1.types.PolicyMode): + Optional. The policy mode of this hub. This field can be + either PRESET or CUSTOM. If unspecified, the policy_mode + defaults to PRESET. + preset_topology (google.cloud.networkconnectivity_v1.types.PresetTopology): + Optional. The topology implemented in this hub. Currently, + this field is only used when policy_mode = PRESET. The + available preset topologies are MESH and STAR. If + preset_topology is unspecified and policy_mode = PRESET, the + preset_topology defaults to MESH. When policy_mode = CUSTOM, + the preset_topology is set to PRESET_TOPOLOGY_UNSPECIFIED. + export_psc (bool): + Optional. Whether Private Service Connect + transitivity is enabled for the hub. If true, + Private Service Connect endpoints in VPC spokes + attached to the hub are made accessible to other + VPC spokes attached to the hub. The default + value is false. + + This field is a member of `oneof`_ ``_export_psc``. """ name: str = proto.Field( @@ -280,6 +360,21 @@ class Hub(proto.Message): number=12, message="SpokeSummary", ) + policy_mode: "PolicyMode" = proto.Field( + proto.ENUM, + number=13, + enum="PolicyMode", + ) + preset_topology: "PresetTopology" = proto.Field( + proto.ENUM, + number=14, + enum="PresetTopology", + ) + export_psc: bool = proto.Field( + proto.BOOL, + number=15, + optional=True, + ) class RoutingVPC(proto.Message): @@ -354,6 +449,9 @@ class Spoke(proto.Message): linked_vpc_network (google.cloud.networkconnectivity_v1.types.LinkedVpcNetwork): Optional. VPC network that is associated with the spoke. + linked_producer_vpc_network (google.cloud.networkconnectivity_v1.types.LinkedProducerVpcNetwork): + Optional. The linked producer VPC that is + associated with the spoke. unique_id (str): Output only. The Google-generated UUID for the spoke. This value is unique across all spoke resources. If a spoke is @@ -472,6 +570,11 @@ class Code(proto.Enum): number=20, message="LinkedVpcNetwork", ) + linked_producer_vpc_network: "LinkedProducerVpcNetwork" = proto.Field( + proto.MESSAGE, + number=26, + message="LinkedProducerVpcNetwork", + ) unique_id: str = proto.Field( proto.STRING, number=11, @@ -601,10 +704,25 @@ class Route(proto.Message): to. Example: projects/12345/locations/global/spokes/SPOKE location (str): - Output only. The location of the route. - Uses the following form: + Output only. The origin location of the + route. Uses the following form: "projects/{project}/locations/{location}" Example: projects/1234/locations/us-central1 + priority (int): + Output only. The priority of this route. + Priority is used to break ties in cases where a + destination matches more than one route. In + these cases the route with the lowest-numbered + priority value wins. + next_hop_vpn_tunnel (google.cloud.networkconnectivity_v1.types.NextHopVPNTunnel): + Immutable. The next-hop VPN tunnel for + packets on this route. + next_hop_router_appliance_instance (google.cloud.networkconnectivity_v1.types.NextHopRouterApplianceInstance): + Immutable. The next-hop Router appliance + instance for packets on this route. + next_hop_interconnect_attachment (google.cloud.networkconnectivity_v1.types.NextHopInterconnectAttachment): + Immutable. The next-hop VLAN attachment for + packets on this route. """ name: str = proto.Field( @@ -661,6 +779,25 @@ class Route(proto.Message): proto.STRING, number=12, ) + priority: int = proto.Field( + proto.INT64, + number=13, + ) + next_hop_vpn_tunnel: "NextHopVPNTunnel" = proto.Field( + proto.MESSAGE, + number=14, + message="NextHopVPNTunnel", + ) + next_hop_router_appliance_instance: "NextHopRouterApplianceInstance" = proto.Field( + proto.MESSAGE, + number=15, + message="NextHopRouterApplianceInstance", + ) + next_hop_interconnect_attachment: "NextHopInterconnectAttachment" = proto.Field( + proto.MESSAGE, + number=16, + message="NextHopInterconnectAttachment", + ) class Group(proto.Message): @@ -690,6 +827,13 @@ class Group(proto.Message): state (google.cloud.networkconnectivity_v1.types.State): Output only. The current lifecycle state of this group. + auto_accept (google.cloud.networkconnectivity_v1.types.AutoAccept): + Optional. The auto-accept setting for this + group. + route_table (str): + Output only. The name of the route table that corresponds to + this group. They use the following form: + ``projects/{project_number}/locations/global/hubs/{hub_id}/routeTables/{route_table_id}`` """ name: str = proto.Field( @@ -724,6 +868,38 @@ class Group(proto.Message): number=7, enum="State", ) + auto_accept: "AutoAccept" = proto.Field( + proto.MESSAGE, + number=8, + message="AutoAccept", + ) + route_table: str = proto.Field( + proto.STRING, + number=9, + ) + + +class AutoAccept(proto.Message): + r"""The auto-accept setting for a group controls whether + proposed spokes are automatically attached to the hub. If + auto-accept is enabled, the spoke immediately is attached to the + hub and becomes part of the group. In this case, the new spoke + is in the ACTIVE state. If auto-accept is disabled, the spoke + goes to the INACTIVE state, and it must be reviewed and accepted + by a hub administrator. + + Attributes: + auto_accept_projects (MutableSequence[str]): + A list of project ids or project numbers for + which you want to enable auto-accept. The + auto-accept setting is applied to spokes being + created or updated in these projects. + """ + + auto_accept_projects: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) class ListHubsRequest(proto.Message): @@ -1090,6 +1266,242 @@ def raw_page(self): ) +class QueryHubStatusRequest(proto.Message): + r"""The request for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + + Attributes: + name (str): + Required. The name of the hub. + page_size (int): + Optional. The maximum number of results to + return per page. + page_token (str): + Optional. The page token. + filter (str): + Optional. An expression that filters the list of results. + The filter can be used to filter the results by the + following fields: + + - ``psc_propagation_status.source_spoke`` + - ``psc_propagation_status.source_group`` + - ``psc_propagation_status.source_forwarding_rule`` + - ``psc_propagation_status.target_spoke`` + - ``psc_propagation_status.target_group`` + - ``psc_propagation_status.code`` + - ``psc_propagation_status.message`` + order_by (str): + Optional. Sort the results in ascending order by the + specified fields. A comma-separated list of any of these + fields: + + - ``psc_propagation_status.source_spoke`` + - ``psc_propagation_status.source_group`` + - ``psc_propagation_status.source_forwarding_rule`` + - ``psc_propagation_status.target_spoke`` + - ``psc_propagation_status.target_group`` + - ``psc_propagation_status.code`` If ``group_by`` is set, + the value of the ``order_by`` field must be the same as + or a subset of the ``group_by`` field. + group_by (str): + Optional. Aggregate the results by the specified fields. A + comma-separated list of any of these fields: + + - ``psc_propagation_status.source_spoke`` + - ``psc_propagation_status.source_group`` + - ``psc_propagation_status.source_forwarding_rule`` + - ``psc_propagation_status.target_spoke`` + - ``psc_propagation_status.target_group`` + - ``psc_propagation_status.code`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + group_by: str = proto.Field( + proto.STRING, + number=6, + ) + + +class QueryHubStatusResponse(proto.Message): + r"""The response for + [HubService.QueryHubStatus][google.cloud.networkconnectivity.v1.HubService.QueryHubStatus]. + + Attributes: + hub_status_entries (MutableSequence[google.cloud.networkconnectivity_v1.types.HubStatusEntry]): + The list of hub status. + next_page_token (str): + The token for the next page of the response. To see more + results, use this value as the page_token for your next + request. If this value is empty, there are no more results. + """ + + @property + def raw_page(self): + return self + + hub_status_entries: MutableSequence["HubStatusEntry"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="HubStatusEntry", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class HubStatusEntry(proto.Message): + r"""A hub status entry represents the status of a set of + propagated Private Service Connect connections grouped by + certain fields. + + Attributes: + count (int): + The number of propagated Private Service Connect connections + with this status. If the ``group_by`` field was not set in + the request message, the value of this field is 1. + group_by (str): + The fields that this entry is grouped by. This has the same + value as the ``group_by`` field in the request message. + psc_propagation_status (google.cloud.networkconnectivity_v1.types.PscPropagationStatus): + The Private Service Connect propagation + status. + """ + + count: int = proto.Field( + proto.INT32, + number=1, + ) + group_by: str = proto.Field( + proto.STRING, + number=2, + ) + psc_propagation_status: "PscPropagationStatus" = proto.Field( + proto.MESSAGE, + number=3, + message="PscPropagationStatus", + ) + + +class PscPropagationStatus(proto.Message): + r"""The status of one or more propagated Private Service Connect + connections in a hub. + + Attributes: + source_spoke (str): + The name of the spoke that the source + forwarding rule belongs to. + source_group (str): + The name of the group that the source spoke + belongs to. + source_forwarding_rule (str): + The name of the forwarding rule exported to + the hub. + target_spoke (str): + The name of the spoke that the source + forwarding rule propagates to. + target_group (str): + The name of the group that the target spoke + belongs to. + code (google.cloud.networkconnectivity_v1.types.PscPropagationStatus.Code): + The propagation status. + message (str): + The human-readable summary of the Private + Service Connect connection propagation status. + """ + + class Code(proto.Enum): + r"""The Code enum represents the state of the Private Service + Connect propagation. + + Values: + CODE_UNSPECIFIED (0): + The code is unspecified. + READY (1): + The propagated Private Service Connect + connection is ready. + PROPAGATING (2): + The Private Service Connect connection is + propagating. This is a transient state. + ERROR_PRODUCER_PROPAGATED_CONNECTION_LIMIT_EXCEEDED (3): + The Private Service Connect connection + propagation failed because the VPC network or + the project of the target spoke has exceeded the + connection limit set by the producer. + ERROR_PRODUCER_NAT_IP_SPACE_EXHAUSTED (4): + The Private Service Connect connection propagation failed + because the NAT IP subnet space has been exhausted. It is + equivalent to the ``Needs attention`` status of the Private + Service Connect connection. See + https://cloud.google.com/vpc/docs/about-accessing-vpc-hosted-services-endpoints#connection-statuses. + ERROR_PRODUCER_QUOTA_EXCEEDED (5): + The Private Service Connect connection propagation failed + because the + ``PSC_ILB_CONSUMER_FORWARDING_RULES_PER_PRODUCER_NETWORK`` + quota in the producer VPC network has been exceeded. + ERROR_CONSUMER_QUOTA_EXCEEDED (6): + The Private Service Connect connection propagation failed + because the ``PSC_PROPAGATED_CONNECTIONS_PER_VPC_NETWORK`` + quota in the consumer VPC network has been exceeded. + """ + CODE_UNSPECIFIED = 0 + READY = 1 + PROPAGATING = 2 + ERROR_PRODUCER_PROPAGATED_CONNECTION_LIMIT_EXCEEDED = 3 + ERROR_PRODUCER_NAT_IP_SPACE_EXHAUSTED = 4 + ERROR_PRODUCER_QUOTA_EXCEEDED = 5 + ERROR_CONSUMER_QUOTA_EXCEEDED = 6 + + source_spoke: str = proto.Field( + proto.STRING, + number=1, + ) + source_group: str = proto.Field( + proto.STRING, + number=2, + ) + source_forwarding_rule: str = proto.Field( + proto.STRING, + number=3, + ) + target_spoke: str = proto.Field( + proto.STRING, + number=4, + ) + target_group: str = proto.Field( + proto.STRING, + number=5, + ) + code: Code = proto.Field( + proto.ENUM, + number=6, + enum=Code, + ) + message: str = proto.Field( + proto.STRING, + number=7, + ) + + class ListSpokesRequest(proto.Message): r"""The request for [HubService.ListSpokes][google.cloud.networkconnectivity.v1.HubService.ListSpokes]. @@ -1743,6 +2155,10 @@ class LinkedVpnTunnels(proto.Message): vpc_network (str): Output only. The VPC network where these VPN tunnels are located. + include_import_ranges (MutableSequence[str]): + Optional. IP ranges allowed to be included during import + from hub (does not control transit connectivity). The only + allowed value for now is "ALL_IPV4_RANGES". """ uris: MutableSequence[str] = proto.RepeatedField( @@ -1757,6 +2173,10 @@ class LinkedVpnTunnels(proto.Message): proto.STRING, number=3, ) + include_import_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) class LinkedInterconnectAttachments(proto.Message): @@ -1778,6 +2198,10 @@ class LinkedInterconnectAttachments(proto.Message): vpc_network (str): Output only. The VPC network where these VLAN attachments are located. + include_import_ranges (MutableSequence[str]): + Optional. IP ranges allowed to be included during import + from hub (does not control transit connectivity). The only + allowed value for now is "ALL_IPV4_RANGES". """ uris: MutableSequence[str] = proto.RepeatedField( @@ -1792,6 +2216,10 @@ class LinkedInterconnectAttachments(proto.Message): proto.STRING, number=3, ) + include_import_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) class LinkedRouterApplianceInstances(proto.Message): @@ -1811,6 +2239,10 @@ class LinkedRouterApplianceInstances(proto.Message): vpc_network (str): Output only. The VPC network where these router appliance instances are located. + include_import_ranges (MutableSequence[str]): + Optional. IP ranges allowed to be included during import + from hub (does not control transit connectivity). The only + allowed value for now is "ALL_IPV4_RANGES". """ instances: MutableSequence["RouterApplianceInstance"] = proto.RepeatedField( @@ -1826,6 +2258,10 @@ class LinkedRouterApplianceInstances(proto.Message): proto.STRING, number=3, ) + include_import_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) class LinkedVpcNetwork(proto.Message): @@ -1838,6 +2274,15 @@ class LinkedVpcNetwork(proto.Message): exclude_export_ranges (MutableSequence[str]): Optional. IP ranges encompassing the subnets to be excluded from peering. + include_export_ranges (MutableSequence[str]): + Optional. IP ranges allowed to be included + from peering. + producer_vpc_spokes (MutableSequence[str]): + Output only. The list of Producer VPC spokes + that this VPC spoke is a service consumer VPC + spoke for. These producer VPCs are connected + through VPC peering to this spoke's backing VPC + network. """ uri: str = proto.Field( @@ -1848,6 +2293,66 @@ class LinkedVpcNetwork(proto.Message): proto.STRING, number=2, ) + include_export_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + producer_vpc_spokes: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + + +class LinkedProducerVpcNetwork(proto.Message): + r""" + + Attributes: + network (str): + Immutable. The URI of the Service Consumer + VPC that the Producer VPC is peered with. + service_consumer_vpc_spoke (str): + Output only. The Service Consumer Network + spoke. + peering (str): + Immutable. The name of the VPC peering + between the Service Consumer VPC and the + Producer VPC (defined in the Tenant project) + which is added to the NCC hub. This peering must + be in ACTIVE state. + producer_network (str): + Output only. The URI of the Producer VPC. + exclude_export_ranges (MutableSequence[str]): + Optional. IP ranges encompassing the subnets + to be excluded from peering. + include_export_ranges (MutableSequence[str]): + Optional. IP ranges allowed to be included + from peering. + """ + + network: str = proto.Field( + proto.STRING, + number=1, + ) + service_consumer_vpc_spoke: str = proto.Field( + proto.STRING, + number=6, + ) + peering: str = proto.Field( + proto.STRING, + number=2, + ) + producer_network: str = proto.Field( + proto.STRING, + number=5, + ) + exclude_export_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + include_export_ranges: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) class RouterApplianceInstance(proto.Message): @@ -1902,6 +2407,97 @@ class NextHopVpcNetwork(proto.Message): ) +class NextHopVPNTunnel(proto.Message): + r"""A route next hop that leads to a VPN tunnel resource. + + Attributes: + uri (str): + The URI of the VPN tunnel resource. + vpc_network (str): + The VPC network where this VPN tunnel is + located. + site_to_site_data_transfer (bool): + Indicates whether site-to-site data transfer is allowed for + this VPN tunnel resource. Data transfer is available only in + `supported + locations `__. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + vpc_network: str = proto.Field( + proto.STRING, + number=2, + ) + site_to_site_data_transfer: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class NextHopRouterApplianceInstance(proto.Message): + r"""A route next hop that leads to a Router appliance instance. + + Attributes: + uri (str): + The URI of the Router appliance instance. + vpc_network (str): + The VPC network where this VM is located. + site_to_site_data_transfer (bool): + Indicates whether site-to-site data transfer is allowed for + this Router appliance instance resource. Data transfer is + available only in `supported + locations `__. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + vpc_network: str = proto.Field( + proto.STRING, + number=2, + ) + site_to_site_data_transfer: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class NextHopInterconnectAttachment(proto.Message): + r"""A route next hop that leads to an interconnect attachment + resource. + + Attributes: + uri (str): + The URI of the interconnect attachment + resource. + vpc_network (str): + The VPC network where this interconnect + attachment is located. + site_to_site_data_transfer (bool): + Indicates whether site-to-site data transfer is allowed for + this interconnect attachment resource. Data transfer is + available only in `supported + locations `__. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + vpc_network: str = proto.Field( + proto.STRING, + number=2, + ) + site_to_site_data_transfer: bool = proto.Field( + proto.BOOL, + number=3, + ) + + class SpokeSummary(proto.Message): r"""Summarizes information about the spokes associated with a hub. The summary includes a count of spokes according to type @@ -2029,4 +2625,59 @@ class GetGroupRequest(proto.Message): ) +class UpdateGroupRequest(proto.Message): + r"""Request for + [HubService.UpdateGroup][google.cloud.networkconnectivity.v1.HubService.UpdateGroup] + method. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. In the case of an update to an existing group, + field mask is used to specify the fields to be overwritten. + The fields specified in the update_mask are relative to the + resource, not the full request. A field is overwritten if it + is in the mask. If the user does not provide a mask, then + all fields are overwritten. + group (google.cloud.networkconnectivity_v1.types.Group): + Required. The state that the group should be + in after the update. + request_id (str): + Optional. A request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server knows to ignore + the request if it has already been completed. + The server guarantees that a request doesn't + result in creation of duplicate commitments for + at least 60 minutes. + + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check to see whether the + original operation was received. If it was, the + server ignores the second request. This behavior + prevents clients from mistakenly creating + duplicate commitments. + + The request ID must be a valid UUID, with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + group: "Group" = proto.Field( + proto.MESSAGE, + number=2, + message="Group", + ) + request_id: str = proto.Field( + proto.STRING, + number=3, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/gapic_version.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/gapic_version.py index 4ed306c1cb52..558c8aab67c5 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/gapic_version.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/async_client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/async_client.py index 7d7a93a4ce56..ecfbec9f1294 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/async_client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, HubServiceTransport from .transports.grpc_asyncio import HubServiceGrpcAsyncIOTransport +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 HubServiceAsyncClient: """Network Connectivity Center is a hub-and-spoke abstraction @@ -272,6 +282,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.networkconnectivity_v1alpha1.HubServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1alpha1.HubService", + "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.networkconnectivity.v1alpha1.HubService", + "credentialsType": None, + }, + ) + async def list_hubs( self, request: Optional[Union[hub.ListHubsRequest, dict]] = None, @@ -279,7 +311,7 @@ async def list_hubs( 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.ListHubsAsyncPager: r"""Lists Hubs in a given project and location. @@ -323,8 +355,10 @@ async def sample_list_hubs(): 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.networkconnectivity_v1alpha1.services.hub_service.pagers.ListHubsAsyncPager: @@ -400,7 +434,7 @@ async def get_hub( 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]]] = (), ) -> hub.Hub: r"""Gets details of a single Hub. @@ -445,8 +479,10 @@ async def sample_get_hub(): 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.networkconnectivity_v1alpha1.types.Hub: @@ -512,7 +548,7 @@ async def create_hub( hub_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Hub in a given project and location. @@ -575,8 +611,10 @@ async def sample_create_hub(): 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.api_core.operation_async.AsyncOperation: @@ -655,7 +693,7 @@ async def update_hub( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Hub. @@ -714,8 +752,10 @@ async def sample_update_hub(): 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.api_core.operation_async.AsyncOperation: @@ -791,7 +831,7 @@ async def delete_hub( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Hub. @@ -839,8 +879,10 @@ async def sample_delete_hub(): 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.api_core.operation_async.AsyncOperation: @@ -919,7 +961,7 @@ async def list_spokes( 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.ListSpokesAsyncPager: r"""Lists Spokes in a given project and location. @@ -962,8 +1004,10 @@ async def sample_list_spokes(): 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.networkconnectivity_v1alpha1.services.hub_service.pagers.ListSpokesAsyncPager: @@ -1038,7 +1082,7 @@ async def get_spoke( 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]]] = (), ) -> hub.Spoke: r"""Gets details of a single Spoke. @@ -1080,8 +1124,10 @@ async def sample_get_spoke(): 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.networkconnectivity_v1alpha1.types.Spoke: @@ -1147,7 +1193,7 @@ async def create_spoke( spoke_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Spoke in a given project and location. @@ -1209,8 +1255,10 @@ async def sample_create_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1288,7 +1336,7 @@ async def update_spoke( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Spoke. @@ -1347,8 +1395,10 @@ async def sample_update_spoke(): 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.api_core.operation_async.AsyncOperation: @@ -1425,7 +1475,7 @@ async def delete_spoke( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Spoke. @@ -1473,8 +1523,10 @@ async def sample_delete_spoke(): 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.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/client.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/client.py index 2e316f1a4868..2008b9db8949 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/client.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -671,6 +681,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( @@ -733,6 +747,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.networkconnectivity_v1alpha1.HubServiceClient`.", + extra={ + "serviceName": "google.cloud.networkconnectivity.v1alpha1.HubService", + "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.networkconnectivity.v1alpha1.HubService", + "credentialsType": None, + }, + ) + def list_hubs( self, request: Optional[Union[hub.ListHubsRequest, dict]] = None, @@ -740,7 +777,7 @@ def list_hubs( 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.ListHubsPager: r"""Lists Hubs in a given project and location. @@ -784,8 +821,10 @@ def sample_list_hubs(): 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.networkconnectivity_v1alpha1.services.hub_service.pagers.ListHubsPager: @@ -858,7 +897,7 @@ def get_hub( 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]]] = (), ) -> hub.Hub: r"""Gets details of a single Hub. @@ -903,8 +942,10 @@ def sample_get_hub(): 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.networkconnectivity_v1alpha1.types.Hub: @@ -969,7 +1010,7 @@ def create_hub( hub_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new Hub in a given project and location. @@ -1032,8 +1073,10 @@ def sample_create_hub(): 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.api_core.operation.Operation: @@ -1109,7 +1152,7 @@ def update_hub( 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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Hub. @@ -1168,8 +1211,10 @@ def sample_update_hub(): 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.api_core.operation.Operation: @@ -1242,7 +1287,7 @@ def delete_hub( 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]]] = (), ) -> operation.Operation: r"""Deletes a single Hub. @@ -1290,8 +1335,10 @@ def sample_delete_hub(): 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.api_core.operation.Operation: @@ -1367,7 +1414,7 @@ def list_spokes( 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.ListSpokesPager: r"""Lists Spokes in a given project and location. @@ -1410,8 +1457,10 @@ def sample_list_spokes(): 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.networkconnectivity_v1alpha1.services.hub_service.pagers.ListSpokesPager: @@ -1483,7 +1532,7 @@ def get_spoke( 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]]] = (), ) -> hub.Spoke: r"""Gets details of a single Spoke. @@ -1525,8 +1574,10 @@ def sample_get_spoke(): 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.networkconnectivity_v1alpha1.types.Spoke: @@ -1589,7 +1640,7 @@ def create_spoke( spoke_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new Spoke in a given project and location. @@ -1651,8 +1702,10 @@ def sample_create_spoke(): 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.api_core.operation.Operation: @@ -1727,7 +1780,7 @@ def update_spoke( 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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Spoke. @@ -1786,8 +1839,10 @@ def sample_update_spoke(): 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.api_core.operation.Operation: @@ -1861,7 +1916,7 @@ def delete_spoke( 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]]] = (), ) -> operation.Operation: r"""Deletes a single Spoke. @@ -1909,8 +1964,10 @@ def sample_delete_spoke(): 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.api_core.operation.Operation: diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/pagers.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/pagers.py index d2796a38dc80..d3f075fdc637 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/pagers.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/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 = hub.ListHubsRequest(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 = hub.ListHubsRequest(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 = hub.ListSpokesRequest(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 = hub.ListSpokesRequest(request) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py index fd220d77566c..c5f6b9ccc079 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/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 @@ -21,13 +24,91 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.networkconnectivity_v1alpha1.types import hub from google.cloud.networkconnectivity_v1alpha1.types import hub as gcn_hub from .base import DEFAULT_CLIENT_INFO, HubServiceTransport +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.networkconnectivity.v1alpha1.HubService", + "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.networkconnectivity.v1alpha1.HubService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HubServiceGrpcTransport(HubServiceTransport): """gRPC backend transport for HubService. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def list_hubs(self) -> Callable[[hub.ListHubsRequest], hub.ListHubsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hubs" not in self._stubs: - self._stubs["list_hubs"] = self.grpc_channel.unary_unary( + self._stubs["list_hubs"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/ListHubs", request_serializer=hub.ListHubsRequest.serialize, response_deserializer=hub.ListHubsResponse.deserialize, @@ -295,7 +383,7 @@ def get_hub(self) -> Callable[[hub.GetHubRequest], hub.Hub]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hub" not in self._stubs: - self._stubs["get_hub"] = self.grpc_channel.unary_unary( + self._stubs["get_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/GetHub", request_serializer=hub.GetHubRequest.serialize, response_deserializer=hub.Hub.deserialize, @@ -321,7 +409,7 @@ def create_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hub" not in self._stubs: - self._stubs["create_hub"] = self.grpc_channel.unary_unary( + self._stubs["create_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/CreateHub", request_serializer=gcn_hub.CreateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -347,7 +435,7 @@ def update_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hub" not in self._stubs: - self._stubs["update_hub"] = self.grpc_channel.unary_unary( + self._stubs["update_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/UpdateHub", request_serializer=gcn_hub.UpdateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +459,7 @@ def delete_hub(self) -> Callable[[hub.DeleteHubRequest], operations_pb2.Operatio # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_hub" not in self._stubs: - self._stubs["delete_hub"] = self.grpc_channel.unary_unary( + self._stubs["delete_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/DeleteHub", request_serializer=hub.DeleteHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +483,7 @@ def list_spokes(self) -> Callable[[hub.ListSpokesRequest], hub.ListSpokesRespons # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spokes" not in self._stubs: - self._stubs["list_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/ListSpokes", request_serializer=hub.ListSpokesRequest.serialize, response_deserializer=hub.ListSpokesResponse.deserialize, @@ -419,7 +507,7 @@ def get_spoke(self) -> Callable[[hub.GetSpokeRequest], hub.Spoke]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_spoke" not in self._stubs: - self._stubs["get_spoke"] = self.grpc_channel.unary_unary( + self._stubs["get_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/GetSpoke", request_serializer=hub.GetSpokeRequest.serialize, response_deserializer=hub.Spoke.deserialize, @@ -445,7 +533,7 @@ def create_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_spoke" not in self._stubs: - self._stubs["create_spoke"] = self.grpc_channel.unary_unary( + self._stubs["create_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/CreateSpoke", request_serializer=hub.CreateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -471,7 +559,7 @@ def update_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_spoke" not in self._stubs: - self._stubs["update_spoke"] = self.grpc_channel.unary_unary( + self._stubs["update_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/UpdateSpoke", request_serializer=hub.UpdateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -497,7 +585,7 @@ def delete_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_spoke" not in self._stubs: - self._stubs["delete_spoke"] = self.grpc_channel.unary_unary( + self._stubs["delete_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/DeleteSpoke", request_serializer=hub.DeleteSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -505,7 +593,7 @@ def delete_spoke( return self._stubs["delete_spoke"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py index 599331e7a833..f9b39930ef5c 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/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 @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.networkconnectivity_v1alpha1.types import hub from google.cloud.networkconnectivity_v1alpha1.types import hub as gcn_hub @@ -32,6 +38,82 @@ from .base import DEFAULT_CLIENT_INFO, HubServiceTransport from .grpc import HubServiceGrpcTransport +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.networkconnectivity.v1alpha1.HubService", + "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.networkconnectivity.v1alpha1.HubService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class HubServiceGrpcAsyncIOTransport(HubServiceTransport): """gRPC AsyncIO backend transport for HubService. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def list_hubs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_hubs" not in self._stubs: - self._stubs["list_hubs"] = self.grpc_channel.unary_unary( + self._stubs["list_hubs"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/ListHubs", request_serializer=hub.ListHubsRequest.serialize, response_deserializer=hub.ListHubsResponse.deserialize, @@ -307,7 +392,7 @@ def get_hub(self) -> Callable[[hub.GetHubRequest], Awaitable[hub.Hub]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_hub" not in self._stubs: - self._stubs["get_hub"] = self.grpc_channel.unary_unary( + self._stubs["get_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/GetHub", request_serializer=hub.GetHubRequest.serialize, response_deserializer=hub.Hub.deserialize, @@ -333,7 +418,7 @@ def create_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_hub" not in self._stubs: - self._stubs["create_hub"] = self.grpc_channel.unary_unary( + self._stubs["create_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/CreateHub", request_serializer=gcn_hub.CreateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -359,7 +444,7 @@ def update_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_hub" not in self._stubs: - self._stubs["update_hub"] = self.grpc_channel.unary_unary( + self._stubs["update_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/UpdateHub", request_serializer=gcn_hub.UpdateHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -385,7 +470,7 @@ def delete_hub( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_hub" not in self._stubs: - self._stubs["delete_hub"] = self.grpc_channel.unary_unary( + self._stubs["delete_hub"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/DeleteHub", request_serializer=hub.DeleteHubRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -411,7 +496,7 @@ def list_spokes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spokes" not in self._stubs: - self._stubs["list_spokes"] = self.grpc_channel.unary_unary( + self._stubs["list_spokes"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/ListSpokes", request_serializer=hub.ListSpokesRequest.serialize, response_deserializer=hub.ListSpokesResponse.deserialize, @@ -435,7 +520,7 @@ def get_spoke(self) -> Callable[[hub.GetSpokeRequest], Awaitable[hub.Spoke]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_spoke" not in self._stubs: - self._stubs["get_spoke"] = self.grpc_channel.unary_unary( + self._stubs["get_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/GetSpoke", request_serializer=hub.GetSpokeRequest.serialize, response_deserializer=hub.Spoke.deserialize, @@ -461,7 +546,7 @@ def create_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_spoke" not in self._stubs: - self._stubs["create_spoke"] = self.grpc_channel.unary_unary( + self._stubs["create_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/CreateSpoke", request_serializer=hub.CreateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -487,7 +572,7 @@ def update_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_spoke" not in self._stubs: - self._stubs["update_spoke"] = self.grpc_channel.unary_unary( + self._stubs["update_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/UpdateSpoke", request_serializer=hub.UpdateSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -513,7 +598,7 @@ def delete_spoke( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_spoke" not in self._stubs: - self._stubs["delete_spoke"] = self.grpc_channel.unary_unary( + self._stubs["delete_spoke"] = self._logged_channel.unary_unary( "/google.cloud.networkconnectivity.v1alpha1.HubService/DeleteSpoke", request_serializer=hub.DeleteSpokeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -581,7 +666,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: diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_async.py b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_async.py new file mode 100644 index 000000000000..fede35e005d4 --- /dev/null +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for QueryHubStatus +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-network-connectivity + + +# [START networkconnectivity_v1_generated_HubService_QueryHubStatus_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import networkconnectivity_v1 + + +async def sample_query_hub_status(): + # Create a client + client = networkconnectivity_v1.HubServiceAsyncClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.QueryHubStatusRequest( + name="name_value", + ) + + # Make the request + page_result = client.query_hub_status(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END networkconnectivity_v1_generated_HubService_QueryHubStatus_async] diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py new file mode 100644 index 000000000000..781bc2270911 --- /dev/null +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for QueryHubStatus +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-network-connectivity + + +# [START networkconnectivity_v1_generated_HubService_QueryHubStatus_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import networkconnectivity_v1 + + +def sample_query_hub_status(): + # Create a client + client = networkconnectivity_v1.HubServiceClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.QueryHubStatusRequest( + name="name_value", + ) + + # Make the request + page_result = client.query_hub_status(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END networkconnectivity_v1_generated_HubService_QueryHubStatus_sync] diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_async.py b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_async.py new file mode 100644 index 000000000000..92230f15becb --- /dev/null +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-network-connectivity + + +# [START networkconnectivity_v1_generated_HubService_UpdateGroup_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import networkconnectivity_v1 + + +async def sample_update_group(): + # Create a client + client = networkconnectivity_v1.HubServiceAsyncClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.UpdateGroupRequest( + ) + + # Make the request + operation = client.update_group(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END networkconnectivity_v1_generated_HubService_UpdateGroup_async] diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_sync.py b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_sync.py new file mode 100644 index 000000000000..19b6b6c14b53 --- /dev/null +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/networkconnectivity_v1_generated_hub_service_update_group_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-network-connectivity + + +# [START networkconnectivity_v1_generated_HubService_UpdateGroup_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import networkconnectivity_v1 + + +def sample_update_group(): + # Create a client + client = networkconnectivity_v1.HubServiceClient() + + # Initialize request argument(s) + request = networkconnectivity_v1.UpdateGroupRequest( + ) + + # Make the request + operation = client.update_group(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END networkconnectivity_v1_generated_HubService_UpdateGroup_sync] diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1.json b/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1.json index 16c2a7d96dd2..8d620f5c261f 100644 --- a/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1.json +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-network-connectivity", - "version": "2.5.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.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -570,7 +570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Group", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Group", @@ -1053,7 +1053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Hub", @@ -1133,7 +1133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Hub", @@ -1214,7 +1214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.RouteTable", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.RouteTable", @@ -1375,7 +1375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Route", @@ -1455,7 +1455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Route", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Spoke", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.Spoke", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListGroupsAsyncPager", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListGroupsPager", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListHubSpokesAsyncPager", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListHubSpokesPager", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListHubsAsyncPager", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListHubsPager", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListRouteTablesAsyncPager", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListRouteTablesPager", @@ -2341,7 +2341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListRoutesAsyncPager", @@ -2421,7 +2421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListRoutesPager", @@ -2502,7 +2502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListSpokesAsyncPager", @@ -2582,7 +2582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.ListSpokesPager", @@ -2627,6 +2627,167 @@ ], "title": "networkconnectivity_v1_generated_hub_service_list_spokes_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.networkconnectivity_v1.HubServiceAsyncClient", + "shortName": "HubServiceAsyncClient" + }, + "fullName": "google.cloud.networkconnectivity_v1.HubServiceAsyncClient.query_hub_status", + "method": { + "fullName": "google.cloud.networkconnectivity.v1.HubService.QueryHubStatus", + "service": { + "fullName": "google.cloud.networkconnectivity.v1.HubService", + "shortName": "HubService" + }, + "shortName": "QueryHubStatus" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.QueryHubStatusAsyncPager", + "shortName": "query_hub_status" + }, + "description": "Sample for QueryHubStatus", + "file": "networkconnectivity_v1_generated_hub_service_query_hub_status_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "networkconnectivity_v1_generated_HubService_QueryHubStatus_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "networkconnectivity_v1_generated_hub_service_query_hub_status_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.networkconnectivity_v1.HubServiceClient", + "shortName": "HubServiceClient" + }, + "fullName": "google.cloud.networkconnectivity_v1.HubServiceClient.query_hub_status", + "method": { + "fullName": "google.cloud.networkconnectivity.v1.HubService.QueryHubStatus", + "service": { + "fullName": "google.cloud.networkconnectivity.v1.HubService", + "shortName": "HubService" + }, + "shortName": "QueryHubStatus" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.networkconnectivity_v1.types.QueryHubStatusRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.networkconnectivity_v1.services.hub_service.pagers.QueryHubStatusPager", + "shortName": "query_hub_status" + }, + "description": "Sample for QueryHubStatus", + "file": "networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "networkconnectivity_v1_generated_HubService_QueryHubStatus_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "networkconnectivity_v1_generated_hub_service_query_hub_status_sync.py" + }, { "canonical": true, "clientMethod": { @@ -2667,7 +2828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2751,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2796,6 +2957,175 @@ ], "title": "networkconnectivity_v1_generated_hub_service_reject_hub_spoke_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.networkconnectivity_v1.HubServiceAsyncClient", + "shortName": "HubServiceAsyncClient" + }, + "fullName": "google.cloud.networkconnectivity_v1.HubServiceAsyncClient.update_group", + "method": { + "fullName": "google.cloud.networkconnectivity.v1.HubService.UpdateGroup", + "service": { + "fullName": "google.cloud.networkconnectivity.v1.HubService", + "shortName": "HubService" + }, + "shortName": "UpdateGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.networkconnectivity_v1.types.UpdateGroupRequest" + }, + { + "name": "group", + "type": "google.cloud.networkconnectivity_v1.types.Group" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_group" + }, + "description": "Sample for UpdateGroup", + "file": "networkconnectivity_v1_generated_hub_service_update_group_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "networkconnectivity_v1_generated_HubService_UpdateGroup_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "networkconnectivity_v1_generated_hub_service_update_group_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.networkconnectivity_v1.HubServiceClient", + "shortName": "HubServiceClient" + }, + "fullName": "google.cloud.networkconnectivity_v1.HubServiceClient.update_group", + "method": { + "fullName": "google.cloud.networkconnectivity.v1.HubService.UpdateGroup", + "service": { + "fullName": "google.cloud.networkconnectivity.v1.HubService", + "shortName": "HubService" + }, + "shortName": "UpdateGroup" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.networkconnectivity_v1.types.UpdateGroupRequest" + }, + { + "name": "group", + "type": "google.cloud.networkconnectivity_v1.types.Group" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_group" + }, + "description": "Sample for UpdateGroup", + "file": "networkconnectivity_v1_generated_hub_service_update_group_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "networkconnectivity_v1_generated_HubService_UpdateGroup_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "networkconnectivity_v1_generated_hub_service_update_group_sync.py" + }, { "canonical": true, "clientMethod": { @@ -2836,7 +3166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2920,7 +3250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3005,7 +3335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3089,7 +3419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3178,7 +3508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3266,7 +3596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3347,7 +3677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3427,7 +3757,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3508,7 +3838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.PolicyBasedRoute", @@ -3588,7 +3918,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.types.PolicyBasedRoute", @@ -3669,7 +3999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.policy_based_routing_service.pagers.ListPolicyBasedRoutesAsyncPager", @@ -3749,7 +4079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1.services.policy_based_routing_service.pagers.ListPolicyBasedRoutesPager", diff --git a/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json b/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json index 835f1f3024a7..780180f11887 100644 --- a/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json +++ b/packages/google-cloud-network-connectivity/samples/generated_samples/snippet_metadata_google.cloud.networkconnectivity.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-network-connectivity", - "version": "2.5.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.types.Hub", @@ -803,7 +803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.types.Hub", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.types.Spoke", @@ -964,7 +964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.types.Spoke", @@ -1045,7 +1045,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.services.hub_service.pagers.ListHubsAsyncPager", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.services.hub_service.pagers.ListHubsPager", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.services.hub_service.pagers.ListSpokesAsyncPager", @@ -1286,7 +1286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.networkconnectivity_v1alpha1.services.hub_service.pagers.ListSpokesPager", @@ -1371,7 +1371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1455,7 +1455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1540,7 +1540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-network-connectivity/scripts/fixup_networkconnectivity_v1_keywords.py b/packages/google-cloud-network-connectivity/scripts/fixup_networkconnectivity_v1_keywords.py index 3058b926320f..ea5d22a79d50 100644 --- a/packages/google-cloud-network-connectivity/scripts/fixup_networkconnectivity_v1_keywords.py +++ b/packages/google-cloud-network-connectivity/scripts/fixup_networkconnectivity_v1_keywords.py @@ -59,7 +59,9 @@ class networkconnectivityCallTransformer(cst.CSTTransformer): 'list_routes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), 'list_route_tables': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), 'list_spokes': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'query_hub_status': ('name', 'page_size', 'page_token', 'filter', 'order_by', 'group_by', ), 'reject_hub_spoke': ('name', 'spoke_uri', 'request_id', 'details', ), + 'update_group': ('group', 'update_mask', 'request_id', ), 'update_hub': ('hub', 'update_mask', 'request_id', ), 'update_spoke': ('spoke', 'update_mask', 'request_id', ), } diff --git a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py index 05be2931ae4e..7f31660a9d03 100644 --- a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py +++ b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py @@ -1567,6 +1567,9 @@ def test_get_hub(request_type, transport: str = "grpc"): unique_id="unique_id_value", state=hub.State.CREATING, route_tables=["route_tables_value"], + policy_mode=hub.PolicyMode.PRESET, + preset_topology=hub.PresetTopology.MESH, + export_psc=True, ) response = client.get_hub(request) @@ -1583,6 +1586,9 @@ def test_get_hub(request_type, transport: str = "grpc"): assert response.unique_id == "unique_id_value" assert response.state == hub.State.CREATING assert response.route_tables == ["route_tables_value"] + assert response.policy_mode == hub.PolicyMode.PRESET + assert response.preset_topology == hub.PresetTopology.MESH + assert response.export_psc is True def test_get_hub_non_empty_request_with_auto_populated_field(): @@ -1711,6 +1717,9 @@ async def test_get_hub_async( unique_id="unique_id_value", state=hub.State.CREATING, route_tables=["route_tables_value"], + policy_mode=hub.PolicyMode.PRESET, + preset_topology=hub.PresetTopology.MESH, + export_psc=True, ) ) response = await client.get_hub(request) @@ -1728,6 +1737,9 @@ async def test_get_hub_async( assert response.unique_id == "unique_id_value" assert response.state == hub.State.CREATING assert response.route_tables == ["route_tables_value"] + assert response.policy_mode == hub.PolicyMode.PRESET + assert response.preset_topology == hub.PresetTopology.MESH + assert response.export_psc is True @pytest.mark.asyncio @@ -3415,11 +3427,11 @@ async def test_list_hub_spokes_async_pages(): @pytest.mark.parametrize( "request_type", [ - hub.ListSpokesRequest, + hub.QueryHubStatusRequest, dict, ], ) -def test_list_spokes(request_type, transport: str = "grpc"): +def test_query_hub_status(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3430,27 +3442,25 @@ def test_list_spokes(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListSpokesResponse( + call.return_value = hub.QueryHubStatusResponse( next_page_token="next_page_token_value", - unreachable=["unreachable_value"], ) - response = client.list_spokes(request) + response = client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.ListSpokesRequest() + request = hub.QueryHubStatusRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSpokesPager) + assert isinstance(response, pagers.QueryHubStatusPager) assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] -def test_list_spokes_non_empty_request_with_auto_populated_field(): +def test_query_hub_status_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -3461,30 +3471,32 @@ def test_list_spokes_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.ListSpokesRequest( - parent="parent_value", + request = hub.QueryHubStatusRequest( + name="name_value", page_token="page_token_value", filter="filter_value", order_by="order_by_value", + group_by="group_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_spokes(request=request) + client.query_hub_status(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.ListSpokesRequest( - parent="parent_value", + assert args[0] == hub.QueryHubStatusRequest( + name="name_value", page_token="page_token_value", filter="filter_value", order_by="order_by_value", + group_by="group_by_value", ) -def test_list_spokes_use_cached_wrapped_rpc(): +def test_query_hub_status_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -3498,21 +3510,23 @@ def test_list_spokes_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_spokes in client._transport._wrapped_methods + assert client._transport.query_hub_status in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_spokes] = mock_rpc + client._transport._wrapped_methods[ + client._transport.query_hub_status + ] = mock_rpc request = {} - client.list_spokes(request) + client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_spokes(request) + client.query_hub_status(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -3520,7 +3534,7 @@ def test_list_spokes_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_spokes_async_use_cached_wrapped_rpc( +async def test_query_hub_status_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -3537,7 +3551,7 @@ async def test_list_spokes_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.list_spokes + client._client._transport.query_hub_status in client._client._transport._wrapped_methods ) @@ -3545,16 +3559,16 @@ async def test_list_spokes_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_spokes + client._client._transport.query_hub_status ] = mock_rpc request = {} - await client.list_spokes(request) + await client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_spokes(request) + await client.query_hub_status(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -3562,8 +3576,8 @@ async def test_list_spokes_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_spokes_async( - transport: str = "grpc_asyncio", request_type=hub.ListSpokesRequest +async def test_query_hub_status_async( + transport: str = "grpc_asyncio", request_type=hub.QueryHubStatusRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -3575,48 +3589,46 @@ async def test_list_spokes_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListSpokesResponse( + hub.QueryHubStatusResponse( next_page_token="next_page_token_value", - unreachable=["unreachable_value"], ) ) - response = await client.list_spokes(request) + response = await client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.ListSpokesRequest() + request = hub.QueryHubStatusRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSpokesAsyncPager) + assert isinstance(response, pagers.QueryHubStatusAsyncPager) assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio -async def test_list_spokes_async_from_dict(): - await test_list_spokes_async(request_type=dict) +async def test_query_hub_status_async_from_dict(): + await test_query_hub_status_async(request_type=dict) -def test_list_spokes_field_headers(): +def test_query_hub_status_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListSpokesRequest() + request = hub.QueryHubStatusRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: - call.return_value = hub.ListSpokesResponse() - client.list_spokes(request) + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: + call.return_value = hub.QueryHubStatusResponse() + client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -3627,28 +3639,28 @@ def test_list_spokes_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_spokes_field_headers_async(): +async def test_query_hub_status_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListSpokesRequest() + request = hub.QueryHubStatusRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListSpokesResponse() + hub.QueryHubStatusResponse() ) - await client.list_spokes(request) + await client.query_hub_status(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3659,35 +3671,35 @@ async def test_list_spokes_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_list_spokes_flattened(): +def test_query_hub_status_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListSpokesResponse() + call.return_value = hub.QueryHubStatusResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_spokes( - parent="parent_value", + client.query_hub_status( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_list_spokes_flattened_error(): +def test_query_hub_status_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3695,43 +3707,43 @@ def test_list_spokes_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_spokes( - hub.ListSpokesRequest(), - parent="parent_value", + client.query_hub_status( + hub.QueryHubStatusRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_list_spokes_flattened_async(): +async def test_query_hub_status_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListSpokesResponse() + call.return_value = hub.QueryHubStatusResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListSpokesResponse() + hub.QueryHubStatusResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_spokes( - parent="parent_value", + response = await client.query_hub_status( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_list_spokes_flattened_error_async(): +async def test_query_hub_status_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -3739,44 +3751,44 @@ async def test_list_spokes_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_spokes( - hub.ListSpokesRequest(), - parent="parent_value", + await client.query_hub_status( + hub.QueryHubStatusRequest(), + name="name_value", ) -def test_list_spokes_pager(transport_name: str = "grpc"): +def test_query_hub_status_pager(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], next_page_token="abc", ), - hub.ListSpokesResponse( - spokes=[], + hub.QueryHubStatusResponse( + hub_status_entries=[], next_page_token="def", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), ], next_page_token="ghi", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], ), RuntimeError, @@ -3786,9 +3798,9 @@ def test_list_spokes_pager(transport_name: str = "grpc"): retry = retries.Retry() timeout = 5 expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + gapic_v1.routing_header.to_grpc_metadata((("name", ""),)), ) - pager = client.list_spokes(request={}, retry=retry, timeout=timeout) + pager = client.query_hub_status(request={}, retry=retry, timeout=timeout) assert pager._metadata == expected_metadata assert pager._retry == retry @@ -3796,89 +3808,89 @@ def test_list_spokes_pager(transport_name: str = "grpc"): results = list(pager) assert len(results) == 6 - assert all(isinstance(i, hub.Spoke) for i in results) + assert all(isinstance(i, hub.HubStatusEntry) for i in results) -def test_list_spokes_pages(transport_name: str = "grpc"): +def test_query_hub_status_pages(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], next_page_token="abc", ), - hub.ListSpokesResponse( - spokes=[], + hub.QueryHubStatusResponse( + hub_status_entries=[], next_page_token="def", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), ], next_page_token="ghi", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], ), RuntimeError, ) - pages = list(client.list_spokes(request={}).pages) + pages = list(client.query_hub_status(request={}).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_list_spokes_async_pager(): +async def test_query_hub_status_async_pager(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_spokes), "__call__", new_callable=mock.AsyncMock + type(client.transport.query_hub_status), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], next_page_token="abc", ), - hub.ListSpokesResponse( - spokes=[], + hub.QueryHubStatusResponse( + hub_status_entries=[], next_page_token="def", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), ], next_page_token="ghi", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], ), RuntimeError, ) - async_pager = await client.list_spokes( + async_pager = await client.query_hub_status( request={}, ) assert async_pager.next_page_token == "abc" @@ -3887,43 +3899,43 @@ async def test_list_spokes_async_pager(): responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, hub.Spoke) for i in responses) + assert all(isinstance(i, hub.HubStatusEntry) for i in responses) @pytest.mark.asyncio -async def test_list_spokes_async_pages(): +async def test_query_hub_status_async_pages(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_spokes), "__call__", new_callable=mock.AsyncMock + type(client.transport.query_hub_status), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], next_page_token="abc", ), - hub.ListSpokesResponse( - spokes=[], + hub.QueryHubStatusResponse( + hub_status_entries=[], next_page_token="def", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), ], next_page_token="ghi", ), - hub.ListSpokesResponse( - spokes=[ - hub.Spoke(), - hub.Spoke(), + hub.QueryHubStatusResponse( + hub_status_entries=[ + hub.HubStatusEntry(), + hub.HubStatusEntry(), ], ), RuntimeError, @@ -3932,7 +3944,7 @@ async def test_list_spokes_async_pages(): # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 async for page_ in ( # pragma: no branch - await client.list_spokes(request={}) + await client.query_hub_status(request={}) ).pages: pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): @@ -3942,11 +3954,11 @@ async def test_list_spokes_async_pages(): @pytest.mark.parametrize( "request_type", [ - hub.GetSpokeRequest, + hub.ListSpokesRequest, dict, ], ) -def test_get_spoke(request_type, transport: str = "grpc"): +def test_list_spokes(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3957,37 +3969,27 @@ def test_get_spoke(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Spoke( - name="name_value", - description="description_value", - hub="hub_value", - group="group_value", - unique_id="unique_id_value", - state=hub.State.CREATING, - spoke_type=hub.SpokeType.VPN_TUNNEL, + call.return_value = hub.ListSpokesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) - response = client.get_spoke(request) + response = client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.GetSpokeRequest() + request = hub.ListSpokesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Spoke) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.hub == "hub_value" - assert response.group == "group_value" - assert response.unique_id == "unique_id_value" - assert response.state == hub.State.CREATING - assert response.spoke_type == hub.SpokeType.VPN_TUNNEL + assert isinstance(response, pagers.ListSpokesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] -def test_get_spoke_non_empty_request_with_auto_populated_field(): +def test_list_spokes_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -3998,24 +4000,30 @@ def test_get_spoke_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.GetSpokeRequest( - name="name_value", + request = hub.ListSpokesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_spoke(request=request) + client.list_spokes(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.GetSpokeRequest( - name="name_value", + assert args[0] == hub.ListSpokesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) -def test_get_spoke_use_cached_wrapped_rpc(): +def test_list_spokes_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -4029,21 +4037,21 @@ def test_get_spoke_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_spoke in client._transport._wrapped_methods + assert client._transport.list_spokes in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_spoke] = mock_rpc + client._transport._wrapped_methods[client._transport.list_spokes] = mock_rpc request = {} - client.get_spoke(request) + client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_spoke(request) + client.list_spokes(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4051,7 +4059,9 @@ def test_get_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_list_spokes_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -4066,7 +4076,7 @@ async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asy # Ensure method has been cached assert ( - client._client._transport.get_spoke + client._client._transport.list_spokes in client._client._transport._wrapped_methods ) @@ -4074,16 +4084,16 @@ async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asy mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_spoke + client._client._transport.list_spokes ] = mock_rpc request = {} - await client.get_spoke(request) + await client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_spoke(request) + await client.list_spokes(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4091,8 +4101,8 @@ async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asy @pytest.mark.asyncio -async def test_get_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.GetSpokeRequest +async def test_list_spokes_async( + transport: str = "grpc_asyncio", request_type=hub.ListSpokesRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -4104,58 +4114,48 @@ async def test_get_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.Spoke( - name="name_value", - description="description_value", - hub="hub_value", - group="group_value", - unique_id="unique_id_value", - state=hub.State.CREATING, - spoke_type=hub.SpokeType.VPN_TUNNEL, + hub.ListSpokesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) ) - response = await client.get_spoke(request) + response = await client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.GetSpokeRequest() + request = hub.ListSpokesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Spoke) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.hub == "hub_value" - assert response.group == "group_value" - assert response.unique_id == "unique_id_value" - assert response.state == hub.State.CREATING - assert response.spoke_type == hub.SpokeType.VPN_TUNNEL + assert isinstance(response, pagers.ListSpokesAsyncPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio -async def test_get_spoke_async_from_dict(): - await test_get_spoke_async(request_type=dict) +async def test_list_spokes_async_from_dict(): + await test_list_spokes_async(request_type=dict) -def test_get_spoke_field_headers(): +def test_list_spokes_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetSpokeRequest() + request = hub.ListSpokesRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: - call.return_value = hub.Spoke() - client.get_spoke(request) + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + call.return_value = hub.ListSpokesResponse() + client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4166,26 +4166,28 @@ def test_get_spoke_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_spoke_field_headers_async(): +async def test_list_spokes_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetSpokeRequest() + request = hub.ListSpokesRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Spoke()) - await client.get_spoke(request) + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListSpokesResponse() + ) + await client.list_spokes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4196,35 +4198,35 @@ async def test_get_spoke_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_spoke_flattened(): +def test_list_spokes_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Spoke() + call.return_value = hub.ListSpokesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_spoke( - name="name_value", + client.list_spokes( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_get_spoke_flattened_error(): +def test_list_spokes_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4232,41 +4234,43 @@ def test_get_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_spoke( - hub.GetSpokeRequest(), - name="name_value", + client.list_spokes( + hub.ListSpokesRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_spoke_flattened_async(): +async def test_list_spokes_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Spoke() + call.return_value = hub.ListSpokesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Spoke()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListSpokesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_spoke( - name="name_value", + response = await client.list_spokes( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val @pytest.mark.asyncio -async def test_get_spoke_flattened_error_async(): +async def test_list_spokes_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -4274,111 +4278,993 @@ async def test_get_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_spoke( - hub.GetSpokeRequest(), - name="name_value", + await client.list_spokes( + hub.ListSpokesRequest(), + parent="parent_value", ) -@pytest.mark.parametrize( - "request_type", - [ - hub.CreateSpokeRequest, - dict, - ], -) -def test_create_spoke(request_type, transport: str = "grpc"): +def test_list_spokes_pager(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport=transport_name, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_spoke(request) + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + hub.Spoke(), + ], + next_page_token="abc", + ), + hub.ListSpokesResponse( + spokes=[], + next_page_token="def", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + ], + next_page_token="ghi", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + ], + ), + RuntimeError, + ) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = hub.CreateSpokeRequest() - assert args[0] == request + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_spokes(request={}, retry=retry, timeout=timeout) - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, hub.Spoke) for i in results) -def test_create_spoke_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. +def test_list_spokes_pages(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = hub.CreateSpokeRequest( - parent="parent_value", - spoke_id="spoke_id_value", - request_id="request_id_value", + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: - call.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client.create_spoke(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == hub.CreateSpokeRequest( - parent="parent_value", - spoke_id="spoke_id_value", - request_id="request_id_value", - ) - - -def test_create_spoke_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + with mock.patch.object(type(client.transport.list_spokes), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + hub.Spoke(), + ], + next_page_token="abc", + ), + hub.ListSpokesResponse( + spokes=[], + next_page_token="def", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + ], + next_page_token="ghi", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + ], + ), + RuntimeError, ) + pages = list(client.list_spokes(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_spoke in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.create_spoke] = mock_rpc - request = {} - client.create_spoke(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 +@pytest.mark.asyncio +async def test_list_spokes_async_pager(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_spokes), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + hub.Spoke(), + ], + next_page_token="abc", + ), + hub.ListSpokesResponse( + spokes=[], + next_page_token="def", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + ], + next_page_token="ghi", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_spokes( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, hub.Spoke) for i in responses) + + +@pytest.mark.asyncio +async def test_list_spokes_async_pages(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_spokes), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + hub.Spoke(), + ], + next_page_token="abc", + ), + hub.ListSpokesResponse( + spokes=[], + next_page_token="def", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + ], + next_page_token="ghi", + ), + hub.ListSpokesResponse( + spokes=[ + hub.Spoke(), + hub.Spoke(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_spokes(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + hub.GetSpokeRequest, + dict, + ], +) +def test_get_spoke(request_type, transport: str = "grpc"): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.Spoke( + name="name_value", + description="description_value", + hub="hub_value", + group="group_value", + unique_id="unique_id_value", + state=hub.State.CREATING, + spoke_type=hub.SpokeType.VPN_TUNNEL, + ) + response = client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = hub.GetSpokeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, hub.Spoke) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.hub == "hub_value" + assert response.group == "group_value" + assert response.unique_id == "unique_id_value" + assert response.state == hub.State.CREATING + assert response.spoke_type == hub.SpokeType.VPN_TUNNEL + + +def test_get_spoke_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = hub.GetSpokeRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_spoke(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == hub.GetSpokeRequest( + name="name_value", + ) + + +def test_get_spoke_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_spoke in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_spoke] = mock_rpc + request = {} + client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_spoke(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_spoke + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_spoke + ] = mock_rpc + + request = {} + await client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_spoke(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.GetSpokeRequest +): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.Spoke( + name="name_value", + description="description_value", + hub="hub_value", + group="group_value", + unique_id="unique_id_value", + state=hub.State.CREATING, + spoke_type=hub.SpokeType.VPN_TUNNEL, + ) + ) + response = await client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = hub.GetSpokeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, hub.Spoke) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.hub == "hub_value" + assert response.group == "group_value" + assert response.unique_id == "unique_id_value" + assert response.state == hub.State.CREATING + assert response.spoke_type == hub.SpokeType.VPN_TUNNEL + + +@pytest.mark.asyncio +async def test_get_spoke_async_from_dict(): + await test_get_spoke_async(request_type=dict) + + +def test_get_spoke_field_headers(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = hub.GetSpokeRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + call.return_value = hub.Spoke() + client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_spoke_field_headers_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = hub.GetSpokeRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Spoke()) + await client.get_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_spoke_flattened(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.Spoke() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_spoke( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_spoke_flattened_error(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_spoke( + hub.GetSpokeRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_spoke_flattened_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.Spoke() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Spoke()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_spoke( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_spoke_flattened_error_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_spoke( + hub.GetSpokeRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + hub.CreateSpokeRequest, + dict, + ], +) +def test_create_spoke(request_type, transport: str = "grpc"): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = hub.CreateSpokeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_spoke_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = hub.CreateSpokeRequest( + parent="parent_value", + spoke_id="spoke_id_value", + request_id="request_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_spoke(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == hub.CreateSpokeRequest( + parent="parent_value", + spoke_id="spoke_id_value", + request_id="request_id_value", + ) + + +def test_create_spoke_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_spoke in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_spoke] = mock_rpc + request = {} + client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_spoke(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_spoke_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_spoke + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_spoke + ] = mock_rpc + + request = {} + await client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_spoke(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.CreateSpokeRequest +): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = hub.CreateSpokeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_spoke_async_from_dict(): + await test_create_spoke_async(request_type=dict) + + +def test_create_spoke_field_headers(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = hub.CreateSpokeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_spoke_field_headers_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = hub.CreateSpokeRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_spoke_flattened(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_spoke( + parent="parent_value", + spoke=hub.Spoke(name="name_value"), + spoke_id="spoke_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].spoke + mock_val = hub.Spoke(name="name_value") + assert arg == mock_val + arg = args[0].spoke_id + mock_val = "spoke_id_value" + assert arg == mock_val + + +def test_create_spoke_flattened_error(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_spoke( + hub.CreateSpokeRequest(), + parent="parent_value", + spoke=hub.Spoke(name="name_value"), + spoke_id="spoke_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_spoke_flattened_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_spoke( + parent="parent_value", + spoke=hub.Spoke(name="name_value"), + spoke_id="spoke_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].spoke + mock_val = hub.Spoke(name="name_value") + assert arg == mock_val + arg = args[0].spoke_id + mock_val = "spoke_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_spoke_flattened_error_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_spoke( + hub.CreateSpokeRequest(), + parent="parent_value", + spoke=hub.Spoke(name="name_value"), + spoke_id="spoke_id_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + hub.UpdateSpokeRequest, + dict, + ], +) +def test_update_spoke(request_type, transport: str = "grpc"): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - client.create_spoke(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = hub.UpdateSpokeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_spoke_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = hub.UpdateSpokeRequest( + request_id="request_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_spoke(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == hub.UpdateSpokeRequest( + request_id="request_id_value", + ) + + +def test_update_spoke_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_spoke in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_spoke] = mock_rpc + request = {} + client.update_spoke(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4386,7 +5272,7 @@ def test_create_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_create_spoke_async_use_cached_wrapped_rpc( +async def test_update_spoke_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -4403,7 +5289,7 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.create_spoke + client._client._transport.update_spoke in client._client._transport._wrapped_methods ) @@ -4411,11 +5297,11 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.create_spoke + client._client._transport.update_spoke ] = mock_rpc request = {} - await client.create_spoke(request) + await client.update_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -4425,7 +5311,7 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.create_spoke(request) + await client.update_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4433,8 +5319,8 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.CreateSpokeRequest +async def test_update_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.UpdateSpokeRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -4446,17 +5332,17 @@ async def test_create_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_spoke(request) + response = await client.update_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.CreateSpokeRequest() + request = hub.UpdateSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4464,25 +5350,25 @@ async def test_create_spoke_async( @pytest.mark.asyncio -async def test_create_spoke_async_from_dict(): - await test_create_spoke_async(request_type=dict) +async def test_update_spoke_async_from_dict(): + await test_update_spoke_async(request_type=dict) -def test_create_spoke_field_headers(): +def test_update_spoke_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.CreateSpokeRequest() + request = hub.UpdateSpokeRequest() - request.parent = "parent_value" + request.spoke.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_spoke(request) + client.update_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4493,28 +5379,28 @@ def test_create_spoke_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "spoke.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_create_spoke_field_headers_async(): +async def test_update_spoke_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.CreateSpokeRequest() + request = hub.UpdateSpokeRequest() - request.parent = "parent_value" + request.spoke.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_spoke(request) + await client.update_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4525,43 +5411,39 @@ async def test_create_spoke_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "spoke.name=name_value", ) in kw["metadata"] -def test_create_spoke_flattened(): +def test_update_spoke_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_spoke( - parent="parent_value", + client.update_spoke( spoke=hub.Spoke(name="name_value"), - spoke_id="spoke_id_value", + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val arg = args[0].spoke mock_val = hub.Spoke(name="name_value") assert arg == mock_val - arg = args[0].spoke_id - mock_val = "spoke_id_value" + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_create_spoke_flattened_error(): +def test_update_spoke_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4569,22 +5451,21 @@ def test_create_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_spoke( - hub.CreateSpokeRequest(), - parent="parent_value", + client.update_spoke( + hub.UpdateSpokeRequest(), spoke=hub.Spoke(name="name_value"), - spoke_id="spoke_id_value", + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_create_spoke_flattened_async(): +async def test_update_spoke_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -4593,29 +5474,25 @@ async def test_create_spoke_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_spoke( - parent="parent_value", + response = await client.update_spoke( spoke=hub.Spoke(name="name_value"), - spoke_id="spoke_id_value", + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val arg = args[0].spoke mock_val = hub.Spoke(name="name_value") assert arg == mock_val - arg = args[0].spoke_id - mock_val = "spoke_id_value" + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val @pytest.mark.asyncio -async def test_create_spoke_flattened_error_async(): +async def test_update_spoke_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -4623,22 +5500,21 @@ async def test_create_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_spoke( - hub.CreateSpokeRequest(), - parent="parent_value", + await client.update_spoke( + hub.UpdateSpokeRequest(), spoke=hub.Spoke(name="name_value"), - spoke_id="spoke_id_value", + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - hub.UpdateSpokeRequest, + hub.RejectHubSpokeRequest, dict, ], ) -def test_update_spoke(request_type, transport: str = "grpc"): +def test_reject_hub_spoke(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4649,22 +5525,22 @@ def test_update_spoke(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_spoke(request) + response = client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.UpdateSpokeRequest() + request = hub.RejectHubSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, future.Future) -def test_update_spoke_non_empty_request_with_auto_populated_field(): +def test_reject_hub_spoke_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -4675,24 +5551,30 @@ def test_update_spoke_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.UpdateSpokeRequest( + request = hub.RejectHubSpokeRequest( + name="name_value", + spoke_uri="spoke_uri_value", request_id="request_id_value", + details="details_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_spoke(request=request) + client.reject_hub_spoke(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.UpdateSpokeRequest( + assert args[0] == hub.RejectHubSpokeRequest( + name="name_value", + spoke_uri="spoke_uri_value", request_id="request_id_value", + details="details_value", ) -def test_update_spoke_use_cached_wrapped_rpc(): +def test_reject_hub_spoke_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -4706,16 +5588,18 @@ def test_update_spoke_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.update_spoke in client._transport._wrapped_methods + assert client._transport.reject_hub_spoke in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_spoke] = mock_rpc + client._transport._wrapped_methods[ + client._transport.reject_hub_spoke + ] = mock_rpc request = {} - client.update_spoke(request) + client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -4725,7 +5609,7 @@ def test_update_spoke_use_cached_wrapped_rpc(): # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_spoke(request) + client.reject_hub_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4733,7 +5617,7 @@ def test_update_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_spoke_async_use_cached_wrapped_rpc( +async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -4750,7 +5634,7 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.update_spoke + client._client._transport.reject_hub_spoke in client._client._transport._wrapped_methods ) @@ -4758,11 +5642,11 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_spoke + client._client._transport.reject_hub_spoke ] = mock_rpc request = {} - await client.update_spoke(request) + await client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -4772,7 +5656,7 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.update_spoke(request) + await client.reject_hub_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4780,8 +5664,8 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.UpdateSpokeRequest +async def test_reject_hub_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.RejectHubSpokeRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -4793,17 +5677,17 @@ async def test_update_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_spoke(request) + response = await client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.UpdateSpokeRequest() + request = hub.RejectHubSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4811,25 +5695,25 @@ async def test_update_spoke_async( @pytest.mark.asyncio -async def test_update_spoke_async_from_dict(): - await test_update_spoke_async(request_type=dict) +async def test_reject_hub_spoke_async_from_dict(): + await test_reject_hub_spoke_async(request_type=dict) -def test_update_spoke_field_headers(): +def test_reject_hub_spoke_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.UpdateSpokeRequest() + request = hub.RejectHubSpokeRequest() - request.spoke.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_spoke(request) + client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4840,28 +5724,28 @@ def test_update_spoke_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "spoke.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_spoke_field_headers_async(): +async def test_reject_hub_spoke_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.UpdateSpokeRequest() + request = hub.RejectHubSpokeRequest() - request.spoke.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_spoke(request) + await client.reject_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4872,39 +5756,39 @@ async def test_update_spoke_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "spoke.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_update_spoke_flattened(): +def test_reject_hub_spoke_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_spoke( - spoke=hub.Spoke(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.reject_hub_spoke( + name="name_value", + spoke_uri="spoke_uri_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].spoke - mock_val = hub.Spoke(name="name_value") + arg = args[0].name + mock_val = "name_value" assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].spoke_uri + mock_val = "spoke_uri_value" assert arg == mock_val -def test_update_spoke_flattened_error(): +def test_reject_hub_spoke_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4912,21 +5796,21 @@ def test_update_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_spoke( - hub.UpdateSpokeRequest(), - spoke=hub.Spoke(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.reject_hub_spoke( + hub.RejectHubSpokeRequest(), + name="name_value", + spoke_uri="spoke_uri_value", ) @pytest.mark.asyncio -async def test_update_spoke_flattened_async(): +async def test_reject_hub_spoke_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -4935,25 +5819,25 @@ async def test_update_spoke_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_spoke( - spoke=hub.Spoke(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.reject_hub_spoke( + name="name_value", + spoke_uri="spoke_uri_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].spoke - mock_val = hub.Spoke(name="name_value") + arg = args[0].name + mock_val = "name_value" assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].spoke_uri + mock_val = "spoke_uri_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_spoke_flattened_error_async(): +async def test_reject_hub_spoke_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -4961,21 +5845,21 @@ async def test_update_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.update_spoke( - hub.UpdateSpokeRequest(), - spoke=hub.Spoke(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.reject_hub_spoke( + hub.RejectHubSpokeRequest(), + name="name_value", + spoke_uri="spoke_uri_value", ) @pytest.mark.parametrize( "request_type", [ - hub.RejectHubSpokeRequest, + hub.AcceptHubSpokeRequest, dict, ], ) -def test_reject_hub_spoke(request_type, transport: str = "grpc"): +def test_accept_hub_spoke(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4986,22 +5870,22 @@ def test_reject_hub_spoke(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.reject_hub_spoke(request) + response = client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.RejectHubSpokeRequest() + request = hub.AcceptHubSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, future.Future) -def test_reject_hub_spoke_non_empty_request_with_auto_populated_field(): +def test_accept_hub_spoke_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -5012,30 +5896,28 @@ def test_reject_hub_spoke_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.RejectHubSpokeRequest( + request = hub.AcceptHubSpokeRequest( name="name_value", spoke_uri="spoke_uri_value", request_id="request_id_value", - details="details_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.reject_hub_spoke(request=request) + client.accept_hub_spoke(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.RejectHubSpokeRequest( + assert args[0] == hub.AcceptHubSpokeRequest( name="name_value", spoke_uri="spoke_uri_value", request_id="request_id_value", - details="details_value", ) -def test_reject_hub_spoke_use_cached_wrapped_rpc(): +def test_accept_hub_spoke_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5049,7 +5931,7 @@ def test_reject_hub_spoke_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.reject_hub_spoke in client._transport._wrapped_methods + assert client._transport.accept_hub_spoke in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -5057,10 +5939,10 @@ def test_reject_hub_spoke_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.reject_hub_spoke + client._transport.accept_hub_spoke ] = mock_rpc request = {} - client.reject_hub_spoke(request) + client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5070,7 +5952,7 @@ def test_reject_hub_spoke_use_cached_wrapped_rpc(): # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.reject_hub_spoke(request) + client.accept_hub_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5078,7 +5960,7 @@ def test_reject_hub_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( +async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -5095,7 +5977,7 @@ async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.reject_hub_spoke + client._client._transport.accept_hub_spoke in client._client._transport._wrapped_methods ) @@ -5103,11 +5985,11 @@ async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.reject_hub_spoke + client._client._transport.accept_hub_spoke ] = mock_rpc request = {} - await client.reject_hub_spoke(request) + await client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5117,7 +5999,7 @@ async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.reject_hub_spoke(request) + await client.accept_hub_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5125,8 +6007,8 @@ async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_reject_hub_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.RejectHubSpokeRequest +async def test_accept_hub_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.AcceptHubSpokeRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -5138,17 +6020,17 @@ async def test_reject_hub_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.reject_hub_spoke(request) + response = await client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.RejectHubSpokeRequest() + request = hub.AcceptHubSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -5156,25 +6038,25 @@ async def test_reject_hub_spoke_async( @pytest.mark.asyncio -async def test_reject_hub_spoke_async_from_dict(): - await test_reject_hub_spoke_async(request_type=dict) +async def test_accept_hub_spoke_async_from_dict(): + await test_accept_hub_spoke_async(request_type=dict) -def test_reject_hub_spoke_field_headers(): +def test_accept_hub_spoke_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.RejectHubSpokeRequest() + request = hub.AcceptHubSpokeRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.reject_hub_spoke(request) + client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -5190,23 +6072,23 @@ def test_reject_hub_spoke_field_headers(): @pytest.mark.asyncio -async def test_reject_hub_spoke_field_headers_async(): +async def test_accept_hub_spoke_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.RejectHubSpokeRequest() + request = hub.AcceptHubSpokeRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.reject_hub_spoke(request) + await client.accept_hub_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5221,18 +6103,18 @@ async def test_reject_hub_spoke_field_headers_async(): ) in kw["metadata"] -def test_reject_hub_spoke_flattened(): +def test_accept_hub_spoke_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.reject_hub_spoke( + client.accept_hub_spoke( name="name_value", spoke_uri="spoke_uri_value", ) @@ -5249,7 +6131,7 @@ def test_reject_hub_spoke_flattened(): assert arg == mock_val -def test_reject_hub_spoke_flattened_error(): +def test_accept_hub_spoke_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5257,21 +6139,21 @@ def test_reject_hub_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.reject_hub_spoke( - hub.RejectHubSpokeRequest(), + client.accept_hub_spoke( + hub.AcceptHubSpokeRequest(), name="name_value", spoke_uri="spoke_uri_value", ) @pytest.mark.asyncio -async def test_reject_hub_spoke_flattened_async(): +async def test_accept_hub_spoke_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.reject_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -5280,7 +6162,7 @@ async def test_reject_hub_spoke_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.reject_hub_spoke( + response = await client.accept_hub_spoke( name="name_value", spoke_uri="spoke_uri_value", ) @@ -5298,7 +6180,7 @@ async def test_reject_hub_spoke_flattened_async(): @pytest.mark.asyncio -async def test_reject_hub_spoke_flattened_error_async(): +async def test_accept_hub_spoke_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5306,8 +6188,8 @@ async def test_reject_hub_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.reject_hub_spoke( - hub.RejectHubSpokeRequest(), + await client.accept_hub_spoke( + hub.AcceptHubSpokeRequest(), name="name_value", spoke_uri="spoke_uri_value", ) @@ -5316,11 +6198,11 @@ async def test_reject_hub_spoke_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - hub.AcceptHubSpokeRequest, + hub.DeleteSpokeRequest, dict, ], ) -def test_accept_hub_spoke(request_type, transport: str = "grpc"): +def test_delete_spoke(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5331,22 +6213,22 @@ def test_accept_hub_spoke(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.accept_hub_spoke(request) + response = client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.AcceptHubSpokeRequest() + request = hub.DeleteSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, future.Future) -def test_accept_hub_spoke_non_empty_request_with_auto_populated_field(): +def test_delete_spoke_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -5357,28 +6239,26 @@ def test_accept_hub_spoke_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.AcceptHubSpokeRequest( + request = hub.DeleteSpokeRequest( name="name_value", - spoke_uri="spoke_uri_value", request_id="request_id_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.accept_hub_spoke(request=request) + client.delete_spoke(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.AcceptHubSpokeRequest( + assert args[0] == hub.DeleteSpokeRequest( name="name_value", - spoke_uri="spoke_uri_value", request_id="request_id_value", ) -def test_accept_hub_spoke_use_cached_wrapped_rpc(): +def test_delete_spoke_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5392,18 +6272,16 @@ def test_accept_hub_spoke_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.accept_hub_spoke in client._transport._wrapped_methods + assert client._transport.delete_spoke in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.accept_hub_spoke - ] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_spoke] = mock_rpc request = {} - client.accept_hub_spoke(request) + client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5413,7 +6291,7 @@ def test_accept_hub_spoke_use_cached_wrapped_rpc(): # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.accept_hub_spoke(request) + client.delete_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5421,7 +6299,7 @@ def test_accept_hub_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( +async def test_delete_spoke_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -5438,7 +6316,7 @@ async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.accept_hub_spoke + client._client._transport.delete_spoke in client._client._transport._wrapped_methods ) @@ -5446,11 +6324,11 @@ async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.accept_hub_spoke + client._client._transport.delete_spoke ] = mock_rpc request = {} - await client.accept_hub_spoke(request) + await client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5460,7 +6338,7 @@ async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.accept_hub_spoke(request) + await client.delete_spoke(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5468,8 +6346,8 @@ async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_accept_hub_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.AcceptHubSpokeRequest +async def test_delete_spoke_async( + transport: str = "grpc_asyncio", request_type=hub.DeleteSpokeRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -5481,17 +6359,17 @@ async def test_accept_hub_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.accept_hub_spoke(request) + response = await client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.AcceptHubSpokeRequest() + request = hub.DeleteSpokeRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -5499,25 +6377,25 @@ async def test_accept_hub_spoke_async( @pytest.mark.asyncio -async def test_accept_hub_spoke_async_from_dict(): - await test_accept_hub_spoke_async(request_type=dict) +async def test_delete_spoke_async_from_dict(): + await test_delete_spoke_async(request_type=dict) -def test_accept_hub_spoke_field_headers(): +def test_delete_spoke_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.AcceptHubSpokeRequest() + request = hub.DeleteSpokeRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.accept_hub_spoke(request) + client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -5533,23 +6411,23 @@ def test_accept_hub_spoke_field_headers(): @pytest.mark.asyncio -async def test_accept_hub_spoke_field_headers_async(): +async def test_delete_spoke_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.AcceptHubSpokeRequest() + request = hub.DeleteSpokeRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.accept_hub_spoke(request) + await client.delete_spoke(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5564,20 +6442,19 @@ async def test_accept_hub_spoke_field_headers_async(): ) in kw["metadata"] -def test_accept_hub_spoke_flattened(): +def test_delete_spoke_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.accept_hub_spoke( + client.delete_spoke( name="name_value", - spoke_uri="spoke_uri_value", ) # Establish that the underlying call was made with the expected @@ -5587,12 +6464,9 @@ def test_accept_hub_spoke_flattened(): arg = args[0].name mock_val = "name_value" assert arg == mock_val - arg = args[0].spoke_uri - mock_val = "spoke_uri_value" - assert arg == mock_val -def test_accept_hub_spoke_flattened_error(): +def test_delete_spoke_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5600,21 +6474,20 @@ def test_accept_hub_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.accept_hub_spoke( - hub.AcceptHubSpokeRequest(), + client.delete_spoke( + hub.DeleteSpokeRequest(), name="name_value", - spoke_uri="spoke_uri_value", ) @pytest.mark.asyncio -async def test_accept_hub_spoke_flattened_async(): +async def test_delete_spoke_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.accept_hub_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -5623,9 +6496,8 @@ async def test_accept_hub_spoke_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.accept_hub_spoke( + response = await client.delete_spoke( name="name_value", - spoke_uri="spoke_uri_value", ) # Establish that the underlying call was made with the expected @@ -5635,13 +6507,10 @@ async def test_accept_hub_spoke_flattened_async(): arg = args[0].name mock_val = "name_value" assert arg == mock_val - arg = args[0].spoke_uri - mock_val = "spoke_uri_value" - assert arg == mock_val @pytest.mark.asyncio -async def test_accept_hub_spoke_flattened_error_async(): +async def test_delete_spoke_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5649,21 +6518,20 @@ async def test_accept_hub_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.accept_hub_spoke( - hub.AcceptHubSpokeRequest(), + await client.delete_spoke( + hub.DeleteSpokeRequest(), name="name_value", - spoke_uri="spoke_uri_value", ) @pytest.mark.parametrize( "request_type", [ - hub.DeleteSpokeRequest, + hub.GetRouteTableRequest, dict, ], ) -def test_delete_spoke(request_type, transport: str = "grpc"): +def test_get_route_table(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5674,22 +6542,31 @@ def test_delete_spoke(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_spoke(request) + call.return_value = hub.RouteTable( + name="name_value", + description="description_value", + uid="uid_value", + state=hub.State.CREATING, + ) + response = client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.DeleteSpokeRequest() + request = hub.GetRouteTableRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, hub.RouteTable) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.uid == "uid_value" + assert response.state == hub.State.CREATING -def test_delete_spoke_non_empty_request_with_auto_populated_field(): +def test_get_route_table_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -5700,26 +6577,24 @@ def test_delete_spoke_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.DeleteSpokeRequest( + request = hub.GetRouteTableRequest( name="name_value", - request_id="request_id_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.delete_spoke(request=request) + client.get_route_table(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.DeleteSpokeRequest( + assert args[0] == hub.GetRouteTableRequest( name="name_value", - request_id="request_id_value", ) -def test_delete_spoke_use_cached_wrapped_rpc(): +def test_get_route_table_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5733,26 +6608,21 @@ def test_delete_spoke_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_spoke in client._transport._wrapped_methods + assert client._transport.get_route_table in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_spoke] = mock_rpc + client._transport._wrapped_methods[client._transport.get_route_table] = mock_rpc request = {} - client.delete_spoke(request) + client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_spoke(request) + client.get_route_table(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5760,7 +6630,7 @@ def test_delete_spoke_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_delete_spoke_async_use_cached_wrapped_rpc( +async def test_get_route_table_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -5777,7 +6647,7 @@ async def test_delete_spoke_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.delete_spoke + client._client._transport.get_route_table in client._client._transport._wrapped_methods ) @@ -5785,21 +6655,16 @@ async def test_delete_spoke_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.delete_spoke + client._client._transport.get_route_table ] = mock_rpc request = {} - await client.delete_spoke(request) + await client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_spoke(request) + await client.get_route_table(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5807,8 +6672,8 @@ async def test_delete_spoke_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_spoke_async( - transport: str = "grpc_asyncio", request_type=hub.DeleteSpokeRequest +async def test_get_route_table_async( + transport: str = "grpc_asyncio", request_type=hub.GetRouteTableRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -5820,43 +6685,52 @@ async def test_delete_spoke_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + hub.RouteTable( + name="name_value", + description="description_value", + uid="uid_value", + state=hub.State.CREATING, + ) ) - response = await client.delete_spoke(request) + response = await client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.DeleteSpokeRequest() + request = hub.GetRouteTableRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, hub.RouteTable) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.uid == "uid_value" + assert response.state == hub.State.CREATING @pytest.mark.asyncio -async def test_delete_spoke_async_from_dict(): - await test_delete_spoke_async(request_type=dict) +async def test_get_route_table_async_from_dict(): + await test_get_route_table_async(request_type=dict) -def test_delete_spoke_field_headers(): +def test_get_route_table_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.DeleteSpokeRequest() + request = hub.GetRouteTableRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_spoke(request) + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + call.return_value = hub.RouteTable() + client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -5872,23 +6746,21 @@ def test_delete_spoke_field_headers(): @pytest.mark.asyncio -async def test_delete_spoke_field_headers_async(): +async def test_get_route_table_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.DeleteSpokeRequest() + request = hub.GetRouteTableRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_spoke(request) + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.RouteTable()) + await client.get_route_table(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5903,18 +6775,18 @@ async def test_delete_spoke_field_headers_async(): ) in kw["metadata"] -def test_delete_spoke_flattened(): +def test_get_route_table_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = hub.RouteTable() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_spoke( + client.get_route_table( name="name_value", ) @@ -5927,7 +6799,7 @@ def test_delete_spoke_flattened(): assert arg == mock_val -def test_delete_spoke_flattened_error(): +def test_get_route_table_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5935,29 +6807,27 @@ def test_delete_spoke_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_spoke( - hub.DeleteSpokeRequest(), + client.get_route_table( + hub.GetRouteTableRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_delete_spoke_flattened_async(): +async def test_get_route_table_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_spoke), "__call__") as call: + with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = hub.RouteTable() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.RouteTable()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_spoke( + response = await client.get_route_table( name="name_value", ) @@ -5971,7 +6841,7 @@ async def test_delete_spoke_flattened_async(): @pytest.mark.asyncio -async def test_delete_spoke_flattened_error_async(): +async def test_get_route_table_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5979,8 +6849,8 @@ async def test_delete_spoke_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_spoke( - hub.DeleteSpokeRequest(), + await client.get_route_table( + hub.GetRouteTableRequest(), name="name_value", ) @@ -5988,11 +6858,11 @@ async def test_delete_spoke_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - hub.GetRouteTableRequest, + hub.GetRouteRequest, dict, ], ) -def test_get_route_table(request_type, transport: str = "grpc"): +def test_get_route(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6003,31 +6873,41 @@ def test_get_route_table(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + with mock.patch.object(type(client.transport.get_route), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.RouteTable( + call.return_value = hub.Route( name="name_value", + ip_cidr_range="ip_cidr_range_value", + type_=hub.RouteType.VPC_PRIMARY_SUBNET, description="description_value", uid="uid_value", state=hub.State.CREATING, + spoke="spoke_value", + location="location_value", + priority=898, ) - response = client.get_route_table(request) + response = client.get_route(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.GetRouteTableRequest() + request = hub.GetRouteRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.RouteTable) + assert isinstance(response, hub.Route) assert response.name == "name_value" + assert response.ip_cidr_range == "ip_cidr_range_value" + assert response.type_ == hub.RouteType.VPC_PRIMARY_SUBNET assert response.description == "description_value" assert response.uid == "uid_value" assert response.state == hub.State.CREATING + assert response.spoke == "spoke_value" + assert response.location == "location_value" + assert response.priority == 898 -def test_get_route_table_non_empty_request_with_auto_populated_field(): +def test_get_route_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -6038,24 +6918,24 @@ def test_get_route_table_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.GetRouteTableRequest( + request = hub.GetRouteRequest( name="name_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + with mock.patch.object(type(client.transport.get_route), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_route_table(request=request) + client.get_route(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.GetRouteTableRequest( + assert args[0] == hub.GetRouteRequest( name="name_value", ) -def test_get_route_table_use_cached_wrapped_rpc(): +def test_get_route_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -6069,21 +6949,21 @@ def test_get_route_table_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_route_table in client._transport._wrapped_methods + assert client._transport.get_route in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_route_table] = mock_rpc + client._transport._wrapped_methods[client._transport.get_route] = mock_rpc request = {} - client.get_route_table(request) + client.get_route(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_route_table(request) + client.get_route(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6091,9 +6971,7 @@ def test_get_route_table_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_route_table_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -6108,7 +6986,7 @@ async def test_get_route_table_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_route_table + client._client._transport.get_route in client._client._transport._wrapped_methods ) @@ -6116,16 +6994,16 @@ async def test_get_route_table_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_route_table + client._client._transport.get_route ] = mock_rpc request = {} - await client.get_route_table(request) + await client.get_route(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_route_table(request) + await client.get_route(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6133,8 +7011,8 @@ async def test_get_route_table_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_route_table_async( - transport: str = "grpc_asyncio", request_type=hub.GetRouteTableRequest +async def test_get_route_async( + transport: str = "grpc_asyncio", request_type=hub.GetRouteRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -6146,52 +7024,62 @@ async def test_get_route_table_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + with mock.patch.object(type(client.transport.get_route), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.RouteTable( + hub.Route( name="name_value", + ip_cidr_range="ip_cidr_range_value", + type_=hub.RouteType.VPC_PRIMARY_SUBNET, description="description_value", uid="uid_value", state=hub.State.CREATING, + spoke="spoke_value", + location="location_value", + priority=898, ) ) - response = await client.get_route_table(request) + response = await client.get_route(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.GetRouteTableRequest() + request = hub.GetRouteRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.RouteTable) + assert isinstance(response, hub.Route) assert response.name == "name_value" + assert response.ip_cidr_range == "ip_cidr_range_value" + assert response.type_ == hub.RouteType.VPC_PRIMARY_SUBNET assert response.description == "description_value" assert response.uid == "uid_value" assert response.state == hub.State.CREATING + assert response.spoke == "spoke_value" + assert response.location == "location_value" + assert response.priority == 898 @pytest.mark.asyncio -async def test_get_route_table_async_from_dict(): - await test_get_route_table_async(request_type=dict) +async def test_get_route_async_from_dict(): + await test_get_route_async(request_type=dict) -def test_get_route_table_field_headers(): +def test_get_route_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetRouteTableRequest() + request = hub.GetRouteRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: - call.return_value = hub.RouteTable() - client.get_route_table(request) + with mock.patch.object(type(client.transport.get_route), "__call__") as call: + call.return_value = hub.Route() + client.get_route(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6207,22 +7095,22 @@ def test_get_route_table_field_headers(): @pytest.mark.asyncio -async def test_get_route_table_field_headers_async(): +async def test_get_route_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetRouteTableRequest() + request = hub.GetRouteRequest() request.name = "name_value" - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.RouteTable()) - await client.get_route_table(request) - + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_route), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Route()) + await client.get_route(request) + # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] @@ -6236,18 +7124,18 @@ async def test_get_route_table_field_headers_async(): ) in kw["metadata"] -def test_get_route_table_flattened(): +def test_get_route_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + with mock.patch.object(type(client.transport.get_route), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.RouteTable() + call.return_value = hub.Route() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_route_table( + client.get_route( name="name_value", ) @@ -6260,7 +7148,7 @@ def test_get_route_table_flattened(): assert arg == mock_val -def test_get_route_table_flattened_error(): +def test_get_route_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6268,27 +7156,27 @@ def test_get_route_table_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_route_table( - hub.GetRouteTableRequest(), + client.get_route( + hub.GetRouteRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_route_table_flattened_async(): +async def test_get_route_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route_table), "__call__") as call: + with mock.patch.object(type(client.transport.get_route), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.RouteTable() + call.return_value = hub.Route() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.RouteTable()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Route()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_route_table( + response = await client.get_route( name="name_value", ) @@ -6302,7 +7190,7 @@ async def test_get_route_table_flattened_async(): @pytest.mark.asyncio -async def test_get_route_table_flattened_error_async(): +async def test_get_route_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -6310,8 +7198,8 @@ async def test_get_route_table_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_route_table( - hub.GetRouteTableRequest(), + await client.get_route( + hub.GetRouteRequest(), name="name_value", ) @@ -6319,11 +7207,11 @@ async def test_get_route_table_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - hub.GetRouteRequest, + hub.ListRoutesRequest, dict, ], ) -def test_get_route(request_type, transport: str = "grpc"): +def test_list_routes(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6334,39 +7222,27 @@ def test_get_route(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Route( - name="name_value", - ip_cidr_range="ip_cidr_range_value", - type_=hub.RouteType.VPC_PRIMARY_SUBNET, - description="description_value", - uid="uid_value", - state=hub.State.CREATING, - spoke="spoke_value", - location="location_value", + call.return_value = hub.ListRoutesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) - response = client.get_route(request) + response = client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.GetRouteRequest() + request = hub.ListRoutesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Route) - assert response.name == "name_value" - assert response.ip_cidr_range == "ip_cidr_range_value" - assert response.type_ == hub.RouteType.VPC_PRIMARY_SUBNET - assert response.description == "description_value" - assert response.uid == "uid_value" - assert response.state == hub.State.CREATING - assert response.spoke == "spoke_value" - assert response.location == "location_value" + assert isinstance(response, pagers.ListRoutesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] -def test_get_route_non_empty_request_with_auto_populated_field(): +def test_list_routes_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -6377,24 +7253,30 @@ def test_get_route_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.GetRouteRequest( - name="name_value", + request = hub.ListRoutesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_route(request=request) + client.list_routes(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.GetRouteRequest( - name="name_value", + assert args[0] == hub.ListRoutesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) -def test_get_route_use_cached_wrapped_rpc(): +def test_list_routes_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -6408,21 +7290,21 @@ def test_get_route_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_route in client._transport._wrapped_methods + assert client._transport.list_routes in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_route] = mock_rpc + client._transport._wrapped_methods[client._transport.list_routes] = mock_rpc request = {} - client.get_route(request) + client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_route(request) + client.list_routes(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6430,7 +7312,9 @@ def test_get_route_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_list_routes_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -6445,7 +7329,7 @@ async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asy # Ensure method has been cached assert ( - client._client._transport.get_route + client._client._transport.list_routes in client._client._transport._wrapped_methods ) @@ -6453,16 +7337,16 @@ async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asy mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_route + client._client._transport.list_routes ] = mock_rpc request = {} - await client.get_route(request) + await client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_route(request) + await client.list_routes(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6470,8 +7354,8 @@ async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asy @pytest.mark.asyncio -async def test_get_route_async( - transport: str = "grpc_asyncio", request_type=hub.GetRouteRequest +async def test_list_routes_async( + transport: str = "grpc_asyncio", request_type=hub.ListRoutesRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -6483,60 +7367,48 @@ async def test_get_route_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.Route( - name="name_value", - ip_cidr_range="ip_cidr_range_value", - type_=hub.RouteType.VPC_PRIMARY_SUBNET, - description="description_value", - uid="uid_value", - state=hub.State.CREATING, - spoke="spoke_value", - location="location_value", + hub.ListRoutesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) ) - response = await client.get_route(request) + response = await client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.GetRouteRequest() + request = hub.ListRoutesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Route) - assert response.name == "name_value" - assert response.ip_cidr_range == "ip_cidr_range_value" - assert response.type_ == hub.RouteType.VPC_PRIMARY_SUBNET - assert response.description == "description_value" - assert response.uid == "uid_value" - assert response.state == hub.State.CREATING - assert response.spoke == "spoke_value" - assert response.location == "location_value" + assert isinstance(response, pagers.ListRoutesAsyncPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio -async def test_get_route_async_from_dict(): - await test_get_route_async(request_type=dict) +async def test_list_routes_async_from_dict(): + await test_list_routes_async(request_type=dict) -def test_get_route_field_headers(): +def test_list_routes_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetRouteRequest() + request = hub.ListRoutesRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: - call.return_value = hub.Route() - client.get_route(request) + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + call.return_value = hub.ListRoutesResponse() + client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6547,128 +7419,326 @@ def test_get_route_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_route_field_headers_async(): +async def test_list_routes_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetRouteRequest() + request = hub.ListRoutesRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Route()) - await client.get_route(request) + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListRoutesResponse() + ) + await client.list_routes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == request - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_routes_flattened(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.ListRoutesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_routes( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_routes_flattened_error(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_routes( + hub.ListRoutesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_routes_flattened_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.ListRoutesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListRoutesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_routes( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_routes_flattened_error_async(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_routes( + hub.ListRoutesRequest(), + parent="parent_value", + ) -def test_get_route_flattened(): +def test_list_routes_pager(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = hub.Route() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_route( - name="name_value", + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + hub.Route(), + ], + next_page_token="abc", + ), + hub.ListRoutesResponse( + routes=[], + next_page_token="def", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + ], + next_page_token="ghi", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + ], + ), + RuntimeError, ) - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_routes(request={}, retry=retry, timeout=timeout) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout -def test_get_route_flattened_error(): + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, hub.Route) for i in results) + + +def test_list_routes_pages(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_route( - hub.GetRouteRequest(), - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + hub.Route(), + ], + next_page_token="abc", + ), + hub.ListRoutesResponse( + routes=[], + next_page_token="def", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + ], + next_page_token="ghi", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + ], + ), + RuntimeError, ) + pages = list(client.list_routes(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_get_route_flattened_async(): +async def test_list_routes_async_pager(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_route), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = hub.Route() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Route()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_route( - name="name_value", + with mock.patch.object( + type(client.transport.list_routes), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + hub.Route(), + ], + next_page_token="abc", + ), + hub.ListRoutesResponse( + routes=[], + next_page_token="def", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + ], + next_page_token="ghi", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_routes( + request={}, ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val + assert len(responses) == 6 + assert all(isinstance(i, hub.Route) for i in responses) @pytest.mark.asyncio -async def test_get_route_flattened_error_async(): +async def test_list_routes_async_pages(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_route( - hub.GetRouteRequest(), - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_routes), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + hub.Route(), + ], + next_page_token="abc", + ), + hub.ListRoutesResponse( + routes=[], + next_page_token="def", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + ], + next_page_token="ghi", + ), + hub.ListRoutesResponse( + routes=[ + hub.Route(), + hub.Route(), + ], + ), + RuntimeError, ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_routes(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - hub.ListRoutesRequest, + hub.ListRouteTablesRequest, dict, ], ) -def test_list_routes(request_type, transport: str = "grpc"): +def test_list_route_tables(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6679,27 +7749,29 @@ def test_list_routes(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListRoutesResponse( + call.return_value = hub.ListRouteTablesResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_routes(request) + response = client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.ListRoutesRequest() + request = hub.ListRouteTablesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRoutesPager) + assert isinstance(response, pagers.ListRouteTablesPager) assert response.next_page_token == "next_page_token_value" assert response.unreachable == ["unreachable_value"] -def test_list_routes_non_empty_request_with_auto_populated_field(): +def test_list_route_tables_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -6710,7 +7782,7 @@ def test_list_routes_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.ListRoutesRequest( + request = hub.ListRouteTablesRequest( parent="parent_value", page_token="page_token_value", filter="filter_value", @@ -6718,14 +7790,16 @@ def test_list_routes_non_empty_request_with_auto_populated_field(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_routes(request=request) + client.list_route_tables(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.ListRoutesRequest( + assert args[0] == hub.ListRouteTablesRequest( parent="parent_value", page_token="page_token_value", filter="filter_value", @@ -6733,7 +7807,7 @@ def test_list_routes_non_empty_request_with_auto_populated_field(): ) -def test_list_routes_use_cached_wrapped_rpc(): +def test_list_route_tables_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -6747,21 +7821,23 @@ def test_list_routes_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_routes in client._transport._wrapped_methods + assert client._transport.list_route_tables in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_routes] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_route_tables + ] = mock_rpc request = {} - client.list_routes(request) + client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_routes(request) + client.list_route_tables(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6769,7 +7845,7 @@ def test_list_routes_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_routes_async_use_cached_wrapped_rpc( +async def test_list_route_tables_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -6786,7 +7862,7 @@ async def test_list_routes_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.list_routes + client._client._transport.list_route_tables in client._client._transport._wrapped_methods ) @@ -6794,16 +7870,16 @@ async def test_list_routes_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_routes + client._client._transport.list_route_tables ] = mock_rpc request = {} - await client.list_routes(request) + await client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_routes(request) + await client.list_route_tables(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6811,8 +7887,8 @@ async def test_list_routes_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_routes_async( - transport: str = "grpc_asyncio", request_type=hub.ListRoutesRequest +async def test_list_route_tables_async( + transport: str = "grpc_asyncio", request_type=hub.ListRouteTablesRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -6824,48 +7900,52 @@ async def test_list_routes_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRoutesResponse( + hub.ListRouteTablesResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) ) - response = await client.list_routes(request) + response = await client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.ListRoutesRequest() + request = hub.ListRouteTablesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRoutesAsyncPager) + assert isinstance(response, pagers.ListRouteTablesAsyncPager) assert response.next_page_token == "next_page_token_value" assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio -async def test_list_routes_async_from_dict(): - await test_list_routes_async(request_type=dict) +async def test_list_route_tables_async_from_dict(): + await test_list_route_tables_async(request_type=dict) -def test_list_routes_field_headers(): +def test_list_route_tables_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListRoutesRequest() + request = hub.ListRouteTablesRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: - call.return_value = hub.ListRoutesResponse() - client.list_routes(request) + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: + call.return_value = hub.ListRouteTablesResponse() + client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6881,23 +7961,25 @@ def test_list_routes_field_headers(): @pytest.mark.asyncio -async def test_list_routes_field_headers_async(): +async def test_list_route_tables_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListRoutesRequest() + request = hub.ListRouteTablesRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRoutesResponse() + hub.ListRouteTablesResponse() ) - await client.list_routes(request) + await client.list_route_tables(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -6912,18 +7994,20 @@ async def test_list_routes_field_headers_async(): ) in kw["metadata"] -def test_list_routes_flattened(): +def test_list_route_tables_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListRoutesResponse() + call.return_value = hub.ListRouteTablesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_routes( + client.list_route_tables( parent="parent_value", ) @@ -6936,7 +8020,7 @@ def test_list_routes_flattened(): assert arg == mock_val -def test_list_routes_flattened_error(): +def test_list_route_tables_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6944,29 +8028,31 @@ def test_list_routes_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_routes( - hub.ListRoutesRequest(), + client.list_route_tables( + hub.ListRouteTablesRequest(), parent="parent_value", ) @pytest.mark.asyncio -async def test_list_routes_flattened_async(): +async def test_list_route_tables_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListRoutesResponse() + call.return_value = hub.ListRouteTablesResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRoutesResponse() + hub.ListRouteTablesResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_routes( + response = await client.list_route_tables( parent="parent_value", ) @@ -6980,7 +8066,7 @@ async def test_list_routes_flattened_async(): @pytest.mark.asyncio -async def test_list_routes_flattened_error_async(): +async def test_list_route_tables_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -6988,44 +8074,46 @@ async def test_list_routes_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_routes( - hub.ListRoutesRequest(), + await client.list_route_tables( + hub.ListRouteTablesRequest(), parent="parent_value", ) -def test_list_routes_pager(transport_name: str = "grpc"): +def test_list_route_tables_pager(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), + hub.RouteTable(), ], next_page_token="abc", ), - hub.ListRoutesResponse( - routes=[], + hub.ListRouteTablesResponse( + route_tables=[], next_page_token="def", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), ], next_page_token="ghi", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), ], ), RuntimeError, @@ -7037,7 +8125,7 @@ def test_list_routes_pager(transport_name: str = "grpc"): expected_metadata = tuple(expected_metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - pager = client.list_routes(request={}, retry=retry, timeout=timeout) + pager = client.list_route_tables(request={}, retry=retry, timeout=timeout) assert pager._metadata == expected_metadata assert pager._retry == retry @@ -7045,89 +8133,93 @@ def test_list_routes_pager(transport_name: str = "grpc"): results = list(pager) assert len(results) == 6 - assert all(isinstance(i, hub.Route) for i in results) + assert all(isinstance(i, hub.RouteTable) for i in results) -def test_list_routes_pages(transport_name: str = "grpc"): +def test_list_route_tables_pages(transport_name: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_routes), "__call__") as call: + with mock.patch.object( + type(client.transport.list_route_tables), "__call__" + ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), + hub.RouteTable(), ], next_page_token="abc", ), - hub.ListRoutesResponse( - routes=[], + hub.ListRouteTablesResponse( + route_tables=[], next_page_token="def", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), ], next_page_token="ghi", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), ], ), RuntimeError, ) - pages = list(client.list_routes(request={}).pages) + pages = list(client.list_route_tables(request={}).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_list_routes_async_pager(): +async def test_list_route_tables_async_pager(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_routes), "__call__", new_callable=mock.AsyncMock + type(client.transport.list_route_tables), + "__call__", + new_callable=mock.AsyncMock, ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), + hub.RouteTable(), ], next_page_token="abc", ), - hub.ListRoutesResponse( - routes=[], + hub.ListRouteTablesResponse( + route_tables=[], next_page_token="def", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), ], next_page_token="ghi", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), ], ), RuntimeError, ) - async_pager = await client.list_routes( + async_pager = await client.list_route_tables( request={}, ) assert async_pager.next_page_token == "abc" @@ -7136,43 +8228,45 @@ async def test_list_routes_async_pager(): responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, hub.Route) for i in responses) + assert all(isinstance(i, hub.RouteTable) for i in responses) @pytest.mark.asyncio -async def test_list_routes_async_pages(): +async def test_list_route_tables_async_pages(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_routes), "__call__", new_callable=mock.AsyncMock + type(client.transport.list_route_tables), + "__call__", + new_callable=mock.AsyncMock, ) as call: # Set the response to a series of pages. call.side_effect = ( - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), + hub.RouteTable(), ], next_page_token="abc", ), - hub.ListRoutesResponse( - routes=[], + hub.ListRouteTablesResponse( + route_tables=[], next_page_token="def", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), ], next_page_token="ghi", ), - hub.ListRoutesResponse( - routes=[ - hub.Route(), - hub.Route(), + hub.ListRouteTablesResponse( + route_tables=[ + hub.RouteTable(), + hub.RouteTable(), ], ), RuntimeError, @@ -7181,7 +8275,7 @@ async def test_list_routes_async_pages(): # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 async for page_ in ( # pragma: no branch - await client.list_routes(request={}) + await client.list_route_tables(request={}) ).pages: pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): @@ -7191,11 +8285,11 @@ async def test_list_routes_async_pages(): @pytest.mark.parametrize( "request_type", [ - hub.ListRouteTablesRequest, + hub.GetGroupRequest, dict, ], ) -def test_list_route_tables(request_type, transport: str = "grpc"): +def test_get_group(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7206,29 +8300,33 @@ def test_list_route_tables(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_group), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListRouteTablesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], + call.return_value = hub.Group( + name="name_value", + description="description_value", + uid="uid_value", + state=hub.State.CREATING, + route_table="route_table_value", ) - response = client.list_route_tables(request) + response = client.get_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.ListRouteTablesRequest() + request = hub.GetGroupRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRouteTablesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, hub.Group) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.uid == "uid_value" + assert response.state == hub.State.CREATING + assert response.route_table == "route_table_value" -def test_list_route_tables_non_empty_request_with_auto_populated_field(): +def test_get_group_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -7239,32 +8337,24 @@ def test_list_route_tables_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.ListRouteTablesRequest( - parent="parent_value", - page_token="page_token_value", - filter="filter_value", - order_by="order_by_value", + request = hub.GetGroupRequest( + name="name_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_group), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_route_tables(request=request) + client.get_group(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.ListRouteTablesRequest( - parent="parent_value", - page_token="page_token_value", - filter="filter_value", - order_by="order_by_value", + assert args[0] == hub.GetGroupRequest( + name="name_value", ) -def test_list_route_tables_use_cached_wrapped_rpc(): +def test_get_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7278,23 +8368,21 @@ def test_list_route_tables_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_route_tables in client._transport._wrapped_methods + assert client._transport.get_group in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.list_route_tables - ] = mock_rpc + client._transport._wrapped_methods[client._transport.get_group] = mock_rpc request = {} - client.list_route_tables(request) + client.get_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_route_tables(request) + client.get_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7302,9 +8390,7 @@ def test_list_route_tables_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_route_tables_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -7319,7 +8405,7 @@ async def test_list_route_tables_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.list_route_tables + client._client._transport.get_group in client._client._transport._wrapped_methods ) @@ -7327,16 +8413,16 @@ async def test_list_route_tables_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_route_tables + client._client._transport.get_group ] = mock_rpc request = {} - await client.list_route_tables(request) + await client.get_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_route_tables(request) + await client.get_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7344,8 +8430,8 @@ async def test_list_route_tables_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_route_tables_async( - transport: str = "grpc_asyncio", request_type=hub.ListRouteTablesRequest +async def test_get_group_async( + transport: str = "grpc_asyncio", request_type=hub.GetGroupRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -7357,52 +8443,54 @@ async def test_list_route_tables_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRouteTablesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], + hub.Group( + name="name_value", + description="description_value", + uid="uid_value", + state=hub.State.CREATING, + route_table="route_table_value", ) ) - response = await client.list_route_tables(request) + response = await client.get_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.ListRouteTablesRequest() + request = hub.GetGroupRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRouteTablesAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, hub.Group) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.uid == "uid_value" + assert response.state == hub.State.CREATING + assert response.route_table == "route_table_value" @pytest.mark.asyncio -async def test_list_route_tables_async_from_dict(): - await test_list_route_tables_async(request_type=dict) +async def test_get_group_async_from_dict(): + await test_get_group_async(request_type=dict) -def test_list_route_tables_field_headers(): +def test_get_group_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListRouteTablesRequest() + request = hub.GetGroupRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - call.return_value = hub.ListRouteTablesResponse() - client.list_route_tables(request) + with mock.patch.object(type(client.transport.get_group), "__call__") as call: + call.return_value = hub.Group() + client.get_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7413,30 +8501,26 @@ def test_list_route_tables_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_route_tables_field_headers_async(): +async def test_get_group_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListRouteTablesRequest() + request = hub.GetGroupRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRouteTablesResponse() - ) - await client.list_route_tables(request) + with mock.patch.object(type(client.transport.get_group), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Group()) + await client.get_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7447,306 +8531,98 @@ async def test_list_route_tables_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_list_route_tables_flattened(): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = hub.ListRouteTablesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_route_tables( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -def test_list_route_tables_flattened_error(): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_route_tables( - hub.ListRouteTablesRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_route_tables_flattened_async(): - client = HubServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = hub.ListRouteTablesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListRouteTablesResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_route_tables( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_list_route_tables_flattened_error_async(): - client = HubServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_route_tables( - hub.ListRouteTablesRequest(), - parent="parent_value", - ) - - -def test_list_route_tables_pager(transport_name: str = "grpc"): +def test_get_group_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - hub.RouteTable(), - ], - next_page_token="abc", - ), - hub.ListRouteTablesResponse( - route_tables=[], - next_page_token="def", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - ], - next_page_token="ghi", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_route_tables(request={}, retry=retry, timeout=timeout) + ) - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_group), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.Group() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_group( + name="name_value", + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, hub.RouteTable) for i in results) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_route_tables_pages(transport_name: str = "grpc"): +def test_get_group_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - hub.RouteTable(), - ], - next_page_token="abc", - ), - hub.ListRouteTablesResponse( - route_tables=[], - next_page_token="def", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - ], - next_page_token="ghi", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - ], - ), - RuntimeError, + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_group( + hub.GetGroupRequest(), + name="name_value", ) - pages = list(client.list_route_tables(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_list_route_tables_async_pager(): +async def test_get_group_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - hub.RouteTable(), - ], - next_page_token="abc", - ), - hub.ListRouteTablesResponse( - route_tables=[], - next_page_token="def", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - ], - next_page_token="ghi", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_route_tables( - request={}, + with mock.patch.object(type(client.transport.get_group), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = hub.Group() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Group()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_group( + name="name_value", ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - assert len(responses) == 6 - assert all(isinstance(i, hub.RouteTable) for i in responses) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio -async def test_list_route_tables_async_pages(): +async def test_get_group_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_route_tables), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - hub.RouteTable(), - ], - next_page_token="abc", - ), - hub.ListRouteTablesResponse( - route_tables=[], - next_page_token="def", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - ], - next_page_token="ghi", - ), - hub.ListRouteTablesResponse( - route_tables=[ - hub.RouteTable(), - hub.RouteTable(), - ], - ), - RuntimeError, + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_group( + hub.GetGroupRequest(), + name="name_value", ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_route_tables(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - hub.GetGroupRequest, + hub.ListGroupsRequest, dict, ], ) -def test_get_group(request_type, transport: str = "grpc"): +def test_list_groups(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7757,31 +8633,27 @@ def test_get_group(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Group( - name="name_value", - description="description_value", - uid="uid_value", - state=hub.State.CREATING, + call.return_value = hub.ListGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) - response = client.get_group(request) + response = client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.GetGroupRequest() + request = hub.ListGroupsRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Group) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.uid == "uid_value" - assert response.state == hub.State.CREATING + assert isinstance(response, pagers.ListGroupsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] -def test_get_group_non_empty_request_with_auto_populated_field(): +def test_list_groups_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -7792,24 +8664,30 @@ def test_get_group_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.GetGroupRequest( - name="name_value", + request = hub.ListGroupsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_group(request=request) + client.list_groups(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.GetGroupRequest( - name="name_value", + assert args[0] == hub.ListGroupsRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) -def test_get_group_use_cached_wrapped_rpc(): +def test_list_groups_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7823,21 +8701,21 @@ def test_get_group_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_group in client._transport._wrapped_methods + assert client._transport.list_groups in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_group] = mock_rpc + client._transport._wrapped_methods[client._transport.list_groups] = mock_rpc request = {} - client.get_group(request) + client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_group(request) + client.list_groups(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7845,7 +8723,9 @@ def test_get_group_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_list_groups_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -7860,7 +8740,7 @@ async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asy # Ensure method has been cached assert ( - client._client._transport.get_group + client._client._transport.list_groups in client._client._transport._wrapped_methods ) @@ -7868,16 +8748,16 @@ async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asy mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_group + client._client._transport.list_groups ] = mock_rpc request = {} - await client.get_group(request) + await client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_group(request) + await client.list_groups(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7885,8 +8765,8 @@ async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asy @pytest.mark.asyncio -async def test_get_group_async( - transport: str = "grpc_asyncio", request_type=hub.GetGroupRequest +async def test_list_groups_async( + transport: str = "grpc_asyncio", request_type=hub.ListGroupsRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -7898,52 +8778,48 @@ async def test_get_group_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.Group( - name="name_value", - description="description_value", - uid="uid_value", - state=hub.State.CREATING, + hub.ListGroupsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) ) - response = await client.get_group(request) + response = await client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.GetGroupRequest() + request = hub.ListGroupsRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, hub.Group) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.uid == "uid_value" - assert response.state == hub.State.CREATING + assert isinstance(response, pagers.ListGroupsAsyncPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] @pytest.mark.asyncio -async def test_get_group_async_from_dict(): - await test_get_group_async(request_type=dict) +async def test_list_groups_async_from_dict(): + await test_list_groups_async(request_type=dict) -def test_get_group_field_headers(): +def test_list_groups_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetGroupRequest() + request = hub.ListGroupsRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: - call.return_value = hub.Group() - client.get_group(request) + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + call.return_value = hub.ListGroupsResponse() + client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7954,26 +8830,28 @@ def test_get_group_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_group_field_headers_async(): +async def test_list_groups_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.GetGroupRequest() + request = hub.ListGroupsRequest() - request.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Group()) - await client.get_group(request) + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListGroupsResponse() + ) + await client.list_groups(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7984,35 +8862,35 @@ async def test_get_group_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_group_flattened(): +def test_list_groups_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Group() + call.return_value = hub.ListGroupsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_group( - name="name_value", + client.list_groups( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_get_group_flattened_error(): +def test_list_groups_flattened_error(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -8020,41 +8898,43 @@ def test_get_group_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_group( - hub.GetGroupRequest(), - name="name_value", + client.list_groups( + hub.ListGroupsRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_group_flattened_async(): +async def test_list_groups_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_group), "__call__") as call: + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.Group() + call.return_value = hub.ListGroupsResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(hub.Group()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.ListGroupsResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_group( - name="name_value", + response = await client.list_groups( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val @pytest.mark.asyncio -async def test_get_group_flattened_error_async(): +async def test_list_groups_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) @@ -8062,20 +8942,214 @@ async def test_get_group_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_group( - hub.GetGroupRequest(), - name="name_value", + await client.list_groups( + hub.ListGroupsRequest(), + parent="parent_value", + ) + + +def test_list_groups_pager(transport_name: str = "grpc"): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + hub.Group(), + ], + next_page_token="abc", + ), + hub.ListGroupsResponse( + groups=[], + next_page_token="def", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + ], + next_page_token="ghi", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_groups(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, hub.Group) for i in results) + + +def test_list_groups_pages(transport_name: str = "grpc"): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + hub.Group(), + ], + next_page_token="abc", + ), + hub.ListGroupsResponse( + groups=[], + next_page_token="def", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + ], + next_page_token="ghi", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + ], + ), + RuntimeError, + ) + pages = list(client.list_groups(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_groups_async_pager(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_groups), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + hub.Group(), + ], + next_page_token="abc", + ), + hub.ListGroupsResponse( + groups=[], + next_page_token="def", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + ], + next_page_token="ghi", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_groups( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, hub.Group) for i in responses) + + +@pytest.mark.asyncio +async def test_list_groups_async_pages(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_groups), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + hub.Group(), + ], + next_page_token="abc", + ), + hub.ListGroupsResponse( + groups=[], + next_page_token="def", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + ], + next_page_token="ghi", + ), + hub.ListGroupsResponse( + groups=[ + hub.Group(), + hub.Group(), + ], + ), + RuntimeError, ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_groups(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - hub.ListGroupsRequest, + hub.UpdateGroupRequest, dict, ], ) -def test_list_groups(request_type, transport: str = "grpc"): +def test_update_group(request_type, transport: str = "grpc"): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8086,27 +9160,22 @@ def test_list_groups(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + with mock.patch.object(type(client.transport.update_group), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = hub.ListGroupsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - response = client.list_groups(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = hub.ListGroupsRequest() + request = hub.UpdateGroupRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGroupsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, future.Future) -def test_list_groups_non_empty_request_with_auto_populated_field(): +def test_update_group_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = HubServiceClient( @@ -8117,30 +9186,24 @@ def test_list_groups_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = hub.ListGroupsRequest( - parent="parent_value", - page_token="page_token_value", - filter="filter_value", - order_by="order_by_value", + request = hub.UpdateGroupRequest( + request_id="request_id_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + with mock.patch.object(type(client.transport.update_group), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_groups(request=request) + client.update_group(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == hub.ListGroupsRequest( - parent="parent_value", - page_token="page_token_value", - filter="filter_value", - order_by="order_by_value", + assert args[0] == hub.UpdateGroupRequest( + request_id="request_id_value", ) -def test_list_groups_use_cached_wrapped_rpc(): +def test_update_group_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8154,21 +9217,26 @@ def test_list_groups_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_groups in client._transport._wrapped_methods + assert client._transport.update_group in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_groups] = mock_rpc + client._transport._wrapped_methods[client._transport.update_group] = mock_rpc request = {} - client.list_groups(request) + client.update_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_groups(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -8176,7 +9244,7 @@ def test_list_groups_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_groups_async_use_cached_wrapped_rpc( +async def test_update_group_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -8193,7 +9261,7 @@ async def test_list_groups_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.list_groups + client._client._transport.update_group in client._client._transport._wrapped_methods ) @@ -8201,16 +9269,21 @@ async def test_list_groups_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_groups + client._client._transport.update_group ] = mock_rpc request = {} - await client.list_groups(request) + await client.update_group(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_groups(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_group(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -8218,8 +9291,8 @@ async def test_list_groups_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_groups_async( - transport: str = "grpc_asyncio", request_type=hub.ListGroupsRequest +async def test_update_group_async( + transport: str = "grpc_asyncio", request_type=hub.UpdateGroupRequest ): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), @@ -8231,48 +9304,43 @@ async def test_list_groups_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: + with mock.patch.object(type(client.transport.update_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListGroupsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_groups(request) + response = await client.update_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = hub.ListGroupsRequest() + request = hub.UpdateGroupRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGroupsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_groups_async_from_dict(): - await test_list_groups_async(request_type=dict) +async def test_update_group_async_from_dict(): + await test_update_group_async(request_type=dict) -def test_list_groups_field_headers(): +def test_update_group_field_headers(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = hub.ListGroupsRequest() + request = hub.UpdateGroupRequest() - request.parent = "parent_value" + request.group.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - call.return_value = hub.ListGroupsResponse() - client.list_groups(request) + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_group(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -8283,316 +9351,132 @@ def test_list_groups_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "group.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_groups_field_headers_async(): +async def test_update_group_field_headers_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = hub.ListGroupsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListGroupsResponse() - ) - await client.list_groups(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] - - -def test_list_groups_flattened(): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = hub.ListGroupsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_groups( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -def test_list_groups_flattened_error(): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_groups( - hub.ListGroupsRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_groups_flattened_async(): - client = HubServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = hub.ListGroupsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - hub.ListGroupsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_groups( - parent="parent_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_list_groups_flattened_error_async(): - client = HubServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_groups( - hub.ListGroupsRequest(), - parent="parent_value", - ) - - -def test_list_groups_pager(transport_name: str = "grpc"): - client = HubServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - hub.Group(), - ], - next_page_token="abc", - ), - hub.ListGroupsResponse( - groups=[], - next_page_token="def", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - ], - next_page_token="ghi", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + # a field header. Set these to a non-empty value. + request = hub.UpdateGroupRequest() + + request.group.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - pager = client.list_groups(request={}, retry=retry, timeout=timeout) + await client.update_group(request) - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, hub.Group) for i in results) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "group.name=name_value", + ) in kw["metadata"] -def test_list_groups_pages(transport_name: str = "grpc"): +def test_update_group_flattened(): client = HubServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_groups), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - hub.Group(), - ], - next_page_token="abc", - ), - hub.ListGroupsResponse( - groups=[], - next_page_token="def", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - ], - next_page_token="ghi", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - ], - ), - RuntimeError, + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_group( + group=hub.Group(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].group + mock_val = hub.Group(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_group_flattened_error(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_group( + hub.UpdateGroupRequest(), + group=hub.Group(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - pages = list(client.list_groups(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_list_groups_async_pager(): +async def test_update_group_flattened_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_groups), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - hub.Group(), - ], - next_page_token="abc", - ), - hub.ListGroupsResponse( - groups=[], - next_page_token="def", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - ], - next_page_token="ghi", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - ], - ), - RuntimeError, + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") ) - async_pager = await client.list_groups( - request={}, + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_group( + group=hub.Group(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - assert len(responses) == 6 - assert all(isinstance(i, hub.Group) for i in responses) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].group + mock_val = hub.Group(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio -async def test_list_groups_async_pages(): +async def test_update_group_flattened_error_async(): client = HubServiceAsyncClient( credentials=async_anonymous_credentials(), ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_groups), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - hub.Group(), - ], - next_page_token="abc", - ), - hub.ListGroupsResponse( - groups=[], - next_page_token="def", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - ], - next_page_token="ghi", - ), - hub.ListGroupsResponse( - groups=[ - hub.Group(), - hub.Group(), - ], - ), - RuntimeError, + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_group( + hub.UpdateGroupRequest(), + group=hub.Group(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_groups(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token def test_credentials_transport_error(): @@ -8826,6 +9710,27 @@ def test_list_hub_spokes_empty_call_grpc(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_query_hub_status_empty_call_grpc(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: + call.return_value = hub.QueryHubStatusResponse() + client.query_hub_status(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = hub.QueryHubStatusRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_list_spokes_empty_call_grpc(): @@ -9101,6 +10006,27 @@ def test_list_groups_empty_call_grpc(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_group_empty_call_grpc(): + client = HubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = hub.UpdateGroupRequest() + + assert args[0] == request_msg + + def test_transport_kind_grpc_asyncio(): transport = HubServiceAsyncClient.get_transport_class("grpc_asyncio")( credentials=async_anonymous_credentials() @@ -9162,6 +10088,9 @@ async def test_get_hub_empty_call_grpc_asyncio(): unique_id="unique_id_value", state=hub.State.CREATING, route_tables=["route_tables_value"], + policy_mode=hub.PolicyMode.PRESET, + preset_topology=hub.PresetTopology.MESH, + export_psc=True, ) ) await client.get_hub(request=None) @@ -9277,6 +10206,33 @@ async def test_list_hub_spokes_empty_call_grpc_asyncio(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_query_hub_status_empty_call_grpc_asyncio(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.query_hub_status), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + hub.QueryHubStatusResponse( + next_page_token="next_page_token_value", + ) + ) + await client.query_hub_status(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = hub.QueryHubStatusRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @pytest.mark.asyncio @@ -9515,6 +10471,7 @@ async def test_get_route_empty_call_grpc_asyncio(): state=hub.State.CREATING, spoke="spoke_value", location="location_value", + priority=898, ) ) await client.get_route(request=None) @@ -9603,6 +10560,7 @@ async def test_get_group_empty_call_grpc_asyncio(): description="description_value", uid="uid_value", state=hub.State.CREATING, + route_table="route_table_value", ) ) await client.get_group(request=None) @@ -9643,6 +10601,31 @@ async def test_list_groups_empty_call_grpc_asyncio(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_group_empty_call_grpc_asyncio(): + client = HubServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_group(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = hub.UpdateGroupRequest() + + assert args[0] == request_msg + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = HubServiceClient( @@ -9682,6 +10665,7 @@ def test_hub_service_base_transport(): "update_hub", "delete_hub", "list_hub_spokes", + "query_hub_status", "list_spokes", "get_spoke", "create_spoke", @@ -9695,6 +10679,7 @@ def test_hub_service_base_transport(): "list_route_tables", "get_group", "list_groups", + "update_group", "set_iam_policy", "get_iam_policy", "test_iam_permissions", From a9d60f40dff04f6240dbc8ed46a284830de77ad3 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 17:52:03 +0500 Subject: [PATCH 03/16] feat: [google-cloud-managedkafka] Add support for opt-in debug logging (#13321) 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 feat: A new field `satisfies_pzi` is added to message `.google.cloud.managedkafka.v1.Cluster` feat: A new field `satisfies_pzs` is added to message `.google.cloud.managedkafka.v1.Cluster` 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1hbmFnZWRrYWZrYS8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT feat: [google-cloud-managedkafka] A new field `satisfies_pzi` is added to message `.google.cloud.managedkafka.v1.Cluster` feat: A new field `satisfies_pzs` is added to message `.google.cloud.managedkafka.v1.Cluster` PiperOrigin-RevId: 702413947 Source-Link: https://github.com/googleapis/googleapis/commit/b56dbf5a6a432199f4966be9a0f0a774fb47d606 Source-Link: https://github.com/googleapis/googleapis-gen/commit/52ade1274b90a4ded9eaba4de431a0a06965d99f Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1hbmFnZWRrYWZrYS8uT3dsQm90LnlhbWwiLCJoIjoiNTJhZGUxMjc0YjkwYTRkZWQ5ZWFiYTRkZTQzMWEwYTA2OTY1ZDk5ZiJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../cloud/managedkafka/gapic_version.py | 2 +- .../cloud/managedkafka_v1/gapic_version.py | 2 +- .../services/managed_kafka/async_client.py | 192 ++- .../services/managed_kafka/client.py | 197 ++- .../services/managed_kafka/pagers.py | 48 +- .../services/managed_kafka/transports/grpc.py | 134 +- .../managed_kafka/transports/grpc_asyncio.py | 131 +- .../services/managed_kafka/transports/rest.py | 1204 +++++++++++++++-- .../cloud/managedkafka_v1/types/resources.py | 18 + ...metadata_google.cloud.managedkafka.v1.json | 58 +- .../managedkafka_v1/test_managed_kafka.py | 100 ++ 11 files changed, 1770 insertions(+), 316 deletions(-) diff --git a/packages/google-cloud-managedkafka/google/cloud/managedkafka/gapic_version.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka/gapic_version.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.5" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/gapic_version.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/gapic_version.py index e9c4bb5650f3..558c8aab67c5 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/gapic_version.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.5" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/async_client.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/async_client.py index 9f995279adfd..5893a4d74cfa 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/async_client.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ManagedKafkaTransport from .transports.grpc_asyncio import ManagedKafkaGrpcAsyncIOTransport +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 ManagedKafkaAsyncClient: """The service that a client application uses to manage Apache @@ -268,6 +278,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.managedkafka_v1.ManagedKafkaAsyncClient`.", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "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.managedkafka.v1.ManagedKafka", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[managed_kafka.ListClustersRequest, dict]] = None, @@ -275,7 +307,7 @@ async def list_clusters( 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.ListClustersAsyncPager: r"""Lists the clusters in a given project and location. @@ -320,8 +352,10 @@ async def sample_list_clusters(): 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.managedkafka_v1.services.managed_kafka.pagers.ListClustersAsyncPager: @@ -396,7 +430,7 @@ async def get_cluster( 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]]] = (), ) -> resources.Cluster: r"""Returns the properties of a single cluster. @@ -439,8 +473,10 @@ async def sample_get_cluster(): 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.managedkafka_v1.types.Cluster: @@ -503,7 +539,7 @@ async def create_cluster( cluster_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new cluster in a given project and location. @@ -578,8 +614,10 @@ async def sample_create_cluster(): 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.api_core.operation_async.AsyncOperation: @@ -656,7 +694,7 @@ async def update_cluster( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the properties of a single cluster. @@ -719,8 +757,10 @@ async def sample_update_cluster(): 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.api_core.operation_async.AsyncOperation: @@ -796,7 +836,7 @@ async def delete_cluster( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single cluster. @@ -843,8 +883,10 @@ async def sample_delete_cluster(): 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.api_core.operation_async.AsyncOperation: @@ -923,7 +965,7 @@ async def list_topics( 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.ListTopicsAsyncPager: r"""Lists the topics in a given cluster. @@ -968,8 +1010,10 @@ async def sample_list_topics(): 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.managedkafka_v1.services.managed_kafka.pagers.ListTopicsAsyncPager: @@ -1044,7 +1088,7 @@ async def get_topic( 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]]] = (), ) -> resources.Topic: r"""Returns the properties of a single topic. @@ -1090,8 +1134,10 @@ async def sample_get_topic(): 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.managedkafka_v1.types.Topic: @@ -1152,7 +1198,7 @@ async def create_topic( topic_id: 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]]] = (), ) -> resources.Topic: r"""Creates a new topic in a given project and location. @@ -1218,8 +1264,10 @@ async def sample_create_topic(): 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.managedkafka_v1.types.Topic: @@ -1283,7 +1331,7 @@ async def update_topic( 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]]] = (), ) -> resources.Topic: r"""Updates the properties of a single topic. @@ -1341,8 +1389,10 @@ async def sample_update_topic(): 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.managedkafka_v1.types.Topic: @@ -1405,7 +1455,7 @@ async def delete_topic( 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 single topic. @@ -1445,8 +1495,10 @@ async def sample_delete_topic(): 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 @@ -1498,7 +1550,7 @@ async def list_consumer_groups( 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.ListConsumerGroupsAsyncPager: r"""Lists the consumer groups in a given cluster. @@ -1543,8 +1595,10 @@ async def sample_list_consumer_groups(): 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.managedkafka_v1.services.managed_kafka.pagers.ListConsumerGroupsAsyncPager: @@ -1619,7 +1673,7 @@ async def get_consumer_group( 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]]] = (), ) -> resources.ConsumerGroup: r"""Returns the properties of a single consumer group. @@ -1663,8 +1717,10 @@ async def sample_get_consumer_group(): 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.managedkafka_v1.types.ConsumerGroup: @@ -1726,7 +1782,7 @@ async def update_consumer_group( 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]]] = (), ) -> resources.ConsumerGroup: r"""Updates the properties of a single consumer group. @@ -1779,8 +1835,10 @@ async def sample_update_consumer_group(): 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.managedkafka_v1.types.ConsumerGroup: @@ -1845,7 +1903,7 @@ async def delete_consumer_group( 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 single consumer group. @@ -1885,8 +1943,10 @@ async def sample_delete_consumer_group(): 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 @@ -1937,7 +1997,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1948,8 +2008,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1990,7 +2052,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2001,8 +2063,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2043,7 +2107,7 @@ async def delete_operation( *, 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 long-running operation. @@ -2059,8 +2123,10 @@ async def delete_operation( 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: None """ @@ -2097,7 +2163,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2112,8 +2178,10 @@ async def cancel_operation( 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: None """ @@ -2150,7 +2218,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. @@ -2161,8 +2229,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. @@ -2203,7 +2273,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. @@ -2214,8 +2284,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-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/client.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/client.py index 231a9ffb953b..a0dc8fcefc11 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/client.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -658,6 +668,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( @@ -720,6 +734,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.managedkafka_v1.ManagedKafkaClient`.", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "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.managedkafka.v1.ManagedKafka", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[managed_kafka.ListClustersRequest, dict]] = None, @@ -727,7 +764,7 @@ def list_clusters( 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.ListClustersPager: r"""Lists the clusters in a given project and location. @@ -772,8 +809,10 @@ def sample_list_clusters(): 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.managedkafka_v1.services.managed_kafka.pagers.ListClustersPager: @@ -845,7 +884,7 @@ def get_cluster( 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]]] = (), ) -> resources.Cluster: r"""Returns the properties of a single cluster. @@ -888,8 +927,10 @@ def sample_get_cluster(): 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.managedkafka_v1.types.Cluster: @@ -949,7 +990,7 @@ def create_cluster( cluster_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new cluster in a given project and location. @@ -1024,8 +1065,10 @@ def sample_create_cluster(): 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.api_core.operation.Operation: @@ -1099,7 +1142,7 @@ def update_cluster( 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]]] = (), ) -> operation.Operation: r"""Updates the properties of a single cluster. @@ -1162,8 +1205,10 @@ def sample_update_cluster(): 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.api_core.operation.Operation: @@ -1236,7 +1281,7 @@ def delete_cluster( 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]]] = (), ) -> operation.Operation: r"""Deletes a single cluster. @@ -1283,8 +1328,10 @@ def sample_delete_cluster(): 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.api_core.operation.Operation: @@ -1360,7 +1407,7 @@ def list_topics( 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.ListTopicsPager: r"""Lists the topics in a given cluster. @@ -1405,8 +1452,10 @@ def sample_list_topics(): 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.managedkafka_v1.services.managed_kafka.pagers.ListTopicsPager: @@ -1478,7 +1527,7 @@ def get_topic( 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]]] = (), ) -> resources.Topic: r"""Returns the properties of a single topic. @@ -1524,8 +1573,10 @@ def sample_get_topic(): 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.managedkafka_v1.types.Topic: @@ -1583,7 +1634,7 @@ def create_topic( topic_id: 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]]] = (), ) -> resources.Topic: r"""Creates a new topic in a given project and location. @@ -1649,8 +1700,10 @@ def sample_create_topic(): 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.managedkafka_v1.types.Topic: @@ -1711,7 +1764,7 @@ def update_topic( 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]]] = (), ) -> resources.Topic: r"""Updates the properties of a single topic. @@ -1769,8 +1822,10 @@ def sample_update_topic(): 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.managedkafka_v1.types.Topic: @@ -1830,7 +1885,7 @@ def delete_topic( 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 single topic. @@ -1870,8 +1925,10 @@ def sample_delete_topic(): 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 @@ -1920,7 +1977,7 @@ def list_consumer_groups( 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.ListConsumerGroupsPager: r"""Lists the consumer groups in a given cluster. @@ -1965,8 +2022,10 @@ def sample_list_consumer_groups(): 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.managedkafka_v1.services.managed_kafka.pagers.ListConsumerGroupsPager: @@ -2038,7 +2097,7 @@ def get_consumer_group( 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]]] = (), ) -> resources.ConsumerGroup: r"""Returns the properties of a single consumer group. @@ -2082,8 +2141,10 @@ def sample_get_consumer_group(): 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.managedkafka_v1.types.ConsumerGroup: @@ -2142,7 +2203,7 @@ def update_consumer_group( 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]]] = (), ) -> resources.ConsumerGroup: r"""Updates the properties of a single consumer group. @@ -2195,8 +2256,10 @@ def sample_update_consumer_group(): 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.managedkafka_v1.types.ConsumerGroup: @@ -2258,7 +2321,7 @@ def delete_consumer_group( 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 single consumer group. @@ -2298,8 +2361,10 @@ def sample_delete_consumer_group(): 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 @@ -2360,7 +2425,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2371,8 +2436,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2413,7 +2480,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2424,8 +2491,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2466,7 +2535,7 @@ def delete_operation( *, 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 long-running operation. @@ -2482,8 +2551,10 @@ def delete_operation( 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: None """ @@ -2520,7 +2591,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2535,8 +2606,10 @@ def cancel_operation( 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: None """ @@ -2573,7 +2646,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. @@ -2584,8 +2657,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. @@ -2626,7 +2701,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. @@ -2637,8 +2712,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-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/pagers.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/pagers.py index 431365dd1e61..88ecdce9db87 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/pagers.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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 = managed_kafka.ListClustersRequest(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 = managed_kafka.ListClustersRequest(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 = managed_kafka.ListTopicsRequest(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 = managed_kafka.ListTopicsRequest(request) @@ -371,7 +379,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. @@ -385,8 +393,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 = managed_kafka.ListConsumerGroupsRequest(request) @@ -445,7 +455,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. @@ -459,8 +469,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 = managed_kafka.ListConsumerGroupsRequest(request) diff --git a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc.py index 518ecc114768..a39e31ea2972 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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 @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.managedkafka_v1.types import managed_kafka, resources from .base import DEFAULT_CLIENT_INFO, ManagedKafkaTransport +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.managedkafka.v1.ManagedKafka", + "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.managedkafka.v1.ManagedKafka", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ManagedKafkaGrpcTransport(ManagedKafkaTransport): """gRPC backend transport for ManagedKafka. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListClusters", request_serializer=managed_kafka.ListClustersRequest.serialize, response_deserializer=managed_kafka.ListClustersResponse.deserialize, @@ -300,7 +388,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetCluster", request_serializer=managed_kafka.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -327,7 +415,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/CreateCluster", request_serializer=managed_kafka.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateCluster", request_serializer=managed_kafka.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteCluster", request_serializer=managed_kafka.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def list_topics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_topics" not in self._stubs: - self._stubs["list_topics"] = self.grpc_channel.unary_unary( + self._stubs["list_topics"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListTopics", request_serializer=managed_kafka.ListTopicsRequest.serialize, response_deserializer=managed_kafka.ListTopicsResponse.deserialize, @@ -429,7 +517,7 @@ def get_topic(self) -> Callable[[managed_kafka.GetTopicRequest], resources.Topic # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_topic" not in self._stubs: - self._stubs["get_topic"] = self.grpc_channel.unary_unary( + self._stubs["get_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetTopic", request_serializer=managed_kafka.GetTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -455,7 +543,7 @@ def create_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_topic" not in self._stubs: - self._stubs["create_topic"] = self.grpc_channel.unary_unary( + self._stubs["create_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/CreateTopic", request_serializer=managed_kafka.CreateTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -481,7 +569,7 @@ def update_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_topic" not in self._stubs: - self._stubs["update_topic"] = self.grpc_channel.unary_unary( + self._stubs["update_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateTopic", request_serializer=managed_kafka.UpdateTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -507,7 +595,7 @@ def delete_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_topic" not in self._stubs: - self._stubs["delete_topic"] = self.grpc_channel.unary_unary( + self._stubs["delete_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteTopic", request_serializer=managed_kafka.DeleteTopicRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -536,7 +624,7 @@ def list_consumer_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_consumer_groups" not in self._stubs: - self._stubs["list_consumer_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_consumer_groups"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListConsumerGroups", request_serializer=managed_kafka.ListConsumerGroupsRequest.serialize, response_deserializer=managed_kafka.ListConsumerGroupsResponse.deserialize, @@ -562,7 +650,7 @@ def get_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_consumer_group" not in self._stubs: - self._stubs["get_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["get_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetConsumerGroup", request_serializer=managed_kafka.GetConsumerGroupRequest.serialize, response_deserializer=resources.ConsumerGroup.deserialize, @@ -588,7 +676,7 @@ def update_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_consumer_group" not in self._stubs: - self._stubs["update_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["update_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateConsumerGroup", request_serializer=managed_kafka.UpdateConsumerGroupRequest.serialize, response_deserializer=resources.ConsumerGroup.deserialize, @@ -614,7 +702,7 @@ def delete_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_consumer_group" not in self._stubs: - self._stubs["delete_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteConsumerGroup", request_serializer=managed_kafka.DeleteConsumerGroupRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -622,7 +710,7 @@ def delete_consumer_group( return self._stubs["delete_consumer_group"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -634,7 +722,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -651,7 +739,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -668,7 +756,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -687,7 +775,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -706,7 +794,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, @@ -723,7 +811,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-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc_asyncio.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc_asyncio.py index cab6a6008b5c..6a6b8bde8a1d 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/grpc_asyncio.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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 @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.managedkafka_v1.types import managed_kafka, resources from .base import DEFAULT_CLIENT_INFO, ManagedKafkaTransport from .grpc import ManagedKafkaGrpcTransport +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.managedkafka.v1.ManagedKafka", + "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.managedkafka.v1.ManagedKafka", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ManagedKafkaGrpcAsyncIOTransport(ManagedKafkaTransport): """gRPC AsyncIO backend transport for ManagedKafka. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListClusters", request_serializer=managed_kafka.ListClustersRequest.serialize, response_deserializer=managed_kafka.ListClustersResponse.deserialize, @@ -311,7 +396,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetCluster", request_serializer=managed_kafka.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -340,7 +425,7 @@ def create_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cluster" not in self._stubs: - self._stubs["create_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/CreateCluster", request_serializer=managed_kafka.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +453,7 @@ def update_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cluster" not in self._stubs: - self._stubs["update_cluster"] = self.grpc_channel.unary_unary( + self._stubs["update_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateCluster", request_serializer=managed_kafka.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -396,7 +481,7 @@ def delete_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cluster" not in self._stubs: - self._stubs["delete_cluster"] = self.grpc_channel.unary_unary( + self._stubs["delete_cluster"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteCluster", request_serializer=managed_kafka.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -424,7 +509,7 @@ def list_topics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_topics" not in self._stubs: - self._stubs["list_topics"] = self.grpc_channel.unary_unary( + self._stubs["list_topics"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListTopics", request_serializer=managed_kafka.ListTopicsRequest.serialize, response_deserializer=managed_kafka.ListTopicsResponse.deserialize, @@ -450,7 +535,7 @@ def get_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_topic" not in self._stubs: - self._stubs["get_topic"] = self.grpc_channel.unary_unary( + self._stubs["get_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetTopic", request_serializer=managed_kafka.GetTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -476,7 +561,7 @@ def create_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_topic" not in self._stubs: - self._stubs["create_topic"] = self.grpc_channel.unary_unary( + self._stubs["create_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/CreateTopic", request_serializer=managed_kafka.CreateTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -502,7 +587,7 @@ def update_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_topic" not in self._stubs: - self._stubs["update_topic"] = self.grpc_channel.unary_unary( + self._stubs["update_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateTopic", request_serializer=managed_kafka.UpdateTopicRequest.serialize, response_deserializer=resources.Topic.deserialize, @@ -528,7 +613,7 @@ def delete_topic( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_topic" not in self._stubs: - self._stubs["delete_topic"] = self.grpc_channel.unary_unary( + self._stubs["delete_topic"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteTopic", request_serializer=managed_kafka.DeleteTopicRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -557,7 +642,7 @@ def list_consumer_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_consumer_groups" not in self._stubs: - self._stubs["list_consumer_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_consumer_groups"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/ListConsumerGroups", request_serializer=managed_kafka.ListConsumerGroupsRequest.serialize, response_deserializer=managed_kafka.ListConsumerGroupsResponse.deserialize, @@ -585,7 +670,7 @@ def get_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_consumer_group" not in self._stubs: - self._stubs["get_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["get_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/GetConsumerGroup", request_serializer=managed_kafka.GetConsumerGroupRequest.serialize, response_deserializer=resources.ConsumerGroup.deserialize, @@ -613,7 +698,7 @@ def update_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_consumer_group" not in self._stubs: - self._stubs["update_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["update_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/UpdateConsumerGroup", request_serializer=managed_kafka.UpdateConsumerGroupRequest.serialize, response_deserializer=resources.ConsumerGroup.deserialize, @@ -641,7 +726,7 @@ def delete_consumer_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_consumer_group" not in self._stubs: - self._stubs["delete_consumer_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_consumer_group"] = self._logged_channel.unary_unary( "/google.cloud.managedkafka.v1.ManagedKafka/DeleteConsumerGroup", request_serializer=managed_kafka.DeleteConsumerGroupRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -813,7 +898,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: @@ -829,7 +914,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -846,7 +931,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -863,7 +948,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -882,7 +967,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -901,7 +986,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, @@ -918,7 +1003,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-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/rest.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/rest.py index 4896d572ed04..04cf0f0bfb5a 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/transports/rest.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/services/managed_kafka/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 @@ -40,6 +40,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, @@ -176,8 +184,10 @@ def post_update_topic(self, response): def pre_create_cluster( self, request: managed_kafka.CreateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.CreateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -199,8 +209,10 @@ def post_create_cluster( def pre_create_topic( self, request: managed_kafka.CreateTopicRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.CreateTopicRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.CreateTopicRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_topic Override in a subclass to manipulate the request or metadata @@ -220,8 +232,10 @@ def post_create_topic(self, response: resources.Topic) -> resources.Topic: def pre_delete_cluster( self, request: managed_kafka.DeleteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -243,8 +257,11 @@ def post_delete_cluster( def pre_delete_consumer_group( self, request: managed_kafka.DeleteConsumerGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.DeleteConsumerGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.DeleteConsumerGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_consumer_group Override in a subclass to manipulate the request or metadata @@ -255,8 +272,10 @@ def pre_delete_consumer_group( def pre_delete_topic( self, request: managed_kafka.DeleteTopicRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.DeleteTopicRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.DeleteTopicRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_topic Override in a subclass to manipulate the request or metadata @@ -267,8 +286,10 @@ def pre_delete_topic( def pre_get_cluster( self, request: managed_kafka.GetClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.GetClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -288,8 +309,10 @@ def post_get_cluster(self, response: resources.Cluster) -> resources.Cluster: def pre_get_consumer_group( self, request: managed_kafka.GetConsumerGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.GetConsumerGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.GetConsumerGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_consumer_group Override in a subclass to manipulate the request or metadata @@ -311,8 +334,8 @@ def post_get_consumer_group( def pre_get_topic( self, request: managed_kafka.GetTopicRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.GetTopicRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[managed_kafka.GetTopicRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_topic Override in a subclass to manipulate the request or metadata @@ -332,8 +355,10 @@ def post_get_topic(self, response: resources.Topic) -> resources.Topic: def pre_list_clusters( self, request: managed_kafka.ListClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.ListClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -355,8 +380,10 @@ def post_list_clusters( def pre_list_consumer_groups( self, request: managed_kafka.ListConsumerGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.ListConsumerGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.ListConsumerGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_consumer_groups Override in a subclass to manipulate the request or metadata @@ -378,8 +405,10 @@ def post_list_consumer_groups( def pre_list_topics( self, request: managed_kafka.ListTopicsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.ListTopicsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.ListTopicsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_topics Override in a subclass to manipulate the request or metadata @@ -401,8 +430,10 @@ def post_list_topics( def pre_update_cluster( self, request: managed_kafka.UpdateClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -424,8 +455,11 @@ def post_update_cluster( def pre_update_consumer_group( self, request: managed_kafka.UpdateConsumerGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.UpdateConsumerGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.UpdateConsumerGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_consumer_group Override in a subclass to manipulate the request or metadata @@ -447,8 +481,10 @@ def post_update_consumer_group( def pre_update_topic( self, request: managed_kafka.UpdateTopicRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[managed_kafka.UpdateTopicRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + managed_kafka.UpdateTopicRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_topic Override in a subclass to manipulate the request or metadata @@ -468,8 +504,10 @@ def post_update_topic(self, response: resources.Topic) -> resources.Topic: 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 @@ -491,8 +529,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 @@ -514,8 +554,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -535,8 +577,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -556,8 +600,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -579,8 +625,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -776,7 +824,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -786,8 +834,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: ~.operations_pb2.Operation: @@ -800,6 +850,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -814,6 +865,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.managedkafka_v1.ManagedKafkaClient.CreateCluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._CreateCluster._get_response( self._host, @@ -833,7 +911,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cluster(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.managedkafka_v1.ManagedKafkaClient.create_cluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTopic( @@ -871,7 +971,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]]] = (), ) -> resources.Topic: r"""Call the create topic method over HTTP. @@ -881,8 +981,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: ~.resources.Topic: @@ -892,6 +994,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseCreateTopic._get_http_options() ) + request, metadata = self._interceptor.pre_create_topic(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseCreateTopic._get_transcoded_request( @@ -912,6 +1015,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.managedkafka_v1.ManagedKafkaClient.CreateTopic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "CreateTopic", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._CreateTopic._get_response( self._host, @@ -933,7 +1063,29 @@ def __call__( pb_resp = resources.Topic.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_topic(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Topic.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.managedkafka_v1.ManagedKafkaClient.create_topic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "CreateTopic", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -970,7 +1122,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -980,8 +1132,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: ~.operations_pb2.Operation: @@ -994,6 +1148,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -1004,6 +1159,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.managedkafka_v1.ManagedKafkaClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._DeleteCluster._get_response( self._host, @@ -1022,7 +1204,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cluster(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.managedkafka_v1.ManagedKafkaClient.delete_cluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConsumerGroup( @@ -1059,7 +1263,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 consumer group method over HTTP. @@ -1069,13 +1273,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 = ( _BaseManagedKafkaRestTransport._BaseDeleteConsumerGroup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_consumer_group( request, metadata ) @@ -1088,6 +1295,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.managedkafka_v1.ManagedKafkaClient.DeleteConsumerGroup", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "DeleteConsumerGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._DeleteConsumerGroup._get_response( self._host, @@ -1137,7 +1371,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 topic method over HTTP. @@ -1147,13 +1381,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 = ( _BaseManagedKafkaRestTransport._BaseDeleteTopic._get_http_options() ) + request, metadata = self._interceptor.pre_delete_topic(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseDeleteTopic._get_transcoded_request( @@ -1168,6 +1405,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.managedkafka_v1.ManagedKafkaClient.DeleteTopic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "DeleteTopic", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._DeleteTopic._get_response( self._host, @@ -1217,7 +1481,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]]] = (), ) -> resources.Cluster: r"""Call the get cluster method over HTTP. @@ -1227,8 +1491,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: ~.resources.Cluster: @@ -1240,6 +1506,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseGetCluster._get_transcoded_request( @@ -1254,6 +1521,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.managedkafka_v1.ManagedKafkaClient.GetCluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._GetCluster._get_response( self._host, @@ -1274,7 +1568,29 @@ def __call__( pb_resp = resources.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Cluster.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.managedkafka_v1.ManagedKafkaClient.get_cluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConsumerGroup( @@ -1311,7 +1627,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]]] = (), ) -> resources.ConsumerGroup: r"""Call the get consumer group method over HTTP. @@ -1321,8 +1637,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: ~.resources.ConsumerGroup: @@ -1334,6 +1652,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseGetConsumerGroup._get_http_options() ) + request, metadata = self._interceptor.pre_get_consumer_group( request, metadata ) @@ -1346,6 +1665,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 = 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.managedkafka_v1.ManagedKafkaClient.GetConsumerGroup", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetConsumerGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._GetConsumerGroup._get_response( self._host, @@ -1366,7 +1712,29 @@ def __call__( pb_resp = resources.ConsumerGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_consumer_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConsumerGroup.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.managedkafka_v1.ManagedKafkaClient.get_consumer_group", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetConsumerGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTopic(_BaseManagedKafkaRestTransport._BaseGetTopic, ManagedKafkaRestStub): @@ -1401,7 +1769,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]]] = (), ) -> resources.Topic: r"""Call the get topic method over HTTP. @@ -1411,8 +1779,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: ~.resources.Topic: @@ -1422,6 +1792,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseGetTopic._get_http_options() ) + request, metadata = self._interceptor.pre_get_topic(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseGetTopic._get_transcoded_request( @@ -1436,6 +1807,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.managedkafka_v1.ManagedKafkaClient.GetTopic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetTopic", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._GetTopic._get_response( self._host, @@ -1456,7 +1854,29 @@ def __call__( pb_resp = resources.Topic.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_topic(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Topic.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.managedkafka_v1.ManagedKafkaClient.get_topic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetTopic", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -1493,7 +1913,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]]] = (), ) -> managed_kafka.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -1503,8 +1923,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: ~.managed_kafka.ListClustersResponse: @@ -1514,6 +1936,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -1526,6 +1949,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.managedkafka_v1.ManagedKafkaClient.ListClusters", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._ListClusters._get_response( self._host, @@ -1546,7 +1996,31 @@ def __call__( pb_resp = managed_kafka.ListClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = managed_kafka.ListClustersResponse.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.managedkafka_v1.ManagedKafkaClient.list_clusters", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConsumerGroups( @@ -1583,7 +2057,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]]] = (), ) -> managed_kafka.ListConsumerGroupsResponse: r"""Call the list consumer groups method over HTTP. @@ -1593,8 +2067,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: ~.managed_kafka.ListConsumerGroupsResponse: @@ -1604,6 +2080,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseListConsumerGroups._get_http_options() ) + request, metadata = self._interceptor.pre_list_consumer_groups( request, metadata ) @@ -1616,6 +2093,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 = 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.managedkafka_v1.ManagedKafkaClient.ListConsumerGroups", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListConsumerGroups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._ListConsumerGroups._get_response( self._host, @@ -1636,7 +2140,31 @@ def __call__( pb_resp = managed_kafka.ListConsumerGroupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_consumer_groups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = managed_kafka.ListConsumerGroupsResponse.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.managedkafka_v1.ManagedKafkaClient.list_consumer_groups", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListConsumerGroups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTopics( @@ -1673,7 +2201,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]]] = (), ) -> managed_kafka.ListTopicsResponse: r"""Call the list topics method over HTTP. @@ -1683,8 +2211,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: ~.managed_kafka.ListTopicsResponse: @@ -1694,6 +2224,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseListTopics._get_http_options() ) + request, metadata = self._interceptor.pre_list_topics(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseListTopics._get_transcoded_request( @@ -1708,6 +2239,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.managedkafka_v1.ManagedKafkaClient.ListTopics", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListTopics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._ListTopics._get_response( self._host, @@ -1728,7 +2286,31 @@ def __call__( pb_resp = managed_kafka.ListTopicsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_topics(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = managed_kafka.ListTopicsResponse.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.managedkafka_v1.ManagedKafkaClient.list_topics", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListTopics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -1766,7 +2348,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -1776,8 +2358,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: ~.operations_pb2.Operation: @@ -1790,6 +2374,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -1804,6 +2389,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.managedkafka_v1.ManagedKafkaClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._UpdateCluster._get_response( self._host, @@ -1823,7 +2435,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cluster(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.managedkafka_v1.ManagedKafkaClient.update_cluster", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConsumerGroup( @@ -1861,7 +2495,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]]] = (), ) -> resources.ConsumerGroup: r"""Call the update consumer group method over HTTP. @@ -1871,8 +2505,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: ~.resources.ConsumerGroup: @@ -1884,6 +2520,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseUpdateConsumerGroup._get_http_options() ) + request, metadata = self._interceptor.pre_update_consumer_group( request, metadata ) @@ -1900,6 +2537,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 = 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.managedkafka_v1.ManagedKafkaClient.UpdateConsumerGroup", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateConsumerGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._UpdateConsumerGroup._get_response( self._host, @@ -1921,7 +2585,29 @@ def __call__( pb_resp = resources.ConsumerGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_consumer_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConsumerGroup.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.managedkafka_v1.ManagedKafkaClient.update_consumer_group", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateConsumerGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTopic( @@ -1959,7 +2645,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]]] = (), ) -> resources.Topic: r"""Call the update topic method over HTTP. @@ -1969,8 +2655,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: ~.resources.Topic: @@ -1980,6 +2668,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseUpdateTopic._get_http_options() ) + request, metadata = self._interceptor.pre_update_topic(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseUpdateTopic._get_transcoded_request( @@ -2000,6 +2689,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.managedkafka_v1.ManagedKafkaClient.UpdateTopic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateTopic", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._UpdateTopic._get_response( self._host, @@ -2021,7 +2737,29 @@ def __call__( pb_resp = resources.Topic.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_topic(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Topic.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.managedkafka_v1.ManagedKafkaClient.update_topic", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "UpdateTopic", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2177,7 +2915,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. @@ -2187,8 +2925,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. @@ -2197,6 +2937,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseManagedKafkaRestTransport._BaseGetLocation._get_transcoded_request( @@ -2211,6 +2952,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.managedkafka_v1.ManagedKafkaClient.GetLocation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._GetLocation._get_response( self._host, @@ -2230,6 +2998,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.managedkafka_v1.ManagedKafkaAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2270,7 +3059,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. @@ -2280,8 +3069,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. @@ -2290,6 +3081,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2300,6 +3092,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.managedkafka_v1.ManagedKafkaClient.ListLocations", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._ListLocations._get_response( self._host, @@ -2319,6 +3138,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.managedkafka_v1.ManagedKafkaAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2360,7 +3200,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2370,13 +3210,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 = ( _BaseManagedKafkaRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2393,6 +3236,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.managedkafka_v1.ManagedKafkaClient.CancelOperation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._CancelOperation._get_response( self._host, @@ -2449,7 +3319,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -2459,13 +3329,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 = ( _BaseManagedKafkaRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -2478,6 +3351,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.managedkafka_v1.ManagedKafkaClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._DeleteOperation._get_response( self._host, @@ -2533,7 +3433,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2543,8 +3443,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: operations_pb2.Operation: Response from GetOperation method. @@ -2553,6 +3455,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2565,6 +3468,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.managedkafka_v1.ManagedKafkaClient.GetOperation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._GetOperation._get_response( self._host, @@ -2584,6 +3514,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.managedkafka_v1.ManagedKafkaAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2624,7 +3575,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2634,8 +3585,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2644,6 +3597,7 @@ def __call__( http_options = ( _BaseManagedKafkaRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseManagedKafkaRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2654,6 +3608,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.managedkafka_v1.ManagedKafkaClient.ListOperations", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ManagedKafkaRestTransport._ListOperations._get_response( self._host, @@ -2673,6 +3654,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.managedkafka_v1.ManagedKafkaAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.managedkafka.v1.ManagedKafka", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/types/resources.py b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/types/resources.py index ae837b7a76d3..a6550423cf7d 100644 --- a/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/types/resources.py +++ b/packages/google-cloud-managedkafka/google/cloud/managedkafka_v1/types/resources.py @@ -69,6 +69,14 @@ class Cluster(proto.Message): state (google.cloud.managedkafka_v1.types.Cluster.State): Output only. The current state of the cluster. + satisfies_pzi (bool): + Output only. Reserved for future use. + + This field is a member of `oneof`_ ``_satisfies_pzi``. + satisfies_pzs (bool): + Output only. Reserved for future use. + + This field is a member of `oneof`_ ``_satisfies_pzs``. """ class State(proto.Enum): @@ -129,6 +137,16 @@ class State(proto.Enum): number=10, enum=State, ) + satisfies_pzi: bool = proto.Field( + proto.BOOL, + number=11, + optional=True, + ) + satisfies_pzs: bool = proto.Field( + proto.BOOL, + number=12, + optional=True, + ) class CapacityConfig(proto.Message): diff --git a/packages/google-cloud-managedkafka/samples/generated_samples/snippet_metadata_google.cloud.managedkafka.v1.json b/packages/google-cloud-managedkafka/samples/generated_samples/snippet_metadata_google.cloud.managedkafka.v1.json index f059e2f37f26..6bf6d88a21db 100644 --- a/packages/google-cloud-managedkafka/samples/generated_samples/snippet_metadata_google.cloud.managedkafka.v1.json +++ b/packages/google-cloud-managedkafka/samples/generated_samples/snippet_metadata_google.cloud.managedkafka.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-managedkafka", - "version": "0.1.5" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_consumer_group" @@ -639,7 +639,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_consumer_group" @@ -717,7 +717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_topic" @@ -794,7 +794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_topic" @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Cluster", @@ -952,7 +952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Cluster", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.ConsumerGroup", @@ -1113,7 +1113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.ConsumerGroup", @@ -1194,7 +1194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", @@ -1274,7 +1274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", @@ -1355,7 +1355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListClustersAsyncPager", @@ -1435,7 +1435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListClustersPager", @@ -1516,7 +1516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListConsumerGroupsAsyncPager", @@ -1596,7 +1596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListConsumerGroupsPager", @@ -1677,7 +1677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListTopicsAsyncPager", @@ -1757,7 +1757,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.services.managed_kafka.pagers.ListTopicsPager", @@ -1842,7 +1842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1926,7 +1926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2011,7 +2011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.ConsumerGroup", @@ -2095,7 +2095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.ConsumerGroup", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", @@ -2264,7 +2264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.managedkafka_v1.types.Topic", diff --git a/packages/google-cloud-managedkafka/tests/unit/gapic/managedkafka_v1/test_managed_kafka.py b/packages/google-cloud-managedkafka/tests/unit/gapic/managedkafka_v1/test_managed_kafka.py index bc47546d1c2d..1d21974d4df8 100644 --- a/packages/google-cloud-managedkafka/tests/unit/gapic/managedkafka_v1/test_managed_kafka.py +++ b/packages/google-cloud-managedkafka/tests/unit/gapic/managedkafka_v1/test_managed_kafka.py @@ -1601,6 +1601,8 @@ def test_get_cluster(request_type, transport: str = "grpc"): call.return_value = resources.Cluster( name="name_value", state=resources.Cluster.State.CREATING, + satisfies_pzi=True, + satisfies_pzs=True, ) response = client.get_cluster(request) @@ -1614,6 +1616,8 @@ def test_get_cluster(request_type, transport: str = "grpc"): assert isinstance(response, resources.Cluster) assert response.name == "name_value" assert response.state == resources.Cluster.State.CREATING + assert response.satisfies_pzi is True + assert response.satisfies_pzs is True def test_get_cluster_non_empty_request_with_auto_populated_field(): @@ -1741,6 +1745,8 @@ async def test_get_cluster_async( resources.Cluster( name="name_value", state=resources.Cluster.State.CREATING, + satisfies_pzi=True, + satisfies_pzs=True, ) ) response = await client.get_cluster(request) @@ -1755,6 +1761,8 @@ async def test_get_cluster_async( assert isinstance(response, resources.Cluster) assert response.name == "name_value" assert response.state == resources.Cluster.State.CREATING + assert response.satisfies_pzi is True + assert response.satisfies_pzs is True @pytest.mark.asyncio @@ -6497,6 +6505,7 @@ def test_list_clusters_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.list_clusters(request) @@ -6552,6 +6561,7 @@ def test_list_clusters_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_clusters(**mock_args) @@ -6743,6 +6753,7 @@ def test_get_cluster_rest_required_fields(request_type=managed_kafka.GetClusterR 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_cluster(request) @@ -6788,6 +6799,7 @@ def test_get_cluster_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_cluster(**mock_args) @@ -6934,6 +6946,7 @@ def test_create_cluster_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.create_cluster(request) @@ -7005,6 +7018,7 @@ def test_create_cluster_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_cluster(**mock_args) @@ -7147,6 +7161,7 @@ def test_update_cluster_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.update_cluster(request) @@ -7212,6 +7227,7 @@ def test_update_cluster_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_cluster(**mock_args) @@ -7353,6 +7369,7 @@ def test_delete_cluster_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.delete_cluster(request) @@ -7396,6 +7413,7 @@ def test_delete_cluster_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.delete_cluster(**mock_args) @@ -7531,6 +7549,7 @@ def test_list_topics_rest_required_fields(request_type=managed_kafka.ListTopicsR 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_topics(request) @@ -7586,6 +7605,7 @@ def test_list_topics_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_topics(**mock_args) @@ -7778,6 +7798,7 @@ def test_get_topic_rest_required_fields(request_type=managed_kafka.GetTopicReque 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_topic(request) @@ -7825,6 +7846,7 @@ def test_get_topic_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_topic(**mock_args) @@ -7966,6 +7988,7 @@ def test_create_topic_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.create_topic(request) @@ -8030,6 +8053,7 @@ def test_create_topic_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_topic(**mock_args) @@ -8161,6 +8185,7 @@ def test_update_topic_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.update_topic(request) @@ -8219,6 +8244,7 @@ def test_update_topic_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_topic(**mock_args) @@ -8348,6 +8374,7 @@ def test_delete_topic_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.delete_topic(request) @@ -8393,6 +8420,7 @@ def test_delete_topic_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_topic(**mock_args) @@ -8535,6 +8563,7 @@ def test_list_consumer_groups_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.list_consumer_groups(request) @@ -8590,6 +8619,7 @@ def test_list_consumer_groups_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_consumer_groups(**mock_args) @@ -8790,6 +8820,7 @@ def test_get_consumer_group_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_consumer_group(request) @@ -8837,6 +8868,7 @@ def test_get_consumer_group_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_consumer_group(**mock_args) @@ -8971,6 +9003,7 @@ def test_update_consumer_group_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.update_consumer_group(request) @@ -9029,6 +9062,7 @@ def test_update_consumer_group_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_consumer_group(**mock_args) @@ -9163,6 +9197,7 @@ def test_delete_consumer_group_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.delete_consumer_group(request) @@ -9208,6 +9243,7 @@ def test_delete_consumer_group_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_consumer_group(**mock_args) @@ -9703,6 +9739,8 @@ async def test_get_cluster_empty_call_grpc_asyncio(): resources.Cluster( name="name_value", state=resources.Cluster.State.CREATING, + satisfies_pzi=True, + satisfies_pzs=True, ) ) await client.get_cluster(request=None) @@ -10065,6 +10103,7 @@ def test_list_clusters_rest_bad_request(request_type=managed_kafka.ListClustersR 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_clusters(request) @@ -10101,6 +10140,7 @@ def test_list_clusters_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_clusters(request) # Establish that the response is the type that we expect. @@ -10142,6 +10182,7 @@ def test_list_clusters_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 = managed_kafka.ListClustersResponse.to_json( managed_kafka.ListClustersResponse() ) @@ -10186,6 +10227,7 @@ def test_get_cluster_rest_bad_request(request_type=managed_kafka.GetClusterReque 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_cluster(request) @@ -10211,6 +10253,8 @@ def test_get_cluster_rest_call_success(request_type): return_value = resources.Cluster( name="name_value", state=resources.Cluster.State.CREATING, + satisfies_pzi=True, + satisfies_pzs=True, ) # Wrap the value into a proper Response obj @@ -10222,12 +10266,15 @@ def test_get_cluster_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_cluster(request) # Establish that the response is the type that we expect. assert isinstance(response, resources.Cluster) assert response.name == "name_value" assert response.state == resources.Cluster.State.CREATING + assert response.satisfies_pzi is True + assert response.satisfies_pzs is True @pytest.mark.parametrize("null_interceptor", [True, False]) @@ -10263,6 +10310,7 @@ def test_get_cluster_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 = resources.Cluster.to_json(resources.Cluster()) req.return_value.content = return_value @@ -10307,6 +10355,7 @@ def test_create_cluster_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.create_cluster(request) @@ -10336,6 +10385,8 @@ def test_create_cluster_rest_call_success(request_type): "capacity_config": {"vcpu_count": 1094, "memory_bytes": 1311}, "rebalance_config": {"mode": 1}, "state": 1, + "satisfies_pzi": True, + "satisfies_pzs": True, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -10417,6 +10468,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_cluster(request) # Establish that the response is the type that we expect. @@ -10458,6 +10510,7 @@ def test_create_cluster_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10504,6 +10557,7 @@ def test_update_cluster_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.update_cluster(request) @@ -10535,6 +10589,8 @@ def test_update_cluster_rest_call_success(request_type): "capacity_config": {"vcpu_count": 1094, "memory_bytes": 1311}, "rebalance_config": {"mode": 1}, "state": 1, + "satisfies_pzi": True, + "satisfies_pzs": True, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -10616,6 +10672,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_cluster(request) # Establish that the response is the type that we expect. @@ -10657,6 +10714,7 @@ def test_update_cluster_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10701,6 +10759,7 @@ def test_delete_cluster_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.delete_cluster(request) @@ -10731,6 +10790,7 @@ def test_delete_cluster_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.delete_cluster(request) # Establish that the response is the type that we expect. @@ -10772,6 +10832,7 @@ def test_delete_cluster_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10814,6 +10875,7 @@ def test_list_topics_rest_bad_request(request_type=managed_kafka.ListTopicsReque 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_topics(request) @@ -10849,6 +10911,7 @@ def test_list_topics_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_topics(request) # Establish that the response is the type that we expect. @@ -10889,6 +10952,7 @@ def test_list_topics_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 = managed_kafka.ListTopicsResponse.to_json( managed_kafka.ListTopicsResponse() ) @@ -10935,6 +10999,7 @@ def test_get_topic_rest_bad_request(request_type=managed_kafka.GetTopicRequest): 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_topic(request) @@ -10974,6 +11039,7 @@ def test_get_topic_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_topic(request) # Establish that the response is the type that we expect. @@ -11014,6 +11080,7 @@ def test_get_topic_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 = resources.Topic.to_json(resources.Topic()) req.return_value.content = return_value @@ -11056,6 +11123,7 @@ def test_create_topic_rest_bad_request(request_type=managed_kafka.CreateTopicReq 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_topic(request) @@ -11166,6 +11234,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_topic(request) # Establish that the response is the type that we expect. @@ -11208,6 +11277,7 @@ def test_create_topic_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 = resources.Topic.to_json(resources.Topic()) req.return_value.content = return_value @@ -11254,6 +11324,7 @@ def test_update_topic_rest_bad_request(request_type=managed_kafka.UpdateTopicReq 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_topic(request) @@ -11368,6 +11439,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_topic(request) # Establish that the response is the type that we expect. @@ -11410,6 +11482,7 @@ def test_update_topic_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 = resources.Topic.to_json(resources.Topic()) req.return_value.content = return_value @@ -11454,6 +11527,7 @@ def test_delete_topic_rest_bad_request(request_type=managed_kafka.DeleteTopicReq 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_topic(request) @@ -11486,6 +11560,7 @@ def test_delete_topic_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_topic(request) # Establish that the response is the type that we expect. @@ -11522,6 +11597,7 @@ def test_delete_topic_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 = managed_kafka.DeleteTopicRequest() metadata = [ @@ -11562,6 +11638,7 @@ def test_list_consumer_groups_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.list_consumer_groups(request) @@ -11597,6 +11674,7 @@ def test_list_consumer_groups_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_consumer_groups(request) # Establish that the response is the type that we expect. @@ -11637,6 +11715,7 @@ def test_list_consumer_groups_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 = managed_kafka.ListConsumerGroupsResponse.to_json( managed_kafka.ListConsumerGroupsResponse() ) @@ -11685,6 +11764,7 @@ def test_get_consumer_group_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_consumer_group(request) @@ -11722,6 +11802,7 @@ def test_get_consumer_group_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_consumer_group(request) # Establish that the response is the type that we expect. @@ -11762,6 +11843,7 @@ def test_get_consumer_group_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 = resources.ConsumerGroup.to_json(resources.ConsumerGroup()) req.return_value.content = return_value @@ -11810,6 +11892,7 @@ def test_update_consumer_group_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.update_consumer_group(request) @@ -11920,6 +12003,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_consumer_group(request) # Establish that the response is the type that we expect. @@ -11960,6 +12044,7 @@ def test_update_consumer_group_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 = resources.ConsumerGroup.to_json(resources.ConsumerGroup()) req.return_value.content = return_value @@ -12006,6 +12091,7 @@ def test_delete_consumer_group_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.delete_consumer_group(request) @@ -12038,6 +12124,7 @@ def test_delete_consumer_group_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_consumer_group(request) # Establish that the response is the type that we expect. @@ -12074,6 +12161,7 @@ def test_delete_consumer_group_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 = managed_kafka.DeleteConsumerGroupRequest() metadata = [ @@ -12114,6 +12202,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) @@ -12144,6 +12233,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) @@ -12172,6 +12262,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) @@ -12202,6 +12293,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) @@ -12232,6 +12324,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -12262,6 +12355,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -12292,6 +12386,7 @@ def test_delete_operation_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.delete_operation(request) @@ -12322,6 +12417,7 @@ def test_delete_operation_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.delete_operation(request) @@ -12352,6 +12448,7 @@ def test_get_operation_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.get_operation(request) @@ -12382,6 +12479,7 @@ def test_get_operation_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_operation(request) @@ -12412,6 +12510,7 @@ def test_list_operations_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_operations(request) @@ -12442,6 +12541,7 @@ def test_list_operations_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_operations(request) From 74833d3e77bb5869bd9f2290c23be7ccaa20193f 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 17:56:22 +0500 Subject: [PATCH 04/16] feat: [google-shopping-css] Add support for opt-in debug logging (#13320) 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 docs: fix comment on list account labels 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLWNzcy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT docs: [google-shopping-css] fix comment on list account labels PiperOrigin-RevId: 702393419 Source-Link: https://github.com/googleapis/googleapis/commit/48fa374e29c854cef29dc3f42319e0680217ce8d Source-Link: https://github.com/googleapis/googleapis-gen/commit/061a2482daf339c88d3e8d0b6f47735e20b9a81e Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLWNzcy8uT3dsQm90LnlhbWwiLCJoIjoiMDYxYTI0ODJkYWYzMzljODhkM2U4ZDBiNmY0NzczNWUyMGI5YTgxZSJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/shopping/css/gapic_version.py | 2 +- .../google/shopping/css_v1/gapic_version.py | 2 +- .../account_labels_service/async_client.py | 66 ++++- .../services/account_labels_service/client.py | 71 ++++- .../services/account_labels_service/pagers.py | 16 +- .../account_labels_service/transports/grpc.py | 100 ++++++- .../transports/grpc_asyncio.py | 99 ++++++- .../account_labels_service/transports/rest.py | 250 ++++++++++++++++-- .../services/accounts_service/async_client.py | 56 +++- .../services/accounts_service/client.py | 61 ++++- .../services/accounts_service/pagers.py | 16 +- .../accounts_service/transports/grpc.py | 96 ++++++- .../transports/grpc_asyncio.py | 95 ++++++- .../accounts_service/transports/rest.py | 204 ++++++++++++-- .../async_client.py | 48 +++- .../css_product_inputs_service/client.py | 53 +++- .../transports/grpc.py | 94 ++++++- .../transports/grpc_asyncio.py | 93 ++++++- .../transports/rest.py | 116 +++++++- .../css_products_service/async_client.py | 48 +++- .../services/css_products_service/client.py | 53 +++- .../services/css_products_service/pagers.py | 16 +- .../css_products_service/transports/grpc.py | 94 ++++++- .../transports/grpc_asyncio.py | 93 ++++++- .../css_products_service/transports/rest.py | 140 +++++++++- ...ippet_metadata_google.shopping.css.v1.json | 46 ++-- .../css_v1/test_account_labels_service.py | 20 ++ .../gapic/css_v1/test_accounts_service.py | 15 ++ .../css_v1/test_css_product_inputs_service.py | 9 + .../gapic/css_v1/test_css_products_service.py | 10 + 30 files changed, 1872 insertions(+), 210 deletions(-) diff --git a/packages/google-shopping-css/google/shopping/css/gapic_version.py b/packages/google-shopping-css/google/shopping/css/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-shopping-css/google/shopping/css/gapic_version.py +++ b/packages/google-shopping-css/google/shopping/css/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-shopping-css/google/shopping/css_v1/gapic_version.py b/packages/google-shopping-css/google/shopping/css_v1/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/gapic_version.py +++ b/packages/google-shopping-css/google/shopping/css_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/async_client.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/async_client.py index 66e098bc2490..af95ad18a80f 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/async_client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AccountLabelsServiceTransport from .transports.grpc_asyncio import AccountLabelsServiceGrpcAsyncIOTransport +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 AccountLabelsServiceAsyncClient: """Manages Merchant Center and CSS accounts labels.""" @@ -260,6 +270,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.shopping.css_v1.AccountLabelsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "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.shopping.css.v1.AccountLabelsService", + "credentialsType": None, + }, + ) + async def list_account_labels( self, request: Optional[Union[accounts_labels.ListAccountLabelsRequest, dict]] = None, @@ -267,9 +299,9 @@ async def list_account_labels( 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.ListAccountLabelsAsyncPager: - r"""Lists the labels assigned to an account. + r"""Lists the labels owned by an account. .. code-block:: python @@ -311,8 +343,10 @@ async def sample_list_account_labels(): 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.shopping.css_v1.services.account_labels_service.pagers.ListAccountLabelsAsyncPager: @@ -389,7 +423,7 @@ async def create_account_label( account_label: Optional[accounts_labels.AccountLabel] = 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]]] = (), ) -> accounts_labels.AccountLabel: r"""Creates a new label, not assigned to any account. @@ -438,8 +472,10 @@ async def sample_create_account_label(): 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.shopping.css_v1.types.AccountLabel: @@ -504,7 +540,7 @@ async def update_account_label( account_label: Optional[accounts_labels.AccountLabel] = 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]]] = (), ) -> accounts_labels.AccountLabel: r"""Updates a label. @@ -546,8 +582,10 @@ async def sample_update_account_label(): 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.shopping.css_v1.types.AccountLabel: @@ -612,7 +650,7 @@ async def delete_account_label( 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 label and removes it from all accounts to which it was assigned. @@ -655,8 +693,10 @@ async def sample_delete_account_label(): 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 diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/client.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/client.py index 4b29559d6563..92ce045e0ae2 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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.shopping.css_v1.services.account_labels_service import pagers from google.shopping.css_v1.types import accounts_labels @@ -577,6 +587,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( @@ -643,6 +657,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.shopping.css_v1.AccountLabelsServiceClient`.", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "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.shopping.css.v1.AccountLabelsService", + "credentialsType": None, + }, + ) + def list_account_labels( self, request: Optional[Union[accounts_labels.ListAccountLabelsRequest, dict]] = None, @@ -650,9 +687,9 @@ def list_account_labels( 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.ListAccountLabelsPager: - r"""Lists the labels assigned to an account. + r"""Lists the labels owned by an account. .. code-block:: python @@ -694,8 +731,10 @@ def sample_list_account_labels(): 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.shopping.css_v1.services.account_labels_service.pagers.ListAccountLabelsPager: @@ -769,7 +808,7 @@ def create_account_label( account_label: Optional[accounts_labels.AccountLabel] = 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]]] = (), ) -> accounts_labels.AccountLabel: r"""Creates a new label, not assigned to any account. @@ -818,8 +857,10 @@ def sample_create_account_label(): 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.shopping.css_v1.types.AccountLabel: @@ -881,7 +922,7 @@ def update_account_label( account_label: Optional[accounts_labels.AccountLabel] = 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]]] = (), ) -> accounts_labels.AccountLabel: r"""Updates a label. @@ -923,8 +964,10 @@ def sample_update_account_label(): 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.shopping.css_v1.types.AccountLabel: @@ -986,7 +1029,7 @@ def delete_account_label( 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 label and removes it from all accounts to which it was assigned. @@ -1029,8 +1072,10 @@ def sample_delete_account_label(): 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 diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/pagers.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/pagers.py index 2c4fcdcd2201..f1c3a5224d72 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/pagers.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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 = accounts_labels.ListAccountLabelsRequest(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 = accounts_labels.ListAccountLabelsRequest(request) diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc.py index f66a6122f35f..3d9467a9b2fe 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import accounts_labels from .base import DEFAULT_CLIENT_INFO, AccountLabelsServiceTransport +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.shopping.css.v1.AccountLabelsService", + "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.shopping.css.v1.AccountLabelsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccountLabelsServiceGrpcTransport(AccountLabelsServiceTransport): """gRPC backend transport for AccountLabelsService. @@ -180,7 +261,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 @@ -244,7 +330,7 @@ def list_account_labels( ]: r"""Return a callable for the list account labels method over gRPC. - Lists the labels assigned to an account. + Lists the labels owned by an account. Returns: Callable[[~.ListAccountLabelsRequest], @@ -257,7 +343,7 @@ def list_account_labels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_labels" not in self._stubs: - self._stubs["list_account_labels"] = self.grpc_channel.unary_unary( + self._stubs["list_account_labels"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/ListAccountLabels", request_serializer=accounts_labels.ListAccountLabelsRequest.serialize, response_deserializer=accounts_labels.ListAccountLabelsResponse.deserialize, @@ -285,7 +371,7 @@ def create_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_account_label" not in self._stubs: - self._stubs["create_account_label"] = self.grpc_channel.unary_unary( + self._stubs["create_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/CreateAccountLabel", request_serializer=accounts_labels.CreateAccountLabelRequest.serialize, response_deserializer=accounts_labels.AccountLabel.deserialize, @@ -313,7 +399,7 @@ def update_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account_label" not in self._stubs: - self._stubs["update_account_label"] = self.grpc_channel.unary_unary( + self._stubs["update_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/UpdateAccountLabel", request_serializer=accounts_labels.UpdateAccountLabelRequest.serialize, response_deserializer=accounts_labels.AccountLabel.deserialize, @@ -340,7 +426,7 @@ def delete_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account_label" not in self._stubs: - self._stubs["delete_account_label"] = self.grpc_channel.unary_unary( + self._stubs["delete_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/DeleteAccountLabel", request_serializer=accounts_labels.DeleteAccountLabelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -348,7 +434,7 @@ def delete_account_label( return self._stubs["delete_account_label"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc_asyncio.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc_asyncio.py index cf2c05d3337b..678c64874a47 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import accounts_labels from .base import DEFAULT_CLIENT_INFO, AccountLabelsServiceTransport from .grpc import AccountLabelsServiceGrpcTransport +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.shopping.css.v1.AccountLabelsService", + "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.shopping.css.v1.AccountLabelsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccountLabelsServiceGrpcAsyncIOTransport(AccountLabelsServiceTransport): """gRPC AsyncIO backend transport for AccountLabelsService. @@ -227,10 +309,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 @@ -252,7 +337,7 @@ def list_account_labels( ]: r"""Return a callable for the list account labels method over gRPC. - Lists the labels assigned to an account. + Lists the labels owned by an account. Returns: Callable[[~.ListAccountLabelsRequest], @@ -265,7 +350,7 @@ def list_account_labels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_labels" not in self._stubs: - self._stubs["list_account_labels"] = self.grpc_channel.unary_unary( + self._stubs["list_account_labels"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/ListAccountLabels", request_serializer=accounts_labels.ListAccountLabelsRequest.serialize, response_deserializer=accounts_labels.ListAccountLabelsResponse.deserialize, @@ -294,7 +379,7 @@ def create_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_account_label" not in self._stubs: - self._stubs["create_account_label"] = self.grpc_channel.unary_unary( + self._stubs["create_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/CreateAccountLabel", request_serializer=accounts_labels.CreateAccountLabelRequest.serialize, response_deserializer=accounts_labels.AccountLabel.deserialize, @@ -323,7 +408,7 @@ def update_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account_label" not in self._stubs: - self._stubs["update_account_label"] = self.grpc_channel.unary_unary( + self._stubs["update_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/UpdateAccountLabel", request_serializer=accounts_labels.UpdateAccountLabelRequest.serialize, response_deserializer=accounts_labels.AccountLabel.deserialize, @@ -352,7 +437,7 @@ def delete_account_label( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account_label" not in self._stubs: - self._stubs["delete_account_label"] = self.grpc_channel.unary_unary( + self._stubs["delete_account_label"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountLabelsService/DeleteAccountLabel", request_serializer=accounts_labels.DeleteAccountLabelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -399,7 +484,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: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/rest.py b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/rest.py index 5d8eb88e7636..40e81c19ee91 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/transports/rest.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/account_labels_service/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 @@ -38,6 +38,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, @@ -98,8 +106,11 @@ def post_update_account_label(self, response): def pre_create_account_label( self, request: accounts_labels.CreateAccountLabelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts_labels.CreateAccountLabelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts_labels.CreateAccountLabelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_account_label Override in a subclass to manipulate the request or metadata @@ -121,8 +132,11 @@ def post_create_account_label( def pre_delete_account_label( self, request: accounts_labels.DeleteAccountLabelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts_labels.DeleteAccountLabelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts_labels.DeleteAccountLabelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_account_label Override in a subclass to manipulate the request or metadata @@ -133,8 +147,11 @@ def pre_delete_account_label( def pre_list_account_labels( self, request: accounts_labels.ListAccountLabelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts_labels.ListAccountLabelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts_labels.ListAccountLabelsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_account_labels Override in a subclass to manipulate the request or metadata @@ -156,8 +173,11 @@ def post_list_account_labels( def pre_update_account_label( self, request: accounts_labels.UpdateAccountLabelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts_labels.UpdateAccountLabelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts_labels.UpdateAccountLabelRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_account_label Override in a subclass to manipulate the request or metadata @@ -299,7 +319,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]]] = (), ) -> accounts_labels.AccountLabel: r"""Call the create account label method over HTTP. @@ -310,8 +330,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: ~.accounts_labels.AccountLabel: @@ -323,6 +345,7 @@ def __call__( http_options = ( _BaseAccountLabelsServiceRestTransport._BaseCreateAccountLabel._get_http_options() ) + request, metadata = self._interceptor.pre_create_account_label( request, metadata ) @@ -339,6 +362,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 = 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.shopping.css_v1.AccountLabelsServiceClient.CreateAccountLabel", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "CreateAccountLabel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccountLabelsServiceRestTransport._CreateAccountLabel._get_response( @@ -362,7 +412,29 @@ def __call__( pb_resp = accounts_labels.AccountLabel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_account_label(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accounts_labels.AccountLabel.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.shopping.css_v1.AccountLabelsServiceClient.create_account_label", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "CreateAccountLabel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAccountLabel( @@ -400,7 +472,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 account label method over HTTP. @@ -411,13 +483,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 = ( _BaseAccountLabelsServiceRestTransport._BaseDeleteAccountLabel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_account_label( request, metadata ) @@ -430,6 +505,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.shopping.css_v1.AccountLabelsServiceClient.DeleteAccountLabel", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "DeleteAccountLabel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccountLabelsServiceRestTransport._DeleteAccountLabel._get_response( @@ -482,7 +584,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]]] = (), ) -> accounts_labels.ListAccountLabelsResponse: r"""Call the list account labels method over HTTP. @@ -492,8 +594,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: ~.accounts_labels.ListAccountLabelsResponse: @@ -503,6 +607,7 @@ def __call__( http_options = ( _BaseAccountLabelsServiceRestTransport._BaseListAccountLabels._get_http_options() ) + request, metadata = self._interceptor.pre_list_account_labels( request, metadata ) @@ -515,6 +620,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 = 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.shopping.css_v1.AccountLabelsServiceClient.ListAccountLabels", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "ListAccountLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccountLabelsServiceRestTransport._ListAccountLabels._get_response( @@ -537,7 +669,31 @@ def __call__( pb_resp = accounts_labels.ListAccountLabelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_account_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + accounts_labels.ListAccountLabelsResponse.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.shopping.css_v1.AccountLabelsServiceClient.list_account_labels", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "ListAccountLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccountLabel( @@ -576,7 +732,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]]] = (), ) -> accounts_labels.AccountLabel: r"""Call the update account label method over HTTP. @@ -586,8 +742,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: ~.accounts_labels.AccountLabel: @@ -599,6 +757,7 @@ def __call__( http_options = ( _BaseAccountLabelsServiceRestTransport._BaseUpdateAccountLabel._get_http_options() ) + request, metadata = self._interceptor.pre_update_account_label( request, metadata ) @@ -615,6 +774,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 = 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.shopping.css_v1.AccountLabelsServiceClient.UpdateAccountLabel", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "UpdateAccountLabel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccountLabelsServiceRestTransport._UpdateAccountLabel._get_response( @@ -638,7 +824,29 @@ def __call__( pb_resp = accounts_labels.AccountLabel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_account_label(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accounts_labels.AccountLabel.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.shopping.css_v1.AccountLabelsServiceClient.update_account_label", + extra={ + "serviceName": "google.shopping.css.v1.AccountLabelsService", + "rpcName": "UpdateAccountLabel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/async_client.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/async_client.py index 0cb6cae3efce..ffe3a66e987c 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/async_client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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, @@ -49,6 +50,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AccountsServiceTransport from .transports.grpc_asyncio import AccountsServiceGrpcAsyncIOTransport +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 AccountsServiceAsyncClient: """Service for managing CSS/MC account information.""" @@ -256,6 +266,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.shopping.css_v1.AccountsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "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.shopping.css.v1.AccountsService", + "credentialsType": None, + }, + ) + async def list_child_accounts( self, request: Optional[Union[accounts.ListChildAccountsRequest, dict]] = None, @@ -263,7 +295,7 @@ async def list_child_accounts( 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.ListChildAccountsAsyncPager: r"""Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and @@ -311,8 +343,10 @@ async def sample_list_child_accounts(): 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.shopping.css_v1.services.accounts_service.pagers.ListChildAccountsAsyncPager: @@ -386,7 +420,7 @@ async def get_account( 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]]] = (), ) -> accounts.Account: r"""Retrieves a single CSS/MC account by ID. @@ -430,8 +464,10 @@ async def sample_get_account(): 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.shopping.css_v1.types.Account: @@ -490,7 +526,7 @@ async def update_labels( 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]]] = (), ) -> accounts.Account: r"""Updates labels assigned to CSS/MC accounts by a CSS domain. @@ -534,8 +570,10 @@ async def sample_update_labels(): 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.shopping.css_v1.types.Account: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/client.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/client.py index 6b1360339591..607097515615 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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.shopping.css_v1.services.accounts_service import pagers from google.shopping.css_v1.types import accounts @@ -573,6 +583,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( @@ -638,6 +652,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.shopping.css_v1.AccountsServiceClient`.", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "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.shopping.css.v1.AccountsService", + "credentialsType": None, + }, + ) + def list_child_accounts( self, request: Optional[Union[accounts.ListChildAccountsRequest, dict]] = None, @@ -645,7 +682,7 @@ def list_child_accounts( 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.ListChildAccountsPager: r"""Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and @@ -693,8 +730,10 @@ def sample_list_child_accounts(): 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.shopping.css_v1.services.accounts_service.pagers.ListChildAccountsPager: @@ -765,7 +804,7 @@ def get_account( 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]]] = (), ) -> accounts.Account: r"""Retrieves a single CSS/MC account by ID. @@ -809,8 +848,10 @@ def sample_get_account(): 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.shopping.css_v1.types.Account: @@ -866,7 +907,7 @@ def update_labels( 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]]] = (), ) -> accounts.Account: r"""Updates labels assigned to CSS/MC accounts by a CSS domain. @@ -910,8 +951,10 @@ def sample_update_labels(): 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.shopping.css_v1.types.Account: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/pagers.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/pagers.py index 957a41cb4042..5b56fdd4c2ee 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/pagers.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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 = accounts.ListChildAccountsRequest(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 = accounts.ListChildAccountsRequest(request) diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc.py index 88b7554c79fb..615955891e29 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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 @@ -20,12 +23,90 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.shopping.css_v1.types import accounts from .base import DEFAULT_CLIENT_INFO, AccountsServiceTransport +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.shopping.css.v1.AccountsService", + "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.shopping.css.v1.AccountsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccountsServiceGrpcTransport(AccountsServiceTransport): """gRPC backend transport for AccountsService. @@ -179,7 +260,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 @@ -257,7 +343,7 @@ def list_child_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_child_accounts" not in self._stubs: - self._stubs["list_child_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_child_accounts"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/ListChildAccounts", request_serializer=accounts.ListChildAccountsRequest.serialize, response_deserializer=accounts.ListChildAccountsResponse.deserialize, @@ -281,7 +367,7 @@ def get_account(self) -> Callable[[accounts.GetAccountRequest], accounts.Account # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/GetAccount", request_serializer=accounts.GetAccountRequest.serialize, response_deserializer=accounts.Account.deserialize, @@ -308,7 +394,7 @@ def update_labels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_labels" not in self._stubs: - self._stubs["update_labels"] = self.grpc_channel.unary_unary( + self._stubs["update_labels"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/UpdateLabels", request_serializer=accounts.UpdateAccountLabelsRequest.serialize, response_deserializer=accounts.Account.deserialize, @@ -316,7 +402,7 @@ def update_labels( return self._stubs["update_labels"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc_asyncio.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc_asyncio.py index 6fd4ab3905f0..be073e49eda9 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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 @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import accounts from .base import DEFAULT_CLIENT_INFO, AccountsServiceTransport from .grpc import AccountsServiceGrpcTransport +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.shopping.css.v1.AccountsService", + "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.shopping.css.v1.AccountsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccountsServiceGrpcAsyncIOTransport(AccountsServiceTransport): """gRPC AsyncIO backend transport for AccountsService. @@ -226,10 +308,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 @@ -266,7 +351,7 @@ def list_child_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_child_accounts" not in self._stubs: - self._stubs["list_child_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_child_accounts"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/ListChildAccounts", request_serializer=accounts.ListChildAccountsRequest.serialize, response_deserializer=accounts.ListChildAccountsResponse.deserialize, @@ -292,7 +377,7 @@ def get_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/GetAccount", request_serializer=accounts.GetAccountRequest.serialize, response_deserializer=accounts.Account.deserialize, @@ -319,7 +404,7 @@ def update_labels( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_labels" not in self._stubs: - self._stubs["update_labels"] = self.grpc_channel.unary_unary( + self._stubs["update_labels"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.AccountsService/UpdateLabels", request_serializer=accounts.UpdateAccountLabelsRequest.serialize, response_deserializer=accounts.Account.deserialize, @@ -370,7 +455,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: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/rest.py b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/rest.py index de86742084d7..9a085333d5f3 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/transports/rest.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/accounts_service/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 @@ -37,6 +37,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, @@ -91,8 +99,10 @@ def post_update_labels(self, response): """ def pre_get_account( - self, request: accounts.GetAccountRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[accounts.GetAccountRequest, Sequence[Tuple[str, str]]]: + self, + request: accounts.GetAccountRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[accounts.GetAccountRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_account Override in a subclass to manipulate the request or metadata @@ -112,8 +122,10 @@ def post_get_account(self, response: accounts.Account) -> accounts.Account: def pre_list_child_accounts( self, request: accounts.ListChildAccountsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts.ListChildAccountsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts.ListChildAccountsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_child_accounts Override in a subclass to manipulate the request or metadata @@ -135,8 +147,10 @@ def post_list_child_accounts( def pre_update_labels( self, request: accounts.UpdateAccountLabelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accounts.UpdateAccountLabelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accounts.UpdateAccountLabelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_labels Override in a subclass to manipulate the request or metadata @@ -274,7 +288,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]]] = (), ) -> accounts.Account: r"""Call the get account method over HTTP. @@ -284,8 +298,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: ~.accounts.Account: @@ -295,6 +311,7 @@ def __call__( http_options = ( _BaseAccountsServiceRestTransport._BaseGetAccount._get_http_options() ) + request, metadata = self._interceptor.pre_get_account(request, metadata) transcoded_request = _BaseAccountsServiceRestTransport._BaseGetAccount._get_transcoded_request( http_options, request @@ -305,6 +322,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 = 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.shopping.css_v1.AccountsServiceClient.GetAccount", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "GetAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccountsServiceRestTransport._GetAccount._get_response( self._host, @@ -325,7 +369,29 @@ def __call__( pb_resp = accounts.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accounts.Account.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.shopping.css_v1.AccountsServiceClient.get_account", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "GetAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListChildAccounts( @@ -363,7 +429,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]]] = (), ) -> accounts.ListChildAccountsResponse: r"""Call the list child accounts method over HTTP. @@ -374,8 +440,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: ~.accounts.ListChildAccountsResponse: @@ -385,6 +453,7 @@ def __call__( http_options = ( _BaseAccountsServiceRestTransport._BaseListChildAccounts._get_http_options() ) + request, metadata = self._interceptor.pre_list_child_accounts( request, metadata ) @@ -397,6 +466,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 = 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.shopping.css_v1.AccountsServiceClient.ListChildAccounts", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "ListChildAccounts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccountsServiceRestTransport._ListChildAccounts._get_response( self._host, @@ -417,7 +513,31 @@ def __call__( pb_resp = accounts.ListChildAccountsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_child_accounts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accounts.ListChildAccountsResponse.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.shopping.css_v1.AccountsServiceClient.list_child_accounts", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "ListChildAccounts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateLabels( @@ -455,7 +575,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]]] = (), ) -> accounts.Account: r"""Call the update labels method over HTTP. @@ -465,8 +585,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: ~.accounts.Account: @@ -476,6 +598,7 @@ def __call__( http_options = ( _BaseAccountsServiceRestTransport._BaseUpdateLabels._get_http_options() ) + request, metadata = self._interceptor.pre_update_labels(request, metadata) transcoded_request = _BaseAccountsServiceRestTransport._BaseUpdateLabels._get_transcoded_request( http_options, request @@ -490,6 +613,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 = 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.shopping.css_v1.AccountsServiceClient.UpdateLabels", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "UpdateLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccountsServiceRestTransport._UpdateLabels._get_response( self._host, @@ -511,7 +661,29 @@ def __call__( pb_resp = accounts.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accounts.Account.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.shopping.css_v1.AccountsServiceClient.update_labels", + extra={ + "serviceName": "google.shopping.css.v1.AccountsService", + "rpcName": "UpdateLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/async_client.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/async_client.py index 8c7085c07388..3f7255ea1ec4 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/async_client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/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, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CssProductInputsServiceTransport from .transports.grpc_asyncio import CssProductInputsServiceGrpcAsyncIOTransport +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 CssProductInputsServiceAsyncClient: """Service to use CssProductInput resource. @@ -272,6 +282,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.shopping.css_v1.CssProductInputsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.css.v1.CssProductInputsService", + "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.shopping.css.v1.CssProductInputsService", + "credentialsType": None, + }, + ) + async def insert_css_product_input( self, request: Optional[ @@ -280,7 +312,7 @@ async def insert_css_product_input( *, 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]]] = (), ) -> css_product_inputs.CssProductInput: r"""Uploads a CssProductInput to your CSS Center account. If an input with the same contentLanguage, identity, @@ -331,8 +363,10 @@ async def sample_insert_css_product_input(): 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.shopping.css_v1.types.CssProductInput: @@ -384,7 +418,7 @@ async def delete_css_product_input( 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 CSS Product input from your CSS Center account. @@ -429,8 +463,10 @@ async def sample_delete_css_product_input(): 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 diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/client.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/client.py index 2a003b922e3c..970c28576f03 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/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.protobuf import timestamp_pb2 # type: ignore from google.shopping.type.types import types @@ -588,6 +598,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( @@ -654,6 +668,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.shopping.css_v1.CssProductInputsServiceClient`.", + extra={ + "serviceName": "google.shopping.css.v1.CssProductInputsService", + "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.shopping.css.v1.CssProductInputsService", + "credentialsType": None, + }, + ) + def insert_css_product_input( self, request: Optional[ @@ -662,7 +699,7 @@ def insert_css_product_input( *, 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]]] = (), ) -> css_product_inputs.CssProductInput: r"""Uploads a CssProductInput to your CSS Center account. If an input with the same contentLanguage, identity, @@ -713,8 +750,10 @@ def sample_insert_css_product_input(): 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.shopping.css_v1.types.CssProductInput: @@ -764,7 +803,7 @@ def delete_css_product_input( 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 CSS Product input from your CSS Center account. @@ -809,8 +848,10 @@ def sample_delete_css_product_input(): 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 diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc.py index 94f333d4b6b2..c868e4321233 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import css_product_inputs from .base import DEFAULT_CLIENT_INFO, CssProductInputsServiceTransport +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.shopping.css.v1.CssProductInputsService", + "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.shopping.css.v1.CssProductInputsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CssProductInputsServiceGrpcTransport(CssProductInputsServiceTransport): """gRPC backend transport for CssProductInputsService. @@ -181,7 +262,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 @@ -265,7 +351,7 @@ def insert_css_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "insert_css_product_input" not in self._stubs: - self._stubs["insert_css_product_input"] = self.grpc_channel.unary_unary( + self._stubs["insert_css_product_input"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductInputsService/InsertCssProductInput", request_serializer=css_product_inputs.InsertCssProductInputRequest.serialize, response_deserializer=css_product_inputs.CssProductInput.deserialize, @@ -294,7 +380,7 @@ def delete_css_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_css_product_input" not in self._stubs: - self._stubs["delete_css_product_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_css_product_input"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductInputsService/DeleteCssProductInput", request_serializer=css_product_inputs.DeleteCssProductInputRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -302,7 +388,7 @@ def delete_css_product_input( return self._stubs["delete_css_product_input"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc_asyncio.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc_asyncio.py index bc09141cc86e..517bc45020da 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import css_product_inputs from .base import DEFAULT_CLIENT_INFO, CssProductInputsServiceTransport from .grpc import CssProductInputsServiceGrpcTransport +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.shopping.css.v1.CssProductInputsService", + "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.shopping.css.v1.CssProductInputsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CssProductInputsServiceGrpcAsyncIOTransport(CssProductInputsServiceTransport): """gRPC AsyncIO backend transport for CssProductInputsService. @@ -228,10 +310,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 @@ -273,7 +358,7 @@ def insert_css_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "insert_css_product_input" not in self._stubs: - self._stubs["insert_css_product_input"] = self.grpc_channel.unary_unary( + self._stubs["insert_css_product_input"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductInputsService/InsertCssProductInput", request_serializer=css_product_inputs.InsertCssProductInputRequest.serialize, response_deserializer=css_product_inputs.CssProductInput.deserialize, @@ -304,7 +389,7 @@ def delete_css_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_css_product_input" not in self._stubs: - self._stubs["delete_css_product_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_css_product_input"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductInputsService/DeleteCssProductInput", request_serializer=css_product_inputs.DeleteCssProductInputRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -332,7 +417,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: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/rest.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/rest.py index 4c153a42493b..bd27ed1300a7 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/transports/rest.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_product_inputs_service/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 @@ -38,6 +38,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, @@ -82,9 +90,10 @@ def post_insert_css_product_input(self, response): def pre_delete_css_product_input( self, request: css_product_inputs.DeleteCssProductInputRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - css_product_inputs.DeleteCssProductInputRequest, Sequence[Tuple[str, str]] + css_product_inputs.DeleteCssProductInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_css_product_input @@ -96,9 +105,10 @@ def pre_delete_css_product_input( def pre_insert_css_product_input( self, request: css_product_inputs.InsertCssProductInputRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - css_product_inputs.InsertCssProductInputRequest, Sequence[Tuple[str, str]] + css_product_inputs.InsertCssProductInputRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert_css_product_input @@ -241,7 +251,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 css product input method over HTTP. @@ -252,13 +262,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 = ( _BaseCssProductInputsServiceRestTransport._BaseDeleteCssProductInput._get_http_options() ) + request, metadata = self._interceptor.pre_delete_css_product_input( request, metadata ) @@ -271,6 +284,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.shopping.css_v1.CssProductInputsServiceClient.DeleteCssProductInput", + extra={ + "serviceName": "google.shopping.css.v1.CssProductInputsService", + "rpcName": "DeleteCssProductInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CssProductInputsServiceRestTransport._DeleteCssProductInput._get_response( self._host, @@ -322,7 +362,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]]] = (), ) -> css_product_inputs.CssProductInput: r"""Call the insert css product input method over HTTP. @@ -333,8 +373,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: ~.css_product_inputs.CssProductInput: @@ -349,6 +391,7 @@ def __call__( http_options = ( _BaseCssProductInputsServiceRestTransport._BaseInsertCssProductInput._get_http_options() ) + request, metadata = self._interceptor.pre_insert_css_product_input( request, metadata ) @@ -365,6 +408,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 = 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.shopping.css_v1.CssProductInputsServiceClient.InsertCssProductInput", + extra={ + "serviceName": "google.shopping.css.v1.CssProductInputsService", + "rpcName": "InsertCssProductInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CssProductInputsServiceRestTransport._InsertCssProductInput._get_response( self._host, @@ -386,7 +456,31 @@ def __call__( pb_resp = css_product_inputs.CssProductInput.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert_css_product_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = css_product_inputs.CssProductInput.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.shopping.css_v1.CssProductInputsServiceClient.insert_css_product_input", + extra={ + "serviceName": "google.shopping.css.v1.CssProductInputsService", + "rpcName": "InsertCssProductInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/async_client.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/async_client.py index 59fa5016dcc9..1bd43a0ba0bf 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/async_client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CssProductsServiceTransport from .transports.grpc_asyncio import CssProductsServiceGrpcAsyncIOTransport +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 CssProductsServiceAsyncClient: """Service for doing get and list on Css Products(a.k.a @@ -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.shopping.css_v1.CssProductsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "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.shopping.css.v1.CssProductsService", + "credentialsType": None, + }, + ) + async def get_css_product( self, request: Optional[Union[css_products.GetCssProductRequest, dict]] = None, @@ -271,7 +303,7 @@ async def get_css_product( 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]]] = (), ) -> css_products.CssProduct: r"""Retrieves the processed CSS Product from your CSS Center account. After inserting, updating, or deleting a @@ -317,8 +349,10 @@ async def sample_get_css_product(): 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.shopping.css_v1.types.CssProduct: @@ -379,7 +413,7 @@ async def list_css_products( 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.ListCssProductsAsyncPager: r"""Lists the processed CSS Products in your CSS Center account. The response might contain fewer items than @@ -432,8 +466,10 @@ async def sample_list_css_products(): 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.shopping.css_v1.services.css_products_service.pagers.ListCssProductsAsyncPager: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/client.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/client.py index 906fdac7d928..730ef9df1d9b 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/client.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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.shopping.type.types import types from google.shopping.css_v1.services.css_products_service import pagers @@ -583,6 +593,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( @@ -649,6 +663,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.shopping.css_v1.CssProductsServiceClient`.", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "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.shopping.css.v1.CssProductsService", + "credentialsType": None, + }, + ) + def get_css_product( self, request: Optional[Union[css_products.GetCssProductRequest, dict]] = None, @@ -656,7 +693,7 @@ def get_css_product( 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]]] = (), ) -> css_products.CssProduct: r"""Retrieves the processed CSS Product from your CSS Center account. After inserting, updating, or deleting a @@ -702,8 +739,10 @@ def sample_get_css_product(): 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.shopping.css_v1.types.CssProduct: @@ -761,7 +800,7 @@ def list_css_products( 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.ListCssProductsPager: r"""Lists the processed CSS Products in your CSS Center account. The response might contain fewer items than @@ -814,8 +853,10 @@ def sample_list_css_products(): 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.shopping.css_v1.services.css_products_service.pagers.ListCssProductsPager: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/pagers.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/pagers.py index 7a800cac351f..927c1af68e7b 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/pagers.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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 = css_products.ListCssProductsRequest(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 = css_products.ListCssProductsRequest(request) diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc.py index ba4c8eb1c92c..113d84f9da25 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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 @@ -20,12 +23,90 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.shopping.css_v1.types import css_products from .base import DEFAULT_CLIENT_INFO, CssProductsServiceTransport +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.shopping.css.v1.CssProductsService", + "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.shopping.css.v1.CssProductsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CssProductsServiceGrpcTransport(CssProductsServiceTransport): """gRPC backend transport for CssProductsService. @@ -180,7 +261,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 @@ -257,7 +343,7 @@ def get_css_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_css_product" not in self._stubs: - self._stubs["get_css_product"] = self.grpc_channel.unary_unary( + self._stubs["get_css_product"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductsService/GetCssProduct", request_serializer=css_products.GetCssProductRequest.serialize, response_deserializer=css_products.CssProduct.deserialize, @@ -292,7 +378,7 @@ def list_css_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_css_products" not in self._stubs: - self._stubs["list_css_products"] = self.grpc_channel.unary_unary( + self._stubs["list_css_products"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductsService/ListCssProducts", request_serializer=css_products.ListCssProductsRequest.serialize, response_deserializer=css_products.ListCssProductsResponse.deserialize, @@ -300,7 +386,7 @@ def list_css_products( return self._stubs["list_css_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc_asyncio.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc_asyncio.py index 5ae2aefa9b75..a7c76405e13e 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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 @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.css_v1.types import css_products from .base import DEFAULT_CLIENT_INFO, CssProductsServiceTransport from .grpc import CssProductsServiceGrpcTransport +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.shopping.css.v1.CssProductsService", + "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.shopping.css.v1.CssProductsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CssProductsServiceGrpcAsyncIOTransport(CssProductsServiceTransport): """gRPC AsyncIO backend transport for CssProductsService. @@ -227,10 +309,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 @@ -267,7 +352,7 @@ def get_css_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_css_product" not in self._stubs: - self._stubs["get_css_product"] = self.grpc_channel.unary_unary( + self._stubs["get_css_product"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductsService/GetCssProduct", request_serializer=css_products.GetCssProductRequest.serialize, response_deserializer=css_products.CssProduct.deserialize, @@ -303,7 +388,7 @@ def list_css_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_css_products" not in self._stubs: - self._stubs["list_css_products"] = self.grpc_channel.unary_unary( + self._stubs["list_css_products"] = self._logged_channel.unary_unary( "/google.shopping.css.v1.CssProductsService/ListCssProducts", request_serializer=css_products.ListCssProductsRequest.serialize, response_deserializer=css_products.ListCssProductsResponse.deserialize, @@ -349,7 +434,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: diff --git a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/rest.py b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/rest.py index 02319ec999ae..85e10300ba56 100644 --- a/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/transports/rest.py +++ b/packages/google-shopping-css/google/shopping/css_v1/services/css_products_service/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 @@ -37,6 +37,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, @@ -85,8 +93,10 @@ def post_list_css_products(self, response): def pre_get_css_product( self, request: css_products.GetCssProductRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[css_products.GetCssProductRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + css_products.GetCssProductRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_css_product Override in a subclass to manipulate the request or metadata @@ -108,8 +118,10 @@ def post_get_css_product( def pre_list_css_products( self, request: css_products.ListCssProductsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[css_products.ListCssProductsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + css_products.ListCssProductsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_css_products Override in a subclass to manipulate the request or metadata @@ -251,7 +263,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]]] = (), ) -> css_products.CssProduct: r"""Call the get css product method over HTTP. @@ -261,8 +273,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: ~.css_products.CssProduct: @@ -274,6 +288,7 @@ def __call__( http_options = ( _BaseCssProductsServiceRestTransport._BaseGetCssProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_css_product(request, metadata) transcoded_request = _BaseCssProductsServiceRestTransport._BaseGetCssProduct._get_transcoded_request( http_options, request @@ -284,6 +299,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 = 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.shopping.css_v1.CssProductsServiceClient.GetCssProduct", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "rpcName": "GetCssProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CssProductsServiceRestTransport._GetCssProduct._get_response( self._host, @@ -304,7 +346,29 @@ def __call__( pb_resp = css_products.CssProduct.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_css_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = css_products.CssProduct.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.shopping.css_v1.CssProductsServiceClient.get_css_product", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "rpcName": "GetCssProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCssProducts( @@ -342,7 +406,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]]] = (), ) -> css_products.ListCssProductsResponse: r"""Call the list css products method over HTTP. @@ -353,8 +417,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: ~.css_products.ListCssProductsResponse: @@ -366,6 +432,7 @@ def __call__( http_options = ( _BaseCssProductsServiceRestTransport._BaseListCssProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_css_products( request, metadata ) @@ -378,6 +445,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 = 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.shopping.css_v1.CssProductsServiceClient.ListCssProducts", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "rpcName": "ListCssProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CssProductsServiceRestTransport._ListCssProducts._get_response( self._host, @@ -398,7 +492,31 @@ def __call__( pb_resp = css_products.ListCssProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_css_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = css_products.ListCssProductsResponse.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.shopping.css_v1.CssProductsServiceClient.list_css_products", + extra={ + "serviceName": "google.shopping.css.v1.CssProductsService", + "rpcName": "ListCssProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-css/samples/generated_samples/snippet_metadata_google.shopping.css.v1.json b/packages/google-shopping-css/samples/generated_samples/snippet_metadata_google.shopping.css.v1.json index bffe33091b83..bb49e4f2bf14 100644 --- a/packages/google-shopping-css/samples/generated_samples/snippet_metadata_google.shopping.css.v1.json +++ b/packages/google-shopping-css/samples/generated_samples/snippet_metadata_google.shopping.css.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-shopping-css", - "version": "0.1.10" + "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.shopping.css_v1.types.AccountLabel", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.AccountLabel", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_account_label" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_account_label" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.account_labels_service.pagers.ListAccountLabelsAsyncPager", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.account_labels_service.pagers.ListAccountLabelsPager", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.AccountLabel", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.AccountLabel", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.Account", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.Account", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.accounts_service.pagers.ListChildAccountsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.accounts_service.pagers.ListChildAccountsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.Account", @@ -1095,7 +1095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.Account", @@ -1176,7 +1176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_css_product_input" @@ -1253,7 +1253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_css_product_input" @@ -1327,7 +1327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.CssProductInput", @@ -1403,7 +1403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.CssProductInput", @@ -1484,7 +1484,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.CssProduct", @@ -1564,7 +1564,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.types.CssProduct", @@ -1645,7 +1645,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.css_products_service.pagers.ListCssProductsAsyncPager", @@ -1725,7 +1725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.css_v1.services.css_products_service.pagers.ListCssProductsPager", diff --git a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_account_labels_service.py b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_account_labels_service.py index 5e8e99fb20be..bdbd908f0492 100644 --- a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_account_labels_service.py +++ b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_account_labels_service.py @@ -2839,6 +2839,7 @@ def test_list_account_labels_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.list_account_labels(request) @@ -2892,6 +2893,7 @@ def test_list_account_labels_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_account_labels(**mock_args) @@ -3089,6 +3091,7 @@ def test_create_account_label_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.create_account_label(request) @@ -3143,6 +3146,7 @@ def test_create_account_label_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_account_label(**mock_args) @@ -3273,6 +3277,7 @@ def test_update_account_label_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.update_account_label(request) @@ -3318,6 +3323,7 @@ def test_update_account_label_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_account_label(**mock_args) @@ -3449,6 +3455,7 @@ def test_delete_account_label_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.delete_account_label(request) @@ -3492,6 +3499,7 @@ def test_delete_account_label_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_account_label(**mock_args) @@ -3881,6 +3889,7 @@ def test_list_account_labels_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.list_account_labels(request) @@ -3916,6 +3925,7 @@ def test_list_account_labels_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_account_labels(request) # Establish that the response is the type that we expect. @@ -3956,6 +3966,7 @@ def test_list_account_labels_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 = accounts_labels.ListAccountLabelsResponse.to_json( accounts_labels.ListAccountLabelsResponse() ) @@ -4002,6 +4013,7 @@ def test_create_account_label_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.create_account_label(request) @@ -4117,6 +4129,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_account_label(request) # Establish that the response is the type that we expect. @@ -4162,6 +4175,7 @@ def test_create_account_label_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 = accounts_labels.AccountLabel.to_json( accounts_labels.AccountLabel() ) @@ -4208,6 +4222,7 @@ def test_update_account_label_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.update_account_label(request) @@ -4323,6 +4338,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_account_label(request) # Establish that the response is the type that we expect. @@ -4368,6 +4384,7 @@ def test_update_account_label_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 = accounts_labels.AccountLabel.to_json( accounts_labels.AccountLabel() ) @@ -4414,6 +4431,7 @@ def test_delete_account_label_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.delete_account_label(request) @@ -4444,6 +4462,7 @@ def test_delete_account_label_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_account_label(request) # Establish that the response is the type that we expect. @@ -4480,6 +4499,7 @@ def test_delete_account_label_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 = accounts_labels.DeleteAccountLabelRequest() metadata = [ diff --git a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_accounts_service.py b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_accounts_service.py index 8d5039fa2ca3..bb6835d5bc1c 100644 --- a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_accounts_service.py +++ b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_accounts_service.py @@ -2444,6 +2444,7 @@ def test_list_child_accounts_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.list_child_accounts(request) @@ -2499,6 +2500,7 @@ def test_list_child_accounts_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_child_accounts(**mock_args) @@ -2692,6 +2694,7 @@ def test_get_account_rest_required_fields(request_type=accounts.GetAccountReques 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_account(request) @@ -2737,6 +2740,7 @@ def test_get_account_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_account(**mock_args) @@ -2867,6 +2871,7 @@ def test_update_labels_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.update_labels(request) @@ -2912,6 +2917,7 @@ def test_update_labels_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_labels(**mock_args) @@ -3249,6 +3255,7 @@ def test_list_child_accounts_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.list_child_accounts(request) @@ -3284,6 +3291,7 @@ def test_list_child_accounts_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_child_accounts(request) # Establish that the response is the type that we expect. @@ -3324,6 +3332,7 @@ def test_list_child_accounts_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 = accounts.ListChildAccountsResponse.to_json( accounts.ListChildAccountsResponse() ) @@ -3368,6 +3377,7 @@ def test_get_account_rest_bad_request(request_type=accounts.GetAccountRequest): 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_account(request) @@ -3410,6 +3420,7 @@ def test_get_account_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_account(request) # Establish that the response is the type that we expect. @@ -3455,6 +3466,7 @@ def test_get_account_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 = accounts.Account.to_json(accounts.Account()) req.return_value.content = return_value @@ -3499,6 +3511,7 @@ def test_update_labels_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.update_labels(request) @@ -3541,6 +3554,7 @@ def test_update_labels_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.update_labels(request) # Establish that the response is the type that we expect. @@ -3588,6 +3602,7 @@ def test_update_labels_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 = accounts.Account.to_json(accounts.Account()) req.return_value.content = return_value diff --git a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_product_inputs_service.py b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_product_inputs_service.py index 3b658de6b349..698cbedd8d35 100644 --- a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_product_inputs_service.py +++ b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_product_inputs_service.py @@ -1846,6 +1846,7 @@ def test_insert_css_product_input_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.insert_css_product_input(request) @@ -1984,6 +1985,7 @@ def test_delete_css_product_input_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.delete_css_product_input(request) @@ -2027,6 +2029,7 @@ def test_delete_css_product_input_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_css_product_input(**mock_args) @@ -2307,6 +2310,7 @@ def test_insert_css_product_input_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.insert_css_product_input(request) @@ -2513,6 +2517,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.insert_css_product_input(request) # Establish that the response is the type that we expect. @@ -2559,6 +2564,7 @@ def test_insert_css_product_input_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 = css_product_inputs.CssProductInput.to_json( css_product_inputs.CssProductInput() ) @@ -2605,6 +2611,7 @@ def test_delete_css_product_input_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.delete_css_product_input(request) @@ -2635,6 +2642,7 @@ def test_delete_css_product_input_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_css_product_input(request) # Establish that the response is the type that we expect. @@ -2672,6 +2680,7 @@ def test_delete_css_product_input_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 = css_product_inputs.DeleteCssProductInputRequest() metadata = [ diff --git a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_products_service.py b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_products_service.py index c863dd8a1008..bbde0a0dd355 100644 --- a/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_products_service.py +++ b/packages/google-shopping-css/tests/unit/gapic/css_v1/test_css_products_service.py @@ -2083,6 +2083,7 @@ def test_get_css_product_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_css_product(request) @@ -2128,6 +2129,7 @@ def test_get_css_product_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_css_product(**mock_args) @@ -2266,6 +2268,7 @@ def test_list_css_products_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.list_css_products(request) @@ -2319,6 +2322,7 @@ def test_list_css_products_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_css_products(**mock_args) @@ -2660,6 +2664,7 @@ def test_get_css_product_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_css_product(request) @@ -2698,6 +2703,7 @@ def test_get_css_product_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_css_product(request) # Establish that the response is the type that we expect. @@ -2741,6 +2747,7 @@ def test_get_css_product_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 = css_products.CssProduct.to_json(css_products.CssProduct()) req.return_value.content = return_value @@ -2785,6 +2792,7 @@ def test_list_css_products_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.list_css_products(request) @@ -2820,6 +2828,7 @@ def test_list_css_products_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_css_products(request) # Establish that the response is the type that we expect. @@ -2860,6 +2869,7 @@ def test_list_css_products_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 = css_products.ListCssProductsResponse.to_json( css_products.ListCssProductsResponse() ) From 917e8d3d21a4225b27a3c00dec6efd0a28f1cba6 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 18:00:27 +0500 Subject: [PATCH 05/16] feat: [google-apps-events-subscriptions] Add support for opt-in debug logging (#13315) 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 feat: A new field `dns_endpoint` is added to message `.google.cloud.deploy.v1.GkeCluster` docs: A comment for field `internal_ip` in message `.google.cloud.deploy.v1.GkeCluster` is changed docs: A comment for field `skaffold_version` in message `.google.cloud.deploy.v1.Release` is changed docs: A comment for field `requested_cancellation` in message `.google.cloud.deploy.v1.OperationMetadata` is changed 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtZXZlbnRzLXN1YnNjcmlwdGlvbnMvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== BEGIN_NESTED_COMMIT feat: [google-apps-events-subscriptions] A new field `dns_endpoint` is added to message `.google.cloud.deploy.v1.GkeCluster` docs: A comment for field `internal_ip` in message `.google.cloud.deploy.v1.GkeCluster` is changed docs: A comment for field `skaffold_version` in message `.google.cloud.deploy.v1.Release` is changed docs: A comment for field `requested_cancellation` in message `.google.cloud.deploy.v1.OperationMetadata` is changed PiperOrigin-RevId: 702047981 Source-Link: https://github.com/googleapis/googleapis/commit/99a5e296c891faa79784687422b9d555bcf54a3f Source-Link: https://github.com/googleapis/googleapis-gen/commit/2fdcaafe5e1ebd6fe1921cbb53f41427086462df Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtZXZlbnRzLXN1YnNjcmlwdGlvbnMvLk93bEJvdC55YW1sIiwiaCI6IjJmZGNhYWZlNWUxZWJkNmZlMTkyMWNiYjUzZjQxNDI3MDg2NDYyZGYifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../events_subscriptions/gapic_version.py | 2 +- .../events_subscriptions_v1/gapic_version.py | 2 +- .../subscriptions_service/async_client.py | 88 +++- .../services/subscriptions_service/client.py | 93 +++- .../services/subscriptions_service/pagers.py | 16 +- .../subscriptions_service/transports/grpc.py | 108 ++++- .../transports/grpc_asyncio.py | 105 +++- .../subscriptions_service/transports/rest.py | 459 ++++++++++++++++-- ...a_google.apps.events.subscriptions.v1.json | 26 +- .../test_subscriptions_service.py | 32 ++ 10 files changed, 812 insertions(+), 119 deletions(-) diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions/gapic_version.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions/gapic_version.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/gapic_version.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/gapic_version.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/async_client.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/async_client.py index 8539f466bec3..d36690b0984e 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/async_client.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/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, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SubscriptionsServiceTransport from .transports.grpc_asyncio import SubscriptionsServiceGrpcAsyncIOTransport +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 SubscriptionsServiceAsyncClient: """A service that manages subscriptions to Google Workspace @@ -277,6 +287,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.apps.events.subscriptions_v1.SubscriptionsServiceAsyncClient`.", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "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.apps.events.subscriptions.v1.SubscriptionsService", + "credentialsType": None, + }, + ) + async def create_subscription( self, request: Optional[ @@ -286,7 +318,7 @@ async def create_subscription( subscription: Optional[subscription_resource.Subscription] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Google Workspace subscription. To learn how to use this method, see `Create a Google Workspace @@ -341,8 +373,10 @@ async def sample_create_subscription(): 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.api_core.operation_async.AsyncOperation: @@ -411,7 +445,7 @@ async def delete_subscription( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Google Workspace subscription. To learn how to use this method, see `Delete a Google Workspace @@ -462,8 +496,10 @@ async def sample_delete_subscription(): 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.api_core.operation_async.AsyncOperation: @@ -544,7 +580,7 @@ async def get_subscription( 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]]] = (), ) -> subscription_resource.Subscription: r"""Gets details about a Google Workspace subscription. To learn how to use this method, see `Get details about a Google Workspace @@ -591,8 +627,10 @@ async def sample_get_subscription(): 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.apps.events_subscriptions_v1.types.Subscription: @@ -657,7 +695,7 @@ async def list_subscriptions( filter: 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.ListSubscriptionsAsyncPager: r"""Lists Google Workspace subscriptions. To learn how to use this method, see `List Google Workspace @@ -732,8 +770,10 @@ async def sample_list_subscriptions(): 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.apps.events_subscriptions_v1.services.subscriptions_service.pagers.ListSubscriptionsAsyncPager: @@ -805,7 +845,7 @@ async def update_subscription( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates or renews a Google Workspace subscription. To learn how to use this method, see `Update or renew a Google Workspace @@ -877,8 +917,10 @@ async def sample_update_subscription(): 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.api_core.operation_async.AsyncOperation: @@ -957,7 +999,7 @@ async def reactivate_subscription( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Reactivates a suspended Google Workspace subscription. @@ -1012,8 +1054,10 @@ async def sample_reactivate_subscription(): 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.api_core.operation_async.AsyncOperation: @@ -1085,7 +1129,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1096,8 +1140,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/client.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/client.py index 44bd27225c06..578243a08b4a 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/client.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -620,6 +630,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( @@ -686,6 +700,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.apps.events.subscriptions_v1.SubscriptionsServiceClient`.", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "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.apps.events.subscriptions.v1.SubscriptionsService", + "credentialsType": None, + }, + ) + def create_subscription( self, request: Optional[ @@ -695,7 +732,7 @@ def create_subscription( subscription: Optional[subscription_resource.Subscription] = 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]]] = (), ) -> operation.Operation: r"""Creates a Google Workspace subscription. To learn how to use this method, see `Create a Google Workspace @@ -750,8 +787,10 @@ def sample_create_subscription(): 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.api_core.operation.Operation: @@ -817,7 +856,7 @@ def delete_subscription( 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]]] = (), ) -> operation.Operation: r"""Deletes a Google Workspace subscription. To learn how to use this method, see `Delete a Google Workspace @@ -868,8 +907,10 @@ def sample_delete_subscription(): 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.api_core.operation.Operation: @@ -947,7 +988,7 @@ def get_subscription( 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]]] = (), ) -> subscription_resource.Subscription: r"""Gets details about a Google Workspace subscription. To learn how to use this method, see `Get details about a Google Workspace @@ -994,8 +1035,10 @@ def sample_get_subscription(): 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.apps.events_subscriptions_v1.types.Subscription: @@ -1057,7 +1100,7 @@ def list_subscriptions( filter: 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.ListSubscriptionsPager: r"""Lists Google Workspace subscriptions. To learn how to use this method, see `List Google Workspace @@ -1132,8 +1175,10 @@ def sample_list_subscriptions(): 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.apps.events_subscriptions_v1.services.subscriptions_service.pagers.ListSubscriptionsPager: @@ -1202,7 +1247,7 @@ def update_subscription( 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]]] = (), ) -> operation.Operation: r"""Updates or renews a Google Workspace subscription. To learn how to use this method, see `Update or renew a Google Workspace @@ -1274,8 +1319,10 @@ def sample_update_subscription(): 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.api_core.operation.Operation: @@ -1351,7 +1398,7 @@ def reactivate_subscription( 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]]] = (), ) -> operation.Operation: r"""Reactivates a suspended Google Workspace subscription. @@ -1406,8 +1453,10 @@ def sample_reactivate_subscription(): 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.api_core.operation.Operation: @@ -1489,7 +1538,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1500,8 +1549,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/pagers.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/pagers.py index 0f89a61aa50e..1be14b284877 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/pagers.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/pagers.py @@ -70,7 +70,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. @@ -84,8 +84,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 = subscriptions_service.ListSubscriptionsRequest(request) @@ -146,7 +148,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. @@ -160,8 +162,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 = subscriptions_service.ListSubscriptionsRequest(request) diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc.py index 6c0a7212cfed..f2912b3e22e7 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/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 @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.apps.events_subscriptions_v1.types import ( subscription_resource, @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, SubscriptionsServiceTransport +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.apps.events.subscriptions.v1.SubscriptionsService", + "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.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SubscriptionsServiceGrpcTransport(SubscriptionsServiceTransport): """gRPC backend transport for SubscriptionsService. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -277,7 +365,7 @@ def create_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_subscription" not in self._stubs: - self._stubs["create_subscription"] = self.grpc_channel.unary_unary( + self._stubs["create_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/CreateSubscription", request_serializer=subscriptions_service.CreateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -307,7 +395,7 @@ def delete_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_subscription" not in self._stubs: - self._stubs["delete_subscription"] = self.grpc_channel.unary_unary( + self._stubs["delete_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/DeleteSubscription", request_serializer=subscriptions_service.DeleteSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -338,7 +426,7 @@ def get_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subscription" not in self._stubs: - self._stubs["get_subscription"] = self.grpc_channel.unary_unary( + self._stubs["get_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/GetSubscription", request_serializer=subscriptions_service.GetSubscriptionRequest.serialize, response_deserializer=subscription_resource.Subscription.deserialize, @@ -369,7 +457,7 @@ def list_subscriptions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subscriptions" not in self._stubs: - self._stubs["list_subscriptions"] = self.grpc_channel.unary_unary( + self._stubs["list_subscriptions"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/ListSubscriptions", request_serializer=subscriptions_service.ListSubscriptionsRequest.serialize, response_deserializer=subscriptions_service.ListSubscriptionsResponse.deserialize, @@ -399,7 +487,7 @@ def update_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subscription" not in self._stubs: - self._stubs["update_subscription"] = self.grpc_channel.unary_unary( + self._stubs["update_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/UpdateSubscription", request_serializer=subscriptions_service.UpdateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +521,7 @@ def reactivate_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reactivate_subscription" not in self._stubs: - self._stubs["reactivate_subscription"] = self.grpc_channel.unary_unary( + self._stubs["reactivate_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/ReactivateSubscription", request_serializer=subscriptions_service.ReactivateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +529,7 @@ def reactivate_subscription( return self._stubs["reactivate_subscription"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -453,7 +541,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc_asyncio.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc_asyncio.py index 5924354b3884..599a750f6980 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/grpc_asyncio.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/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 @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.apps.events_subscriptions_v1.types import ( subscription_resource, @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, SubscriptionsServiceTransport from .grpc import SubscriptionsServiceGrpcTransport +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.apps.events.subscriptions.v1.SubscriptionsService", + "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.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SubscriptionsServiceGrpcAsyncIOTransport(SubscriptionsServiceTransport): """gRPC AsyncIO backend transport for SubscriptionsService. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def create_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_subscription" not in self._stubs: - self._stubs["create_subscription"] = self.grpc_channel.unary_unary( + self._stubs["create_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/CreateSubscription", request_serializer=subscriptions_service.CreateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -319,7 +404,7 @@ def delete_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_subscription" not in self._stubs: - self._stubs["delete_subscription"] = self.grpc_channel.unary_unary( + self._stubs["delete_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/DeleteSubscription", request_serializer=subscriptions_service.DeleteSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +435,7 @@ def get_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subscription" not in self._stubs: - self._stubs["get_subscription"] = self.grpc_channel.unary_unary( + self._stubs["get_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/GetSubscription", request_serializer=subscriptions_service.GetSubscriptionRequest.serialize, response_deserializer=subscription_resource.Subscription.deserialize, @@ -381,7 +466,7 @@ def list_subscriptions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subscriptions" not in self._stubs: - self._stubs["list_subscriptions"] = self.grpc_channel.unary_unary( + self._stubs["list_subscriptions"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/ListSubscriptions", request_serializer=subscriptions_service.ListSubscriptionsRequest.serialize, response_deserializer=subscriptions_service.ListSubscriptionsResponse.deserialize, @@ -412,7 +497,7 @@ def update_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_subscription" not in self._stubs: - self._stubs["update_subscription"] = self.grpc_channel.unary_unary( + self._stubs["update_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/UpdateSubscription", request_serializer=subscriptions_service.UpdateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -447,7 +532,7 @@ def reactivate_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reactivate_subscription" not in self._stubs: - self._stubs["reactivate_subscription"] = self.grpc_channel.unary_unary( + self._stubs["reactivate_subscription"] = self._logged_channel.unary_unary( "/google.apps.events.subscriptions.v1.SubscriptionsService/ReactivateSubscription", request_serializer=subscriptions_service.ReactivateSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -518,7 +603,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: @@ -534,7 +619,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, diff --git a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/rest.py b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/rest.py index 41ca884d7a4c..4bf33555dab4 100644 --- a/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/transports/rest.py +++ b/packages/google-apps-events-subscriptions/google/apps/events_subscriptions_v1/services/subscriptions_service/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 @@ -41,6 +41,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, @@ -121,9 +129,10 @@ def post_update_subscription(self, response): def pre_create_subscription( self, request: subscriptions_service.CreateSubscriptionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - subscriptions_service.CreateSubscriptionRequest, Sequence[Tuple[str, str]] + subscriptions_service.CreateSubscriptionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_subscription @@ -146,9 +155,10 @@ def post_create_subscription( def pre_delete_subscription( self, request: subscriptions_service.DeleteSubscriptionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - subscriptions_service.DeleteSubscriptionRequest, Sequence[Tuple[str, str]] + subscriptions_service.DeleteSubscriptionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_subscription @@ -171,8 +181,11 @@ def post_delete_subscription( def pre_get_subscription( self, request: subscriptions_service.GetSubscriptionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[subscriptions_service.GetSubscriptionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + subscriptions_service.GetSubscriptionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_subscription Override in a subclass to manipulate the request or metadata @@ -194,9 +207,10 @@ def post_get_subscription( def pre_list_subscriptions( self, request: subscriptions_service.ListSubscriptionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - subscriptions_service.ListSubscriptionsRequest, Sequence[Tuple[str, str]] + subscriptions_service.ListSubscriptionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_subscriptions @@ -219,9 +233,10 @@ def post_list_subscriptions( def pre_reactivate_subscription( self, request: subscriptions_service.ReactivateSubscriptionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - subscriptions_service.ReactivateSubscriptionRequest, Sequence[Tuple[str, str]] + subscriptions_service.ReactivateSubscriptionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for reactivate_subscription @@ -244,9 +259,10 @@ def post_reactivate_subscription( def pre_update_subscription( self, request: subscriptions_service.UpdateSubscriptionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - subscriptions_service.UpdateSubscriptionRequest, Sequence[Tuple[str, str]] + subscriptions_service.UpdateSubscriptionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_subscription @@ -269,8 +285,10 @@ def post_update_subscription( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -448,7 +466,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create subscription method over HTTP. @@ -459,8 +477,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: ~.operations_pb2.Operation: @@ -473,6 +493,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseCreateSubscription._get_http_options() ) + request, metadata = self._interceptor.pre_create_subscription( request, metadata ) @@ -489,6 +510,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.apps.events.subscriptions_v1.SubscriptionsServiceClient.CreateSubscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "CreateSubscription", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SubscriptionsServiceRestTransport._CreateSubscription._get_response( @@ -510,7 +558,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_subscription(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.apps.events.subscriptions_v1.SubscriptionsServiceClient.create_subscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "CreateSubscription", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSubscription( @@ -548,7 +618,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete subscription method over HTTP. @@ -559,8 +629,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: ~.operations_pb2.Operation: @@ -573,6 +645,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseDeleteSubscription._get_http_options() ) + request, metadata = self._interceptor.pre_delete_subscription( request, metadata ) @@ -585,6 +658,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.apps.events.subscriptions_v1.SubscriptionsServiceClient.DeleteSubscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "DeleteSubscription", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SubscriptionsServiceRestTransport._DeleteSubscription._get_response( @@ -605,7 +705,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_subscription(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.apps.events.subscriptions_v1.SubscriptionsServiceClient.delete_subscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "DeleteSubscription", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSubscription( @@ -643,7 +765,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]]] = (), ) -> subscription_resource.Subscription: r"""Call the get subscription method over HTTP. @@ -654,8 +776,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: ~.subscription_resource.Subscription: @@ -669,6 +793,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseGetSubscription._get_http_options() ) + request, metadata = self._interceptor.pre_get_subscription( request, metadata ) @@ -681,6 +806,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 = 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.apps.events.subscriptions_v1.SubscriptionsServiceClient.GetSubscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "GetSubscription", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubscriptionsServiceRestTransport._GetSubscription._get_response( self._host, @@ -701,7 +853,31 @@ def __call__( pb_resp = subscription_resource.Subscription.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_subscription(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = subscription_resource.Subscription.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.apps.events.subscriptions_v1.SubscriptionsServiceClient.get_subscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "GetSubscription", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSubscriptions( @@ -739,7 +915,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]]] = (), ) -> subscriptions_service.ListSubscriptionsResponse: r"""Call the list subscriptions method over HTTP. @@ -750,8 +926,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: ~.subscriptions_service.ListSubscriptionsResponse: @@ -763,6 +941,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseListSubscriptions._get_http_options() ) + request, metadata = self._interceptor.pre_list_subscriptions( request, metadata ) @@ -775,6 +954,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 = 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.apps.events.subscriptions_v1.SubscriptionsServiceClient.ListSubscriptions", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "ListSubscriptions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SubscriptionsServiceRestTransport._ListSubscriptions._get_response( @@ -797,7 +1003,33 @@ def __call__( pb_resp = subscriptions_service.ListSubscriptionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_subscriptions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + subscriptions_service.ListSubscriptionsResponse.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.apps.events.subscriptions_v1.SubscriptionsServiceClient.list_subscriptions", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "ListSubscriptions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReactivateSubscription( @@ -836,7 +1068,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]]] = (), ) -> operations_pb2.Operation: r"""Call the reactivate subscription method over HTTP. @@ -847,8 +1079,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: ~.operations_pb2.Operation: @@ -861,6 +1095,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseReactivateSubscription._get_http_options() ) + request, metadata = self._interceptor.pre_reactivate_subscription( request, metadata ) @@ -877,6 +1112,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.apps.events.subscriptions_v1.SubscriptionsServiceClient.ReactivateSubscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "ReactivateSubscription", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SubscriptionsServiceRestTransport._ReactivateSubscription._get_response( @@ -898,7 +1160,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reactivate_subscription(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.apps.events.subscriptions_v1.SubscriptionsServiceClient.reactivate_subscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "ReactivateSubscription", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSubscription( @@ -937,7 +1221,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update subscription method over HTTP. @@ -948,8 +1232,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: ~.operations_pb2.Operation: @@ -962,6 +1248,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseUpdateSubscription._get_http_options() ) + request, metadata = self._interceptor.pre_update_subscription( request, metadata ) @@ -978,6 +1265,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.apps.events.subscriptions_v1.SubscriptionsServiceClient.UpdateSubscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "UpdateSubscription", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SubscriptionsServiceRestTransport._UpdateSubscription._get_response( @@ -999,7 +1313,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_subscription(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.apps.events.subscriptions_v1.SubscriptionsServiceClient.update_subscription", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "UpdateSubscription", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1103,7 +1439,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1113,8 +1449,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: operations_pb2.Operation: Response from GetOperation method. @@ -1123,6 +1461,7 @@ def __call__( http_options = ( _BaseSubscriptionsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSubscriptionsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1133,6 +1472,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.apps.events.subscriptions_v1.SubscriptionsServiceClient.GetOperation", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubscriptionsServiceRestTransport._GetOperation._get_response( self._host, @@ -1152,6 +1518,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.apps.events.subscriptions_v1.SubscriptionsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.apps.events.subscriptions.v1.SubscriptionsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-apps-events-subscriptions/samples/generated_samples/snippet_metadata_google.apps.events.subscriptions.v1.json b/packages/google-apps-events-subscriptions/samples/generated_samples/snippet_metadata_google.apps.events.subscriptions.v1.json index 3d32acd71a3d..b893a1c0de8c 100644 --- a/packages/google-apps-events-subscriptions/samples/generated_samples/snippet_metadata_google.apps.events.subscriptions.v1.json +++ b/packages/google-apps-events-subscriptions/samples/generated_samples/snippet_metadata_google.apps.events.subscriptions.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-apps-events-subscriptions", - "version": "0.1.4" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.events_subscriptions_v1.types.Subscription", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.events_subscriptions_v1.types.Subscription", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.events_subscriptions_v1.services.subscriptions_service.pagers.ListSubscriptionsAsyncPager", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.events_subscriptions_v1.services.subscriptions_service.pagers.ListSubscriptionsPager", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-apps-events-subscriptions/tests/unit/gapic/events_subscriptions_v1/test_subscriptions_service.py b/packages/google-apps-events-subscriptions/tests/unit/gapic/events_subscriptions_v1/test_subscriptions_service.py index d1ea54d0926c..639f5130b6ec 100644 --- a/packages/google-apps-events-subscriptions/tests/unit/gapic/events_subscriptions_v1/test_subscriptions_service.py +++ b/packages/google-apps-events-subscriptions/tests/unit/gapic/events_subscriptions_v1/test_subscriptions_service.py @@ -3444,6 +3444,7 @@ def test_create_subscription_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.create_subscription(request) @@ -3489,6 +3490,7 @@ def test_create_subscription_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_subscription(**mock_args) @@ -3633,6 +3635,7 @@ def test_delete_subscription_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.delete_subscription(request) @@ -3685,6 +3688,7 @@ def test_delete_subscription_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.delete_subscription(**mock_args) @@ -3816,6 +3820,7 @@ def test_get_subscription_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_subscription(request) @@ -3861,6 +3866,7 @@ def test_get_subscription_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_subscription(**mock_args) @@ -4007,6 +4013,7 @@ def test_list_subscriptions_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.list_subscriptions(request) @@ -4067,6 +4074,7 @@ def test_list_subscriptions_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_subscriptions(**mock_args) @@ -4267,6 +4275,7 @@ def test_update_subscription_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.update_subscription(request) @@ -4321,6 +4330,7 @@ def test_update_subscription_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_subscription(**mock_args) @@ -4461,6 +4471,7 @@ def test_reactivate_subscription_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.reactivate_subscription(request) @@ -4504,6 +4515,7 @@ def test_reactivate_subscription_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.reactivate_subscription(**mock_args) @@ -4987,6 +4999,7 @@ def test_create_subscription_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.create_subscription(request) @@ -5106,6 +5119,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_subscription(request) # Establish that the response is the type that we expect. @@ -5147,6 +5161,7 @@ def test_create_subscription_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5191,6 +5206,7 @@ def test_delete_subscription_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.delete_subscription(request) @@ -5221,6 +5237,7 @@ def test_delete_subscription_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.delete_subscription(request) # Establish that the response is the type that we expect. @@ -5262,6 +5279,7 @@ def test_delete_subscription_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5306,6 +5324,7 @@ def test_get_subscription_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_subscription(request) @@ -5349,6 +5368,7 @@ def test_get_subscription_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_subscription(request) # Establish that the response is the type that we expect. @@ -5400,6 +5420,7 @@ def test_get_subscription_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 = subscription_resource.Subscription.to_json( subscription_resource.Subscription() ) @@ -5446,6 +5467,7 @@ def test_list_subscriptions_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.list_subscriptions(request) @@ -5481,6 +5503,7 @@ def test_list_subscriptions_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_subscriptions(request) # Establish that the response is the type that we expect. @@ -5521,6 +5544,7 @@ def test_list_subscriptions_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 = subscriptions_service.ListSubscriptionsResponse.to_json( subscriptions_service.ListSubscriptionsResponse() ) @@ -5567,6 +5591,7 @@ def test_update_subscription_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.update_subscription(request) @@ -5686,6 +5711,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_subscription(request) # Establish that the response is the type that we expect. @@ -5727,6 +5753,7 @@ def test_update_subscription_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5771,6 +5798,7 @@ def test_reactivate_subscription_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.reactivate_subscription(request) @@ -5801,6 +5829,7 @@ def test_reactivate_subscription_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.reactivate_subscription(request) # Establish that the response is the type that we expect. @@ -5842,6 +5871,7 @@ def test_reactivate_subscription_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5886,6 +5916,7 @@ def test_get_operation_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.get_operation(request) @@ -5916,6 +5947,7 @@ def test_get_operation_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_operation(request) From 4795f26b927cc138f5bdc92245848a8ca262ef86 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 18:04:42 +0500 Subject: [PATCH 06/16] feat: [google-cloud-config] Add support for opt-in debug logging (#13339) 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 feat: added annotations docs: Service Account is a required field fix: Changed field behavior for an existing field `service_account` in message `.google.cloud.config.v1.Deployment` fix: Changed field behavior for an existing field `service_account` in message `.google.cloud.config.v1.Preview` 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbmZpZy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT feat: [google-cloud-config] added annotations docs: Service Account is a required field fix: Changed field behavior for an existing field `service_account` in message `.google.cloud.config.v1.Deployment` fix: Changed field behavior for an existing field `service_account` in message `.google.cloud.config.v1.Preview` PiperOrigin-RevId: 705212738 Source-Link: https://github.com/googleapis/googleapis/commit/c46c4ec72b13fe2d32d1c8fb878419562b54c031 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b3a85723b14ae1346323e43515c36a6904e18c3e Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbmZpZy8uT3dsQm90LnlhbWwiLCJoIjoiYjNhODU3MjNiMTRhZTEzNDYzMjNlNDM1MTVjMzZhNjkwNGUxOGMzZSJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/config/gapic_version.py | 2 +- .../google/cloud/config_v1/gapic_version.py | 2 +- .../config_v1/services/config/async_client.py | 291 ++- .../cloud/config_v1/services/config/client.py | 296 ++- .../cloud/config_v1/services/config/pagers.py | 80 +- .../services/config/transports/grpc.py | 162 +- .../config/transports/grpc_asyncio.py | 159 +- .../services/config/transports/rest.py | 1976 +++++++++++++++-- .../google/cloud/config_v1/types/config.py | 31 +- ...1_generated_config_create_preview_async.py | 1 + ...v1_generated_config_create_preview_sync.py | 1 + ...ippet_metadata_google.cloud.config.v1.json | 122 +- .../tests/unit/gapic/config_v1/test_config.py | 131 ++ 13 files changed, 2725 insertions(+), 529 deletions(-) diff --git a/packages/google-cloud-config/google/cloud/config/gapic_version.py b/packages/google-cloud-config/google/cloud/config/gapic_version.py index 7daf9a1dd221..558c8aab67c5 100644 --- a/packages/google-cloud-config/google/cloud/config/gapic_version.py +++ b/packages/google-cloud-config/google/cloud/config/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-config/google/cloud/config_v1/gapic_version.py b/packages/google-cloud-config/google/cloud/config_v1/gapic_version.py index 7daf9a1dd221..558c8aab67c5 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/gapic_version.py +++ b/packages/google-cloud-config/google/cloud/config_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py index 351fa0f47b40..d7f5958fc9f6 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/async_client.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ConfigTransport from .transports.grpc_asyncio import ConfigGrpcAsyncIOTransport +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 ConfigAsyncClient: """Infrastructure Manager is a managed service that automates @@ -271,6 +281,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.config_v1.ConfigAsyncClient`.", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "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.config.v1.Config", + "credentialsType": None, + }, + ) + async def list_deployments( self, request: Optional[Union[config.ListDeploymentsRequest, dict]] = None, @@ -278,7 +310,7 @@ async def list_deployments( 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.ListDeploymentsAsyncPager: r"""Lists [Deployment][google.cloud.config.v1.Deployment]s in a given project and location. @@ -324,8 +356,10 @@ async def sample_list_deployments(): 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.config_v1.services.config.pagers.ListDeploymentsAsyncPager: @@ -398,7 +432,7 @@ async def get_deployment( 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]]] = (), ) -> config.Deployment: r"""Gets details about a [Deployment][google.cloud.config.v1.Deployment]. @@ -442,8 +476,10 @@ async def sample_get_deployment(): 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.config_v1.types.Deployment: @@ -507,7 +543,7 @@ async def create_deployment( deployment_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [Deployment][google.cloud.config.v1.Deployment]. @@ -573,8 +609,10 @@ async def sample_create_deployment(): 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.api_core.operation_async.AsyncOperation: @@ -650,7 +688,7 @@ async def update_deployment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a [Deployment][google.cloud.config.v1.Deployment]. @@ -717,8 +755,10 @@ async def sample_update_deployment(): 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.api_core.operation_async.AsyncOperation: @@ -793,7 +833,7 @@ async def delete_deployment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a [Deployment][google.cloud.config.v1.Deployment]. @@ -840,8 +880,10 @@ async def sample_delete_deployment(): 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.api_core.operation_async.AsyncOperation: @@ -912,7 +954,7 @@ async def list_revisions( 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.ListRevisionsAsyncPager: r"""Lists [Revision][google.cloud.config.v1.Revision]s of a deployment. @@ -959,8 +1001,10 @@ async def sample_list_revisions(): 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.config_v1.services.config.pagers.ListRevisionsAsyncPager: @@ -1035,7 +1079,7 @@ async def get_revision( 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]]] = (), ) -> config.Revision: r"""Gets details about a [Revision][google.cloud.config.v1.Revision]. @@ -1080,8 +1124,10 @@ async def sample_get_revision(): 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.config_v1.types.Revision: @@ -1145,7 +1191,7 @@ async def get_resource( 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]]] = (), ) -> config.Resource: r"""Gets details about a [Resource][google.cloud.config.v1.Resource] deployed by Infra Manager. @@ -1190,8 +1236,10 @@ async def sample_get_resource(): 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.config_v1.types.Resource: @@ -1254,9 +1302,9 @@ async def list_resources( 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.ListResourcesAsyncPager: - r"""Lists [Resource][google.cloud.config.v1.Resource]s in a given + r"""Lists [Resources][google.cloud.config.v1.Resource] in a given revision. .. code-block:: python @@ -1301,8 +1349,10 @@ async def sample_list_resources(): 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.config_v1.services.config.pagers.ListResourcesAsyncPager: @@ -1376,7 +1426,7 @@ async def export_deployment_statefile( *, 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]]] = (), ) -> config.Statefile: r"""Exports Terraform state file from a given deployment. @@ -1414,8 +1464,10 @@ async def sample_export_deployment_statefile(): 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.config_v1.types.Statefile: @@ -1461,7 +1513,7 @@ async def export_revision_statefile( *, 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]]] = (), ) -> config.Statefile: r"""Exports Terraform state file from a given revision. @@ -1499,8 +1551,10 @@ async def sample_export_revision_statefile(): 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.config_v1.types.Statefile: @@ -1548,7 +1602,7 @@ async def import_statefile( lock_id: Optional[int] = 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]]] = (), ) -> config.Statefile: r"""Imports Terraform state file in a given deployment. The state file does not take effect until the Deployment @@ -1605,8 +1659,10 @@ async def sample_import_statefile(): 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.config_v1.types.Statefile: @@ -1669,7 +1725,7 @@ async def delete_statefile( 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 Terraform state file in a given deployment. @@ -1711,8 +1767,10 @@ async def sample_delete_statefile(): 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 @@ -1764,7 +1822,7 @@ async def lock_deployment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Locks a deployment. @@ -1812,8 +1870,10 @@ async def sample_lock_deployment(): 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.api_core.operation_async.AsyncOperation: @@ -1885,7 +1945,7 @@ async def unlock_deployment( lock_id: Optional[int] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Unlocks a locked deployment. @@ -1941,8 +2001,10 @@ async def sample_unlock_deployment(): 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.api_core.operation_async.AsyncOperation: @@ -2015,7 +2077,7 @@ async def export_lock_info( 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]]] = (), ) -> config.LockInfo: r"""Exports the lock info on a locked deployment. @@ -2059,8 +2121,10 @@ async def sample_export_lock_info(): 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.config_v1.types.LockInfo: @@ -2122,7 +2186,7 @@ async def create_preview( preview: Optional[config.Preview] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a [Preview][google.cloud.config.v1.Preview]. @@ -2144,6 +2208,7 @@ async def sample_create_preview(): # Initialize request argument(s) preview = config_v1.Preview() preview.terraform_blueprint.gcs_source = "gcs_source_value" + preview.service_account = "service_account_value" request = config_v1.CreatePreviewRequest( parent="parent_value", @@ -2181,8 +2246,10 @@ async def sample_create_preview(): 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.api_core.operation_async.AsyncOperation: @@ -2256,7 +2323,7 @@ async def get_preview( 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]]] = (), ) -> config.Preview: r"""Gets details about a [Preview][google.cloud.config.v1.Preview]. @@ -2300,8 +2367,10 @@ async def sample_get_preview(): 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.config_v1.types.Preview: @@ -2364,7 +2433,7 @@ async def list_previews( 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.ListPreviewsAsyncPager: r"""Lists [Preview][google.cloud.config.v1.Preview]s in a given project and location. @@ -2411,8 +2480,10 @@ async def sample_list_previews(): 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.config_v1.services.config.pagers.ListPreviewsAsyncPager: @@ -2487,7 +2558,7 @@ async def delete_preview( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a [Preview][google.cloud.config.v1.Preview]. @@ -2534,8 +2605,10 @@ async def sample_delete_preview(): 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.api_core.operation_async.AsyncOperation: @@ -2606,7 +2679,7 @@ async def export_preview_result( *, 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]]] = (), ) -> config.ExportPreviewResultResponse: r"""Export [Preview][google.cloud.config.v1.Preview] results. @@ -2642,8 +2715,10 @@ async def sample_export_preview_result(): 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.config_v1.types.ExportPreviewResultResponse: @@ -2690,7 +2765,7 @@ async def list_terraform_versions( 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.ListTerraformVersionsAsyncPager: r"""Lists [TerraformVersion][google.cloud.config.v1.TerraformVersion]s in @@ -2738,8 +2813,10 @@ async def sample_list_terraform_versions(): 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.config_v1.services.config.pagers.ListTerraformVersionsAsyncPager: @@ -2814,7 +2891,7 @@ async def get_terraform_version( 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]]] = (), ) -> config.TerraformVersion: r"""Gets details about a [TerraformVersion][google.cloud.config.v1.TerraformVersion]. @@ -2859,8 +2936,10 @@ async def sample_get_terraform_version(): 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.config_v1.types.TerraformVersion: @@ -2921,7 +3000,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2932,8 +3011,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2974,7 +3055,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2985,8 +3066,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3027,7 +3110,7 @@ async def delete_operation( *, 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 long-running operation. @@ -3043,8 +3126,10 @@ async def delete_operation( 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: None """ @@ -3081,7 +3166,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -3096,8 +3181,10 @@ async def cancel_operation( 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: None """ @@ -3134,7 +3221,7 @@ async def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -3147,8 +3234,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3253,7 +3342,7 @@ async def get_iam_policy( *, 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 IAM access control policy for a function. @@ -3267,8 +3356,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3373,7 +3464,7 @@ async def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3388,8 +3479,10 @@ async def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3433,7 +3526,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. @@ -3444,8 +3537,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. @@ -3486,7 +3581,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. @@ -3497,8 +3592,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-config/google/cloud/config_v1/services/config/client.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py index 87fb2897e6c5..faa3c74eea47 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/client.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -729,6 +739,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( @@ -791,6 +805,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.config_v1.ConfigClient`.", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "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.config.v1.Config", + "credentialsType": None, + }, + ) + def list_deployments( self, request: Optional[Union[config.ListDeploymentsRequest, dict]] = None, @@ -798,7 +835,7 @@ def list_deployments( 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.ListDeploymentsPager: r"""Lists [Deployment][google.cloud.config.v1.Deployment]s in a given project and location. @@ -844,8 +881,10 @@ def sample_list_deployments(): 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.config_v1.services.config.pagers.ListDeploymentsPager: @@ -915,7 +954,7 @@ def get_deployment( 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]]] = (), ) -> config.Deployment: r"""Gets details about a [Deployment][google.cloud.config.v1.Deployment]. @@ -959,8 +998,10 @@ def sample_get_deployment(): 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.config_v1.types.Deployment: @@ -1021,7 +1062,7 @@ def create_deployment( deployment_id: 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]]] = (), ) -> operation.Operation: r"""Creates a [Deployment][google.cloud.config.v1.Deployment]. @@ -1087,8 +1128,10 @@ def sample_create_deployment(): 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.api_core.operation.Operation: @@ -1161,7 +1204,7 @@ def update_deployment( 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]]] = (), ) -> operation.Operation: r"""Updates a [Deployment][google.cloud.config.v1.Deployment]. @@ -1228,8 +1271,10 @@ def sample_update_deployment(): 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.api_core.operation.Operation: @@ -1301,7 +1346,7 @@ def delete_deployment( 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]]] = (), ) -> operation.Operation: r"""Deletes a [Deployment][google.cloud.config.v1.Deployment]. @@ -1348,8 +1393,10 @@ def sample_delete_deployment(): 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.api_core.operation.Operation: @@ -1417,7 +1464,7 @@ def list_revisions( 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.ListRevisionsPager: r"""Lists [Revision][google.cloud.config.v1.Revision]s of a deployment. @@ -1464,8 +1511,10 @@ def sample_list_revisions(): 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.config_v1.services.config.pagers.ListRevisionsPager: @@ -1537,7 +1586,7 @@ def get_revision( 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]]] = (), ) -> config.Revision: r"""Gets details about a [Revision][google.cloud.config.v1.Revision]. @@ -1582,8 +1631,10 @@ def sample_get_revision(): 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.config_v1.types.Revision: @@ -1644,7 +1695,7 @@ def get_resource( 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]]] = (), ) -> config.Resource: r"""Gets details about a [Resource][google.cloud.config.v1.Resource] deployed by Infra Manager. @@ -1689,8 +1740,10 @@ def sample_get_resource(): 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.config_v1.types.Resource: @@ -1750,9 +1803,9 @@ def list_resources( 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.ListResourcesPager: - r"""Lists [Resource][google.cloud.config.v1.Resource]s in a given + r"""Lists [Resources][google.cloud.config.v1.Resource] in a given revision. .. code-block:: python @@ -1797,8 +1850,10 @@ def sample_list_resources(): 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.config_v1.services.config.pagers.ListResourcesPager: @@ -1869,7 +1924,7 @@ def export_deployment_statefile( *, 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]]] = (), ) -> config.Statefile: r"""Exports Terraform state file from a given deployment. @@ -1907,8 +1962,10 @@ def sample_export_deployment_statefile(): 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.config_v1.types.Statefile: @@ -1954,7 +2011,7 @@ def export_revision_statefile( *, 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]]] = (), ) -> config.Statefile: r"""Exports Terraform state file from a given revision. @@ -1992,8 +2049,10 @@ def sample_export_revision_statefile(): 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.config_v1.types.Statefile: @@ -2041,7 +2100,7 @@ def import_statefile( lock_id: Optional[int] = 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]]] = (), ) -> config.Statefile: r"""Imports Terraform state file in a given deployment. The state file does not take effect until the Deployment @@ -2098,8 +2157,10 @@ def sample_import_statefile(): 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.config_v1.types.Statefile: @@ -2159,7 +2220,7 @@ def delete_statefile( 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 Terraform state file in a given deployment. @@ -2201,8 +2262,10 @@ def sample_delete_statefile(): 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 @@ -2251,7 +2314,7 @@ def lock_deployment( 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]]] = (), ) -> operation.Operation: r"""Locks a deployment. @@ -2299,8 +2362,10 @@ def sample_lock_deployment(): 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.api_core.operation.Operation: @@ -2369,7 +2434,7 @@ def unlock_deployment( lock_id: Optional[int] = 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]]] = (), ) -> operation.Operation: r"""Unlocks a locked deployment. @@ -2425,8 +2490,10 @@ def sample_unlock_deployment(): 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.api_core.operation.Operation: @@ -2496,7 +2563,7 @@ def export_lock_info( 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]]] = (), ) -> config.LockInfo: r"""Exports the lock info on a locked deployment. @@ -2540,8 +2607,10 @@ def sample_export_lock_info(): 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.config_v1.types.LockInfo: @@ -2600,7 +2669,7 @@ def create_preview( preview: Optional[config.Preview] = 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]]] = (), ) -> operation.Operation: r"""Creates a [Preview][google.cloud.config.v1.Preview]. @@ -2622,6 +2691,7 @@ def sample_create_preview(): # Initialize request argument(s) preview = config_v1.Preview() preview.terraform_blueprint.gcs_source = "gcs_source_value" + preview.service_account = "service_account_value" request = config_v1.CreatePreviewRequest( parent="parent_value", @@ -2659,8 +2729,10 @@ def sample_create_preview(): 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.api_core.operation.Operation: @@ -2731,7 +2803,7 @@ def get_preview( 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]]] = (), ) -> config.Preview: r"""Gets details about a [Preview][google.cloud.config.v1.Preview]. @@ -2775,8 +2847,10 @@ def sample_get_preview(): 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.config_v1.types.Preview: @@ -2836,7 +2910,7 @@ def list_previews( 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.ListPreviewsPager: r"""Lists [Preview][google.cloud.config.v1.Preview]s in a given project and location. @@ -2883,8 +2957,10 @@ def sample_list_previews(): 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.config_v1.services.config.pagers.ListPreviewsPager: @@ -2956,7 +3032,7 @@ def delete_preview( 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]]] = (), ) -> operation.Operation: r"""Deletes a [Preview][google.cloud.config.v1.Preview]. @@ -3003,8 +3079,10 @@ def sample_delete_preview(): 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.api_core.operation.Operation: @@ -3072,7 +3150,7 @@ def export_preview_result( *, 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]]] = (), ) -> config.ExportPreviewResultResponse: r"""Export [Preview][google.cloud.config.v1.Preview] results. @@ -3108,8 +3186,10 @@ def sample_export_preview_result(): 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.config_v1.types.ExportPreviewResultResponse: @@ -3154,7 +3234,7 @@ def list_terraform_versions( 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.ListTerraformVersionsPager: r"""Lists [TerraformVersion][google.cloud.config.v1.TerraformVersion]s in @@ -3202,8 +3282,10 @@ def sample_list_terraform_versions(): 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.config_v1.services.config.pagers.ListTerraformVersionsPager: @@ -3275,7 +3357,7 @@ def get_terraform_version( 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]]] = (), ) -> config.TerraformVersion: r"""Gets details about a [TerraformVersion][google.cloud.config.v1.TerraformVersion]. @@ -3320,8 +3402,10 @@ def sample_get_terraform_version(): 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.config_v1.types.TerraformVersion: @@ -3392,7 +3476,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3403,8 +3487,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3445,7 +3531,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3456,8 +3542,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3498,7 +3586,7 @@ def delete_operation( *, 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 long-running operation. @@ -3514,8 +3602,10 @@ def delete_operation( 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: None """ @@ -3552,7 +3642,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -3567,8 +3657,10 @@ def cancel_operation( 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: None """ @@ -3605,7 +3697,7 @@ def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -3618,8 +3710,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3724,7 +3818,7 @@ def get_iam_policy( *, 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 IAM access control policy for a function. @@ -3738,8 +3832,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -3844,7 +3940,7 @@ def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -3859,8 +3955,10 @@ def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. @@ -3902,7 +4000,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. @@ -3913,8 +4011,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. @@ -3955,7 +4055,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. @@ -3966,8 +4066,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-config/google/cloud/config_v1/services/config/pagers.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py index 74826cc5b6f7..e380109079d1 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/pagers.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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 = config.ListDeploymentsRequest(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 = config.ListDeploymentsRequest(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 = config.ListRevisionsRequest(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 = config.ListRevisionsRequest(request) @@ -371,7 +379,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. @@ -385,8 +393,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 = config.ListResourcesRequest(request) @@ -445,7 +455,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. @@ -459,8 +469,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 = config.ListResourcesRequest(request) @@ -523,7 +535,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. @@ -537,8 +549,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 = config.ListPreviewsRequest(request) @@ -597,7 +611,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. @@ -611,8 +625,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 = config.ListPreviewsRequest(request) @@ -675,7 +691,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. @@ -689,8 +705,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 = config.ListTerraformVersionsRequest(request) @@ -749,7 +767,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. @@ -763,8 +781,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 = config.ListTerraformVersionsRequest(request) diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py index 997c16eb2e8d..db6d05b9cb3c 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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 @@ -25,12 +28,90 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.config_v1.types import config from .base import DEFAULT_CLIENT_INFO, ConfigTransport +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.config.v1.Config", + "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.config.v1.Config", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConfigGrpcTransport(ConfigTransport): """gRPC backend transport for Config. @@ -187,7 +268,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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListDeployments", request_serializer=config.ListDeploymentsRequest.serialize, response_deserializer=config.ListDeploymentsResponse.deserialize, @@ -303,7 +391,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetDeployment", request_serializer=config.GetDeploymentRequest.serialize, response_deserializer=config.Deployment.deserialize, @@ -329,7 +417,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/CreateDeployment", request_serializer=config.CreateDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +443,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/UpdateDeployment", request_serializer=config.UpdateDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -381,7 +469,7 @@ def delete_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_deployment" not in self._stubs: - self._stubs["delete_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeleteDeployment", request_serializer=config.DeleteDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def list_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_revisions" not in self._stubs: - self._stubs["list_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_revisions"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListRevisions", request_serializer=config.ListRevisionsRequest.serialize, response_deserializer=config.ListRevisionsResponse.deserialize, @@ -433,7 +521,7 @@ def get_revision(self) -> Callable[[config.GetRevisionRequest], config.Revision] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_revision" not in self._stubs: - self._stubs["get_revision"] = self.grpc_channel.unary_unary( + self._stubs["get_revision"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetRevision", request_serializer=config.GetRevisionRequest.serialize, response_deserializer=config.Revision.deserialize, @@ -458,7 +546,7 @@ def get_resource(self) -> Callable[[config.GetResourceRequest], config.Resource] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource" not in self._stubs: - self._stubs["get_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_resource"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetResource", request_serializer=config.GetResourceRequest.serialize, response_deserializer=config.Resource.deserialize, @@ -471,7 +559,7 @@ def list_resources( ) -> Callable[[config.ListResourcesRequest], config.ListResourcesResponse]: r"""Return a callable for the list resources method over gRPC. - Lists [Resource][google.cloud.config.v1.Resource]s in a given + Lists [Resources][google.cloud.config.v1.Resource] in a given revision. Returns: @@ -485,7 +573,7 @@ def list_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resources" not in self._stubs: - self._stubs["list_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_resources"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListResources", request_serializer=config.ListResourcesRequest.serialize, response_deserializer=config.ListResourcesResponse.deserialize, @@ -511,7 +599,9 @@ def export_deployment_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_deployment_statefile" not in self._stubs: - self._stubs["export_deployment_statefile"] = self.grpc_channel.unary_unary( + self._stubs[ + "export_deployment_statefile" + ] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportDeploymentStatefile", request_serializer=config.ExportDeploymentStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -537,7 +627,7 @@ def export_revision_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_revision_statefile" not in self._stubs: - self._stubs["export_revision_statefile"] = self.grpc_channel.unary_unary( + self._stubs["export_revision_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportRevisionStatefile", request_serializer=config.ExportRevisionStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -565,7 +655,7 @@ def import_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_statefile" not in self._stubs: - self._stubs["import_statefile"] = self.grpc_channel.unary_unary( + self._stubs["import_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ImportStatefile", request_serializer=config.ImportStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -591,7 +681,7 @@ def delete_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_statefile" not in self._stubs: - self._stubs["delete_statefile"] = self.grpc_channel.unary_unary( + self._stubs["delete_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeleteStatefile", request_serializer=config.DeleteStatefileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -617,7 +707,7 @@ def lock_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lock_deployment" not in self._stubs: - self._stubs["lock_deployment"] = self.grpc_channel.unary_unary( + self._stubs["lock_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/LockDeployment", request_serializer=config.LockDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -643,7 +733,7 @@ def unlock_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "unlock_deployment" not in self._stubs: - self._stubs["unlock_deployment"] = self.grpc_channel.unary_unary( + self._stubs["unlock_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/UnlockDeployment", request_serializer=config.UnlockDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -669,7 +759,7 @@ def export_lock_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_lock_info" not in self._stubs: - self._stubs["export_lock_info"] = self.grpc_channel.unary_unary( + self._stubs["export_lock_info"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportLockInfo", request_serializer=config.ExportLockInfoRequest.serialize, response_deserializer=config.LockInfo.deserialize, @@ -695,7 +785,7 @@ def create_preview( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_preview" not in self._stubs: - self._stubs["create_preview"] = self.grpc_channel.unary_unary( + self._stubs["create_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/CreatePreview", request_serializer=config.CreatePreviewRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -719,7 +809,7 @@ def get_preview(self) -> Callable[[config.GetPreviewRequest], config.Preview]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_preview" not in self._stubs: - self._stubs["get_preview"] = self.grpc_channel.unary_unary( + self._stubs["get_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetPreview", request_serializer=config.GetPreviewRequest.serialize, response_deserializer=config.Preview.deserialize, @@ -746,7 +836,7 @@ def list_previews( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_previews" not in self._stubs: - self._stubs["list_previews"] = self.grpc_channel.unary_unary( + self._stubs["list_previews"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListPreviews", request_serializer=config.ListPreviewsRequest.serialize, response_deserializer=config.ListPreviewsResponse.deserialize, @@ -772,7 +862,7 @@ def delete_preview( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_preview" not in self._stubs: - self._stubs["delete_preview"] = self.grpc_channel.unary_unary( + self._stubs["delete_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeletePreview", request_serializer=config.DeletePreviewRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -800,7 +890,7 @@ def export_preview_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_preview_result" not in self._stubs: - self._stubs["export_preview_result"] = self.grpc_channel.unary_unary( + self._stubs["export_preview_result"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportPreviewResult", request_serializer=config.ExportPreviewResultRequest.serialize, response_deserializer=config.ExportPreviewResultResponse.deserialize, @@ -830,7 +920,7 @@ def list_terraform_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_terraform_versions" not in self._stubs: - self._stubs["list_terraform_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_terraform_versions"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListTerraformVersions", request_serializer=config.ListTerraformVersionsRequest.serialize, response_deserializer=config.ListTerraformVersionsResponse.deserialize, @@ -857,7 +947,7 @@ def get_terraform_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_terraform_version" not in self._stubs: - self._stubs["get_terraform_version"] = self.grpc_channel.unary_unary( + self._stubs["get_terraform_version"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetTerraformVersion", request_serializer=config.GetTerraformVersionRequest.serialize, response_deserializer=config.TerraformVersion.deserialize, @@ -865,7 +955,7 @@ def get_terraform_version( return self._stubs["get_terraform_version"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -877,7 +967,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -894,7 +984,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -911,7 +1001,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -930,7 +1020,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -949,7 +1039,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, @@ -966,7 +1056,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, @@ -991,7 +1081,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1017,7 +1107,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1046,7 +1136,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py index a8d58b67c2c5..fb2c6870c643 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/grpc_asyncio.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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 @@ -27,14 +30,93 @@ from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.config_v1.types import config from .base import DEFAULT_CLIENT_INFO, ConfigTransport from .grpc import ConfigGrpcTransport +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.config.v1.Config", + "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.config.v1.Config", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConfigGrpcAsyncIOTransport(ConfigTransport): """gRPC AsyncIO backend transport for Config. @@ -234,10 +316,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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def list_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_deployments" not in self._stubs: - self._stubs["list_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_deployments"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListDeployments", request_serializer=config.ListDeploymentsRequest.serialize, response_deserializer=config.ListDeploymentsResponse.deserialize, @@ -315,7 +400,7 @@ def get_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_deployment" not in self._stubs: - self._stubs["get_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetDeployment", request_serializer=config.GetDeploymentRequest.serialize, response_deserializer=config.Deployment.deserialize, @@ -343,7 +428,7 @@ def create_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_deployment" not in self._stubs: - self._stubs["create_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/CreateDeployment", request_serializer=config.CreateDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +456,7 @@ def update_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_deployment" not in self._stubs: - self._stubs["update_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/UpdateDeployment", request_serializer=config.UpdateDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -399,7 +484,7 @@ def delete_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_deployment" not in self._stubs: - self._stubs["delete_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeleteDeployment", request_serializer=config.DeleteDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +513,7 @@ def list_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_revisions" not in self._stubs: - self._stubs["list_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_revisions"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListRevisions", request_serializer=config.ListRevisionsRequest.serialize, response_deserializer=config.ListRevisionsResponse.deserialize, @@ -455,7 +540,7 @@ def get_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_revision" not in self._stubs: - self._stubs["get_revision"] = self.grpc_channel.unary_unary( + self._stubs["get_revision"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetRevision", request_serializer=config.GetRevisionRequest.serialize, response_deserializer=config.Revision.deserialize, @@ -482,7 +567,7 @@ def get_resource( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_resource" not in self._stubs: - self._stubs["get_resource"] = self.grpc_channel.unary_unary( + self._stubs["get_resource"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetResource", request_serializer=config.GetResourceRequest.serialize, response_deserializer=config.Resource.deserialize, @@ -497,7 +582,7 @@ def list_resources( ]: r"""Return a callable for the list resources method over gRPC. - Lists [Resource][google.cloud.config.v1.Resource]s in a given + Lists [Resources][google.cloud.config.v1.Resource] in a given revision. Returns: @@ -511,7 +596,7 @@ def list_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_resources" not in self._stubs: - self._stubs["list_resources"] = self.grpc_channel.unary_unary( + self._stubs["list_resources"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListResources", request_serializer=config.ListResourcesRequest.serialize, response_deserializer=config.ListResourcesResponse.deserialize, @@ -539,7 +624,9 @@ def export_deployment_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_deployment_statefile" not in self._stubs: - self._stubs["export_deployment_statefile"] = self.grpc_channel.unary_unary( + self._stubs[ + "export_deployment_statefile" + ] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportDeploymentStatefile", request_serializer=config.ExportDeploymentStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -565,7 +652,7 @@ def export_revision_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_revision_statefile" not in self._stubs: - self._stubs["export_revision_statefile"] = self.grpc_channel.unary_unary( + self._stubs["export_revision_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportRevisionStatefile", request_serializer=config.ExportRevisionStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -593,7 +680,7 @@ def import_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_statefile" not in self._stubs: - self._stubs["import_statefile"] = self.grpc_channel.unary_unary( + self._stubs["import_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ImportStatefile", request_serializer=config.ImportStatefileRequest.serialize, response_deserializer=config.Statefile.deserialize, @@ -619,7 +706,7 @@ def delete_statefile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_statefile" not in self._stubs: - self._stubs["delete_statefile"] = self.grpc_channel.unary_unary( + self._stubs["delete_statefile"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeleteStatefile", request_serializer=config.DeleteStatefileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -645,7 +732,7 @@ def lock_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lock_deployment" not in self._stubs: - self._stubs["lock_deployment"] = self.grpc_channel.unary_unary( + self._stubs["lock_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/LockDeployment", request_serializer=config.LockDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -673,7 +760,7 @@ def unlock_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "unlock_deployment" not in self._stubs: - self._stubs["unlock_deployment"] = self.grpc_channel.unary_unary( + self._stubs["unlock_deployment"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/UnlockDeployment", request_serializer=config.UnlockDeploymentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -699,7 +786,7 @@ def export_lock_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_lock_info" not in self._stubs: - self._stubs["export_lock_info"] = self.grpc_channel.unary_unary( + self._stubs["export_lock_info"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportLockInfo", request_serializer=config.ExportLockInfoRequest.serialize, response_deserializer=config.LockInfo.deserialize, @@ -725,7 +812,7 @@ def create_preview( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_preview" not in self._stubs: - self._stubs["create_preview"] = self.grpc_channel.unary_unary( + self._stubs["create_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/CreatePreview", request_serializer=config.CreatePreviewRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -751,7 +838,7 @@ def get_preview( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_preview" not in self._stubs: - self._stubs["get_preview"] = self.grpc_channel.unary_unary( + self._stubs["get_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetPreview", request_serializer=config.GetPreviewRequest.serialize, response_deserializer=config.Preview.deserialize, @@ -778,7 +865,7 @@ def list_previews( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_previews" not in self._stubs: - self._stubs["list_previews"] = self.grpc_channel.unary_unary( + self._stubs["list_previews"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListPreviews", request_serializer=config.ListPreviewsRequest.serialize, response_deserializer=config.ListPreviewsResponse.deserialize, @@ -804,7 +891,7 @@ def delete_preview( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_preview" not in self._stubs: - self._stubs["delete_preview"] = self.grpc_channel.unary_unary( + self._stubs["delete_preview"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/DeletePreview", request_serializer=config.DeletePreviewRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -833,7 +920,7 @@ def export_preview_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_preview_result" not in self._stubs: - self._stubs["export_preview_result"] = self.grpc_channel.unary_unary( + self._stubs["export_preview_result"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ExportPreviewResult", request_serializer=config.ExportPreviewResultRequest.serialize, response_deserializer=config.ExportPreviewResultResponse.deserialize, @@ -864,7 +951,7 @@ def list_terraform_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_terraform_versions" not in self._stubs: - self._stubs["list_terraform_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_terraform_versions"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/ListTerraformVersions", request_serializer=config.ListTerraformVersionsRequest.serialize, response_deserializer=config.ListTerraformVersionsResponse.deserialize, @@ -893,7 +980,7 @@ def get_terraform_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_terraform_version" not in self._stubs: - self._stubs["get_terraform_version"] = self.grpc_channel.unary_unary( + self._stubs["get_terraform_version"] = self._logged_channel.unary_unary( "/google.cloud.config.v1.Config/GetTerraformVersion", request_serializer=config.GetTerraformVersionRequest.serialize, response_deserializer=config.TerraformVersion.deserialize, @@ -1071,7 +1158,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: @@ -1087,7 +1174,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1104,7 +1191,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -1121,7 +1208,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -1140,7 +1227,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -1159,7 +1246,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, @@ -1176,7 +1263,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, @@ -1201,7 +1288,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1227,7 +1314,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1256,7 +1343,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py b/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py index b437202ef684..ee4e755ffdde 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/services/config/transports/rest.py +++ b/packages/google-cloud-config/google/cloud/config_v1/services/config/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 @@ -42,6 +42,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, @@ -254,8 +262,8 @@ def post_update_deployment(self, response): def pre_create_deployment( self, request: config.CreateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.CreateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.CreateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_deployment Override in a subclass to manipulate the request or metadata @@ -275,8 +283,10 @@ def post_create_deployment( return response def pre_create_preview( - self, request: config.CreatePreviewRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.CreatePreviewRequest, Sequence[Tuple[str, str]]]: + self, + request: config.CreatePreviewRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.CreatePreviewRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_preview Override in a subclass to manipulate the request or metadata @@ -298,8 +308,8 @@ def post_create_preview( def pre_delete_deployment( self, request: config.DeleteDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.DeleteDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.DeleteDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_deployment Override in a subclass to manipulate the request or metadata @@ -319,8 +329,10 @@ def post_delete_deployment( return response def pre_delete_preview( - self, request: config.DeletePreviewRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.DeletePreviewRequest, Sequence[Tuple[str, str]]]: + self, + request: config.DeletePreviewRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.DeletePreviewRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_preview Override in a subclass to manipulate the request or metadata @@ -342,8 +354,8 @@ def post_delete_preview( def pre_delete_statefile( self, request: config.DeleteStatefileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.DeleteStatefileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.DeleteStatefileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_statefile Override in a subclass to manipulate the request or metadata @@ -354,8 +366,10 @@ def pre_delete_statefile( def pre_export_deployment_statefile( self, request: config.ExportDeploymentStatefileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ExportDeploymentStatefileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.ExportDeploymentStatefileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_deployment_statefile Override in a subclass to manipulate the request or metadata @@ -375,8 +389,10 @@ def post_export_deployment_statefile( return response def pre_export_lock_info( - self, request: config.ExportLockInfoRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.ExportLockInfoRequest, Sequence[Tuple[str, str]]]: + self, + request: config.ExportLockInfoRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ExportLockInfoRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_lock_info Override in a subclass to manipulate the request or metadata @@ -396,8 +412,10 @@ def post_export_lock_info(self, response: config.LockInfo) -> config.LockInfo: def pre_export_preview_result( self, request: config.ExportPreviewResultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ExportPreviewResultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.ExportPreviewResultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_preview_result Override in a subclass to manipulate the request or metadata @@ -419,8 +437,10 @@ def post_export_preview_result( def pre_export_revision_statefile( self, request: config.ExportRevisionStatefileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ExportRevisionStatefileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.ExportRevisionStatefileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_revision_statefile Override in a subclass to manipulate the request or metadata @@ -440,8 +460,10 @@ def post_export_revision_statefile( return response def pre_get_deployment( - self, request: config.GetDeploymentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.GetDeploymentRequest, Sequence[Tuple[str, str]]]: + self, + request: config.GetDeploymentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.GetDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_deployment Override in a subclass to manipulate the request or metadata @@ -459,8 +481,10 @@ def post_get_deployment(self, response: config.Deployment) -> config.Deployment: return response def pre_get_preview( - self, request: config.GetPreviewRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.GetPreviewRequest, Sequence[Tuple[str, str]]]: + self, + request: config.GetPreviewRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.GetPreviewRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_preview Override in a subclass to manipulate the request or metadata @@ -478,8 +502,10 @@ def post_get_preview(self, response: config.Preview) -> config.Preview: return response def pre_get_resource( - self, request: config.GetResourceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.GetResourceRequest, Sequence[Tuple[str, str]]]: + self, + request: config.GetResourceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.GetResourceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_resource Override in a subclass to manipulate the request or metadata @@ -497,8 +523,10 @@ def post_get_resource(self, response: config.Resource) -> config.Resource: return response def pre_get_revision( - self, request: config.GetRevisionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.GetRevisionRequest, Sequence[Tuple[str, str]]]: + self, + request: config.GetRevisionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.GetRevisionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_revision Override in a subclass to manipulate the request or metadata @@ -518,8 +546,10 @@ def post_get_revision(self, response: config.Revision) -> config.Revision: def pre_get_terraform_version( self, request: config.GetTerraformVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.GetTerraformVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.GetTerraformVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_terraform_version Override in a subclass to manipulate the request or metadata @@ -541,8 +571,8 @@ def post_get_terraform_version( def pre_import_statefile( self, request: config.ImportStatefileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ImportStatefileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ImportStatefileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_statefile Override in a subclass to manipulate the request or metadata @@ -562,8 +592,8 @@ def post_import_statefile(self, response: config.Statefile) -> config.Statefile: def pre_list_deployments( self, request: config.ListDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ListDeploymentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_deployments Override in a subclass to manipulate the request or metadata @@ -583,8 +613,10 @@ def post_list_deployments( return response def pre_list_previews( - self, request: config.ListPreviewsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.ListPreviewsRequest, Sequence[Tuple[str, str]]]: + self, + request: config.ListPreviewsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListPreviewsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_previews Override in a subclass to manipulate the request or metadata @@ -604,8 +636,10 @@ def post_list_previews( return response def pre_list_resources( - self, request: config.ListResourcesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.ListResourcesRequest, Sequence[Tuple[str, str]]]: + self, + request: config.ListResourcesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListResourcesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_resources Override in a subclass to manipulate the request or metadata @@ -625,8 +659,10 @@ def post_list_resources( return response def pre_list_revisions( - self, request: config.ListRevisionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.ListRevisionsRequest, Sequence[Tuple[str, str]]]: + self, + request: config.ListRevisionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.ListRevisionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_revisions Override in a subclass to manipulate the request or metadata @@ -648,8 +684,10 @@ def post_list_revisions( def pre_list_terraform_versions( self, request: config.ListTerraformVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.ListTerraformVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + config.ListTerraformVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_terraform_versions Override in a subclass to manipulate the request or metadata @@ -669,8 +707,10 @@ def post_list_terraform_versions( return response def pre_lock_deployment( - self, request: config.LockDeploymentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[config.LockDeploymentRequest, Sequence[Tuple[str, str]]]: + self, + request: config.LockDeploymentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.LockDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for lock_deployment Override in a subclass to manipulate the request or metadata @@ -692,8 +732,8 @@ def post_lock_deployment( def pre_unlock_deployment( self, request: config.UnlockDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.UnlockDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.UnlockDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for unlock_deployment Override in a subclass to manipulate the request or metadata @@ -715,8 +755,8 @@ def post_unlock_deployment( def pre_update_deployment( self, request: config.UpdateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[config.UpdateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[config.UpdateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_deployment Override in a subclass to manipulate the request or metadata @@ -738,8 +778,10 @@ def post_update_deployment( 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 @@ -761,8 +803,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 @@ -784,8 +828,10 @@ def post_list_locations( 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 @@ -805,8 +851,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: 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 @@ -826,8 +874,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 @@ -849,8 +900,10 @@ def post_test_iam_permissions( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -870,8 +923,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -891,8 +946,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -914,8 +971,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -1112,7 +1171,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create deployment method over HTTP. @@ -1122,8 +1181,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: ~.operations_pb2.Operation: @@ -1136,6 +1197,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseCreateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_deployment( request, metadata ) @@ -1158,6 +1220,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.config_v1.ConfigClient.CreateDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "CreateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._CreateDeployment._get_response( self._host, @@ -1177,7 +1266,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_deployment(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.config_v1.ConfigClient.create_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "CreateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreatePreview(_BaseConfigRestTransport._BaseCreatePreview, ConfigRestStub): @@ -1213,7 +1324,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create preview method over HTTP. @@ -1223,8 +1334,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: ~.operations_pb2.Operation: @@ -1237,6 +1350,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseCreatePreview._get_http_options() ) + request, metadata = self._interceptor.pre_create_preview(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseCreatePreview._get_transcoded_request( @@ -1255,6 +1369,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.config_v1.ConfigClient.CreatePreview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "CreatePreview", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._CreatePreview._get_response( self._host, @@ -1274,7 +1415,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_preview(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.config_v1.ConfigClient.create_preview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "CreatePreview", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDeployment( @@ -1311,7 +1474,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete deployment method over HTTP. @@ -1321,8 +1484,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: ~.operations_pb2.Operation: @@ -1335,6 +1500,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseDeleteDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_deployment( request, metadata ) @@ -1351,6 +1517,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.config_v1.ConfigClient.DeleteDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._DeleteDeployment._get_response( self._host, @@ -1369,7 +1562,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_deployment(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.config_v1.ConfigClient.delete_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePreview(_BaseConfigRestTransport._BaseDeletePreview, ConfigRestStub): @@ -1404,7 +1619,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete preview method over HTTP. @@ -1414,8 +1629,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: ~.operations_pb2.Operation: @@ -1428,6 +1645,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseDeletePreview._get_http_options() ) + request, metadata = self._interceptor.pre_delete_preview(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseDeletePreview._get_transcoded_request( @@ -1442,6 +1660,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.config_v1.ConfigClient.DeletePreview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeletePreview", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._DeletePreview._get_response( self._host, @@ -1460,7 +1705,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_preview(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.config_v1.ConfigClient.delete_preview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeletePreview", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteStatefile( @@ -1498,7 +1765,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 statefile method over HTTP. @@ -1509,13 +1776,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 = ( _BaseConfigRestTransport._BaseDeleteStatefile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_statefile( request, metadata ) @@ -1536,6 +1806,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.config_v1.ConfigClient.DeleteStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._DeleteStatefile._get_response( self._host, @@ -1587,7 +1884,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]]] = (), ) -> config.Statefile: r"""Call the export deployment statefile method over HTTP. @@ -1600,8 +1897,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: ~.config.Statefile: @@ -1613,6 +1912,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseExportDeploymentStatefile._get_http_options() ) + request, metadata = self._interceptor.pre_export_deployment_statefile( request, metadata ) @@ -1629,6 +1929,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 = 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.config_v1.ConfigClient.ExportDeploymentStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportDeploymentStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ExportDeploymentStatefile._get_response( self._host, @@ -1650,7 +1977,29 @@ def __call__( pb_resp = config.Statefile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_deployment_statefile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Statefile.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.config_v1.ConfigClient.export_deployment_statefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportDeploymentStatefile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportLockInfo(_BaseConfigRestTransport._BaseExportLockInfo, ConfigRestStub): @@ -1685,7 +2034,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]]] = (), ) -> config.LockInfo: r"""Call the export lock info method over HTTP. @@ -1696,8 +2045,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: ~.config.LockInfo: @@ -1709,6 +2060,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseExportLockInfo._get_http_options() ) + request, metadata = self._interceptor.pre_export_lock_info( request, metadata ) @@ -1725,6 +2077,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.config_v1.ConfigClient.ExportLockInfo", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportLockInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ExportLockInfo._get_response( self._host, @@ -1745,7 +2124,29 @@ def __call__( pb_resp = config.LockInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_lock_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.LockInfo.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.config_v1.ConfigClient.export_lock_info", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportLockInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportPreviewResult( @@ -1783,7 +2184,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]]] = (), ) -> config.ExportPreviewResultResponse: r"""Call the export preview result method over HTTP. @@ -1793,8 +2194,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: ~.config.ExportPreviewResultResponse: @@ -1806,6 +2209,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseExportPreviewResult._get_http_options() ) + request, metadata = self._interceptor.pre_export_preview_result( request, metadata ) @@ -1822,6 +2226,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 = 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.config_v1.ConfigClient.ExportPreviewResult", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportPreviewResult", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ExportPreviewResult._get_response( self._host, @@ -1843,7 +2274,31 @@ def __call__( pb_resp = config.ExportPreviewResultResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_preview_result(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ExportPreviewResultResponse.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.config_v1.ConfigClient.export_preview_result", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportPreviewResult", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportRevisionStatefile( @@ -1881,7 +2336,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]]] = (), ) -> config.Statefile: r"""Call the export revision statefile method over HTTP. @@ -1893,8 +2348,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: ~.config.Statefile: @@ -1906,6 +2363,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseExportRevisionStatefile._get_http_options() ) + request, metadata = self._interceptor.pre_export_revision_statefile( request, metadata ) @@ -1922,6 +2380,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 = 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.config_v1.ConfigClient.ExportRevisionStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportRevisionStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ExportRevisionStatefile._get_response( self._host, @@ -1943,7 +2428,29 @@ def __call__( pb_resp = config.Statefile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_revision_statefile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Statefile.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.config_v1.ConfigClient.export_revision_statefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ExportRevisionStatefile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeployment(_BaseConfigRestTransport._BaseGetDeployment, ConfigRestStub): @@ -1978,7 +2485,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]]] = (), ) -> config.Deployment: r"""Call the get deployment method over HTTP. @@ -1988,8 +2495,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: ~.config.Deployment: @@ -2002,6 +2511,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseGetDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_deployment(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetDeployment._get_transcoded_request( @@ -2016,6 +2526,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.config_v1.ConfigClient.GetDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetDeployment._get_response( self._host, @@ -2036,7 +2573,29 @@ def __call__( pb_resp = config.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Deployment.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.config_v1.ConfigClient.get_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPreview(_BaseConfigRestTransport._BaseGetPreview, ConfigRestStub): @@ -2071,7 +2630,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]]] = (), ) -> config.Preview: r"""Call the get preview method over HTTP. @@ -2082,8 +2641,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: ~.config.Preview: @@ -2095,6 +2656,7 @@ def __call__( """ http_options = _BaseConfigRestTransport._BaseGetPreview._get_http_options() + request, metadata = self._interceptor.pre_get_preview(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetPreview._get_transcoded_request( @@ -2109,6 +2671,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.config_v1.ConfigClient.GetPreview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetPreview", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetPreview._get_response( self._host, @@ -2129,7 +2718,29 @@ def __call__( pb_resp = config.Preview.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_preview(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Preview.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.config_v1.ConfigClient.get_preview", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetPreview", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetResource(_BaseConfigRestTransport._BaseGetResource, ConfigRestStub): @@ -2164,7 +2775,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]]] = (), ) -> config.Resource: r"""Call the get resource method over HTTP. @@ -2175,8 +2786,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: ~.config.Resource: @@ -2188,6 +2801,7 @@ def __call__( """ http_options = _BaseConfigRestTransport._BaseGetResource._get_http_options() + request, metadata = self._interceptor.pre_get_resource(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetResource._get_transcoded_request( @@ -2202,6 +2816,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.config_v1.ConfigClient.GetResource", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetResource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetResource._get_response( self._host, @@ -2222,7 +2863,29 @@ def __call__( pb_resp = config.Resource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_resource(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Resource.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.config_v1.ConfigClient.get_resource", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetResource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRevision(_BaseConfigRestTransport._BaseGetRevision, ConfigRestStub): @@ -2257,7 +2920,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]]] = (), ) -> config.Revision: r"""Call the get revision method over HTTP. @@ -2268,8 +2931,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: ~.config.Revision: @@ -2282,6 +2947,7 @@ def __call__( """ http_options = _BaseConfigRestTransport._BaseGetRevision._get_http_options() + request, metadata = self._interceptor.pre_get_revision(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetRevision._get_transcoded_request( @@ -2296,6 +2962,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.config_v1.ConfigClient.GetRevision", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetRevision._get_response( self._host, @@ -2316,7 +3009,29 @@ def __call__( pb_resp = config.Revision.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Revision.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.config_v1.ConfigClient.get_revision", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTerraformVersion( @@ -2353,7 +3068,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]]] = (), ) -> config.TerraformVersion: r"""Call the get terraform version method over HTTP. @@ -2364,8 +3079,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: ~.config.TerraformVersion: @@ -2378,6 +3095,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseGetTerraformVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_terraform_version( request, metadata ) @@ -2390,6 +3108,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 = 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.config_v1.ConfigClient.GetTerraformVersion", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetTerraformVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetTerraformVersion._get_response( self._host, @@ -2410,7 +3155,29 @@ def __call__( pb_resp = config.TerraformVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_terraform_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.TerraformVersion.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.config_v1.ConfigClient.get_terraform_version", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetTerraformVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportStatefile( @@ -2448,7 +3215,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]]] = (), ) -> config.Statefile: r"""Call the import statefile method over HTTP. @@ -2459,8 +3226,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: ~.config.Statefile: @@ -2472,6 +3241,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseImportStatefile._get_http_options() ) + request, metadata = self._interceptor.pre_import_statefile( request, metadata ) @@ -2492,6 +3262,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.config_v1.ConfigClient.ImportStatefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ImportStatefile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ImportStatefile._get_response( self._host, @@ -2513,7 +3310,29 @@ def __call__( pb_resp = config.Statefile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_statefile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.Statefile.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.config_v1.ConfigClient.import_statefile", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ImportStatefile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeployments( @@ -2550,7 +3369,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]]] = (), ) -> config.ListDeploymentsResponse: r"""Call the list deployments method over HTTP. @@ -2560,8 +3379,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: ~.config.ListDeploymentsResponse: @@ -2571,6 +3392,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployments( request, metadata ) @@ -2587,6 +3409,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.config_v1.ConfigClient.ListDeployments", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListDeployments._get_response( self._host, @@ -2607,7 +3456,29 @@ def __call__( pb_resp = config.ListDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ListDeploymentsResponse.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.config_v1.ConfigClient.list_deployments", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPreviews(_BaseConfigRestTransport._BaseListPreviews, ConfigRestStub): @@ -2642,7 +3513,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]]] = (), ) -> config.ListPreviewsResponse: r"""Call the list previews method over HTTP. @@ -2653,8 +3524,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: ~.config.ListPreviewsResponse: @@ -2666,6 +3539,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListPreviews._get_http_options() ) + request, metadata = self._interceptor.pre_list_previews(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseListPreviews._get_transcoded_request( @@ -2680,6 +3554,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.config_v1.ConfigClient.ListPreviews", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListPreviews", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListPreviews._get_response( self._host, @@ -2700,7 +3601,29 @@ def __call__( pb_resp = config.ListPreviewsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_previews(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ListPreviewsResponse.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.config_v1.ConfigClient.list_previews", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListPreviews", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListResources(_BaseConfigRestTransport._BaseListResources, ConfigRestStub): @@ -2735,7 +3658,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]]] = (), ) -> config.ListResourcesResponse: r"""Call the list resources method over HTTP. @@ -2746,8 +3669,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: ~.config.ListResourcesResponse: @@ -2759,6 +3684,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListResources._get_http_options() ) + request, metadata = self._interceptor.pre_list_resources(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseListResources._get_transcoded_request( @@ -2773,6 +3699,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.config_v1.ConfigClient.ListResources", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListResources._get_response( self._host, @@ -2793,7 +3746,29 @@ def __call__( pb_resp = config.ListResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ListResourcesResponse.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.config_v1.ConfigClient.list_resources", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRevisions(_BaseConfigRestTransport._BaseListRevisions, ConfigRestStub): @@ -2828,7 +3803,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]]] = (), ) -> config.ListRevisionsResponse: r"""Call the list revisions method over HTTP. @@ -2839,8 +3814,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: ~.config.ListRevisionsResponse: @@ -2852,6 +3829,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_revisions(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseListRevisions._get_transcoded_request( @@ -2866,6 +3844,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.config_v1.ConfigClient.ListRevisions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListRevisions._get_response( self._host, @@ -2886,7 +3891,29 @@ def __call__( pb_resp = config.ListRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ListRevisionsResponse.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.config_v1.ConfigClient.list_revisions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTerraformVersions( @@ -2923,7 +3950,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]]] = (), ) -> config.ListTerraformVersionsResponse: r"""Call the list terraform versions method over HTTP. @@ -2934,8 +3961,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: ~.config.ListTerraformVersionsResponse: @@ -2947,6 +3976,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListTerraformVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_terraform_versions( request, metadata ) @@ -2959,6 +3989,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 = 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.config_v1.ConfigClient.ListTerraformVersions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListTerraformVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListTerraformVersions._get_response( self._host, @@ -2979,7 +4036,31 @@ def __call__( pb_resp = config.ListTerraformVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_terraform_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = config.ListTerraformVersionsResponse.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.config_v1.ConfigClient.list_terraform_versions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListTerraformVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LockDeployment(_BaseConfigRestTransport._BaseLockDeployment, ConfigRestStub): @@ -3015,7 +4096,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]]] = (), ) -> operations_pb2.Operation: r"""Call the lock deployment method over HTTP. @@ -3026,8 +4107,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: ~.operations_pb2.Operation: @@ -3040,6 +4123,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseLockDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_lock_deployment(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseLockDeployment._get_transcoded_request( @@ -3058,6 +4142,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.config_v1.ConfigClient.LockDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "LockDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._LockDeployment._get_response( self._host, @@ -3077,7 +4188,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lock_deployment(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.config_v1.ConfigClient.lock_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "LockDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UnlockDeployment( @@ -3115,7 +4248,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]]] = (), ) -> operations_pb2.Operation: r"""Call the unlock deployment method over HTTP. @@ -3126,8 +4259,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: ~.operations_pb2.Operation: @@ -3140,6 +4275,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseUnlockDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_unlock_deployment( request, metadata ) @@ -3162,6 +4298,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.config_v1.ConfigClient.UnlockDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UnlockDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._UnlockDeployment._get_response( self._host, @@ -3181,7 +4344,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_unlock_deployment(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.config_v1.ConfigClient.unlock_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UnlockDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeployment( @@ -3219,7 +4404,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update deployment method over HTTP. @@ -3229,8 +4414,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: ~.operations_pb2.Operation: @@ -3243,6 +4430,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseUpdateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_deployment( request, metadata ) @@ -3265,6 +4453,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.config_v1.ConfigClient.UpdateDeployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UpdateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._UpdateDeployment._get_response( self._host, @@ -3284,7 +4499,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_deployment(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.config_v1.ConfigClient.update_deployment", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "UpdateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3505,7 +4742,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. @@ -3515,14 +4752,17 @@ 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. """ http_options = _BaseConfigRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetLocation._get_transcoded_request( @@ -3537,6 +4777,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.config_v1.ConfigClient.GetLocation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetLocation._get_response( self._host, @@ -3556,6 +4823,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.config_v1.ConfigAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3594,7 +4882,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. @@ -3604,8 +4892,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. @@ -3614,6 +4904,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseListLocations._get_transcoded_request( @@ -3628,6 +4919,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.config_v1.ConfigClient.ListLocations", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListLocations._get_response( self._host, @@ -3647,6 +4965,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.config_v1.ConfigAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3685,7 +5024,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. @@ -3695,8 +5034,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: Response from GetIamPolicy method. @@ -3705,6 +5046,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -3719,6 +5061,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.config_v1.ConfigClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetIamPolicy._get_response( self._host, @@ -3738,6 +5107,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) 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.config_v1.ConfigAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3777,7 +5167,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. @@ -3787,8 +5177,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: Response from SetIamPolicy method. @@ -3797,6 +5189,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -3815,6 +5208,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.config_v1.ConfigClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._SetIamPolicy._get_response( self._host, @@ -3835,6 +5255,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) 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.config_v1.ConfigAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3876,7 +5317,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. @@ -3886,8 +5327,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: Response from TestIamPermissions method. @@ -3896,6 +5339,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3916,6 +5360,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.config_v1.ConfigClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._TestIamPermissions._get_response( self._host, @@ -3936,6 +5407,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) 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.config_v1.ConfigAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3977,7 +5469,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3987,13 +5479,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 = ( _BaseConfigRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4014,6 +5509,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.config_v1.ConfigClient.CancelOperation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._CancelOperation._get_response( self._host, @@ -4070,7 +5592,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -4080,13 +5602,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 = ( _BaseConfigRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4103,6 +5628,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.config_v1.ConfigClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._DeleteOperation._get_response( self._host, @@ -4156,7 +5708,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4166,8 +5718,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: operations_pb2.Operation: Response from GetOperation method. @@ -4176,6 +5730,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseGetOperation._get_transcoded_request( @@ -4190,6 +5745,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.config_v1.ConfigClient.GetOperation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._GetOperation._get_response( self._host, @@ -4209,6 +5791,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.config_v1.ConfigAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4247,7 +5850,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -4257,8 +5860,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -4267,6 +5872,7 @@ def __call__( http_options = ( _BaseConfigRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseConfigRestTransport._BaseListOperations._get_transcoded_request( @@ -4281,6 +5887,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.config_v1.ConfigClient.ListOperations", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConfigRestTransport._ListOperations._get_response( self._host, @@ -4300,6 +5933,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.config_v1.ConfigAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.config.v1.Config", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-config/google/cloud/config_v1/types/config.py b/packages/google-cloud-config/google/cloud/config_v1/types/config.py index fa6c40c43e32..02a34b69fa64 100644 --- a/packages/google-cloud-config/google/cloud/config_v1/types/config.py +++ b/packages/google-cloud-config/google/cloud/config_v1/types/config.py @@ -176,7 +176,7 @@ class Deployment(proto.Message): This field is a member of `oneof`_ ``_artifacts_gcs_bucket``. service_account (str): - Optional. User-specified Service Account (SA) credentials to + Required. User-specified Service Account (SA) credentials to be used when actuating resources. Format: ``projects/{projectID}/serviceAccounts/{serviceAccount}`` @@ -445,7 +445,7 @@ class TerraformBlueprint(proto.Message): Attributes: gcs_source (str): - Required. URI of an object in Google Cloud Storage. Format: + URI of an object in Google Cloud Storage. Format: ``gs://{bucket}/{object}`` URI may also specify an object version for zipped objects. @@ -453,7 +453,7 @@ class TerraformBlueprint(proto.Message): This field is a member of `oneof`_ ``source``. git_source (google.cloud.config_v1.types.GitSource): - Required. URI of a public Git repo. + URI of a public Git repo. This field is a member of `oneof`_ ``source``. input_values (MutableMapping[str, google.cloud.config_v1.types.TerraformVariable]): @@ -1004,9 +1004,11 @@ class OperationMetadata(proto.Message): requested_cancellation (bool): Output only. Identifies whether the user has requested cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value - with a [google.rpc.Status.code][google.rpc.Status.code] of - 1, corresponding to ``Code.CANCELLED``. + successfully been cancelled have + [google.longrunning.Operation.error][google.longrunning.Operation.error] + value with a + [google.rpc.Status.code][google.rpc.Status.code] of ``1``, + corresponding to ``Code.CANCELLED``. api_version (str): Output only. API version used to start the operation. @@ -1693,7 +1695,7 @@ class ListResourcesResponse(proto.Message): Attributes: resources (MutableSequence[google.cloud.config_v1.types.Resource]): - List of [Resources][]s. + List of [Resources][google.cloud.config.v1.Resource]. next_page_token (str): A token to request the next page of resources from the 'ListResources' method. The value of an @@ -1973,7 +1975,7 @@ class Preview(proto.Message): preview_mode (google.cloud.config_v1.types.Preview.PreviewMode): Optional. Current mode of preview. service_account (str): - Optional. User-specified Service Account (SA) credentials to + Required. User-specified Service Account (SA) credentials to be used when previewing resources. Format: ``projects/{projectID}/serviceAccounts/{serviceAccount}`` artifacts_gcs_bucket (str): @@ -2033,6 +2035,12 @@ class Preview(proto.Message): version constraint. Example: "=1.3.10". This field is a member of `oneof`_ ``_tf_version_constraint``. + annotations (MutableMapping[str, str]): + Optional. Arbitrary key-value metadata + storage e.g. to help client tools identifiy + preview during automation. See + https://google.aip.dev/148#annotations for + details on format and size limitations. """ class State(proto.Enum): @@ -2211,6 +2219,11 @@ class ErrorCode(proto.Enum): number=19, optional=True, ) + annotations: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=20, + ) class PreviewOperationMetadata(proto.Message): @@ -2457,7 +2470,7 @@ class ListPreviewsResponse(proto.Message): Attributes: previews (MutableSequence[google.cloud.config_v1.types.Preview]): - List of [Previews][]s. + List of [Previews][google.cloud.config.v1.Preview]. next_page_token (str): Token to be supplied to the next ListPreviews request via ``page_token`` to obtain the next set of results. diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_async.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_async.py index 7423dae1db25..ddca7d225327 100644 --- a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_async.py +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_async.py @@ -41,6 +41,7 @@ async def sample_create_preview(): # Initialize request argument(s) preview = config_v1.Preview() preview.terraform_blueprint.gcs_source = "gcs_source_value" + preview.service_account = "service_account_value" request = config_v1.CreatePreviewRequest( parent="parent_value", diff --git a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_sync.py b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_sync.py index 64ead6c3ab15..adaa14060d31 100644 --- a/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_sync.py +++ b/packages/google-cloud-config/samples/generated_samples/config_v1_generated_config_create_preview_sync.py @@ -41,6 +41,7 @@ def sample_create_preview(): # Initialize request argument(s) preview = config_v1.Preview() preview.terraform_blueprint.gcs_source = "gcs_source_value" + preview.service_account = "service_account_value" request = config_v1.CreatePreviewRequest( parent="parent_value", diff --git a/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json b/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json index b930b4cd32a8..e9c423a602a2 100644 --- a/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json +++ b/packages/google-cloud-config/samples/generated_samples/snippet_metadata_google.cloud.config.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-config", - "version": "0.1.13" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -228,7 +228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -241,12 +241,12 @@ "regionTag": "config_v1_generated_Config_CreatePreview_async", "segments": [ { - "end": 59, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 60, "start": 27, "type": "SHORT" }, @@ -256,18 +256,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -325,12 +325,12 @@ "regionTag": "config_v1_generated_Config_CreatePreview_sync", "segments": [ { - "end": 59, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 59, + "end": 60, "start": 27, "type": "SHORT" }, @@ -340,18 +340,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 49, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 56, - "start": 50, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 60, - "start": 57, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_statefile" @@ -792,7 +792,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_statefile" @@ -866,7 +866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -942,7 +942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -1023,7 +1023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.LockInfo", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.LockInfo", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", @@ -1256,7 +1256,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.ExportPreviewResultResponse", @@ -1333,7 +1333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -1409,7 +1409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -1490,7 +1490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Deployment", @@ -1570,7 +1570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Deployment", @@ -1651,7 +1651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Preview", @@ -1731,7 +1731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Preview", @@ -1812,7 +1812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Resource", @@ -1892,7 +1892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Resource", @@ -1973,7 +1973,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Revision", @@ -2053,7 +2053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Revision", @@ -2134,7 +2134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.TerraformVersion", @@ -2214,7 +2214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.TerraformVersion", @@ -2299,7 +2299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -2383,7 +2383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.types.Statefile", @@ -2464,7 +2464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentsAsyncPager", @@ -2544,7 +2544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListDeploymentsPager", @@ -2625,7 +2625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListPreviewsAsyncPager", @@ -2705,7 +2705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListPreviewsPager", @@ -2786,7 +2786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListResourcesAsyncPager", @@ -2866,7 +2866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListResourcesPager", @@ -2947,7 +2947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListRevisionsAsyncPager", @@ -3027,7 +3027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListRevisionsPager", @@ -3108,7 +3108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsAsyncPager", @@ -3188,7 +3188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.config_v1.services.config.pagers.ListTerraformVersionsPager", @@ -3269,7 +3269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3349,7 +3349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3434,7 +3434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3518,7 +3518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3603,7 +3603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3687,7 +3687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py b/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py index aca6fcb728b7..b71e304a5eff 100644 --- a/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py +++ b/packages/google-cloud-config/tests/unit/gapic/config_v1/test_config.py @@ -9797,6 +9797,7 @@ def test_list_deployments_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.list_deployments(request) @@ -9852,6 +9853,7 @@ def test_list_deployments_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_deployments(**mock_args) @@ -10042,6 +10044,7 @@ def test_get_deployment_rest_required_fields(request_type=config.GetDeploymentRe 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_deployment(request) @@ -10089,6 +10092,7 @@ def test_get_deployment_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_deployment(**mock_args) @@ -10238,6 +10242,7 @@ def test_create_deployment_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.create_deployment(request) @@ -10307,6 +10312,7 @@ def test_create_deployment_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_deployment(**mock_args) @@ -10450,6 +10456,7 @@ def test_update_deployment_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.update_deployment(request) @@ -10510,6 +10517,7 @@ def test_update_deployment_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_deployment(**mock_args) @@ -10657,6 +10665,7 @@ def test_delete_deployment_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.delete_deployment(request) @@ -10711,6 +10720,7 @@ def test_delete_deployment_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.delete_deployment(**mock_args) @@ -10849,6 +10859,7 @@ def test_list_revisions_rest_required_fields(request_type=config.ListRevisionsRe 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_revisions(request) @@ -10906,6 +10917,7 @@ def test_list_revisions_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_revisions(**mock_args) @@ -11098,6 +11110,7 @@ def test_get_revision_rest_required_fields(request_type=config.GetRevisionReques 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_revision(request) @@ -11145,6 +11158,7 @@ def test_get_revision_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_revision(**mock_args) @@ -11274,6 +11288,7 @@ def test_get_resource_rest_required_fields(request_type=config.GetResourceReques 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_resource(request) @@ -11321,6 +11336,7 @@ def test_get_resource_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_resource(**mock_args) @@ -11459,6 +11475,7 @@ def test_list_resources_rest_required_fields(request_type=config.ListResourcesRe 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_resources(request) @@ -11516,6 +11533,7 @@ def test_list_resources_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_resources(**mock_args) @@ -11716,6 +11734,7 @@ def test_export_deployment_statefile_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.export_deployment_statefile(request) @@ -11841,6 +11860,7 @@ def test_export_revision_statefile_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.export_revision_statefile(request) @@ -11967,6 +11987,7 @@ def test_import_statefile_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.import_statefile(request) @@ -12023,6 +12044,7 @@ def test_import_statefile_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.import_statefile(**mock_args) @@ -12159,6 +12181,7 @@ def test_delete_statefile_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.delete_statefile(request) @@ -12212,6 +12235,7 @@ def test_delete_statefile_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_statefile(**mock_args) @@ -12345,6 +12369,7 @@ def test_lock_deployment_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.lock_deployment(request) @@ -12390,6 +12415,7 @@ def test_lock_deployment_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.lock_deployment(**mock_args) @@ -12529,6 +12555,7 @@ def test_unlock_deployment_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.unlock_deployment(request) @@ -12583,6 +12610,7 @@ def test_unlock_deployment_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.unlock_deployment(**mock_args) @@ -12717,6 +12745,7 @@ def test_export_lock_info_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.export_lock_info(request) @@ -12764,6 +12793,7 @@ def test_export_lock_info_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.export_lock_info(**mock_args) @@ -12902,6 +12932,7 @@ def test_create_preview_rest_required_fields(request_type=config.CreatePreviewRe 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_preview(request) @@ -12963,6 +12994,7 @@ def test_create_preview_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_preview(**mock_args) @@ -13096,6 +13128,7 @@ def test_get_preview_rest_required_fields(request_type=config.GetPreviewRequest) 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_preview(request) @@ -13141,6 +13174,7 @@ def test_get_preview_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_preview(**mock_args) @@ -13278,6 +13312,7 @@ def test_list_previews_rest_required_fields(request_type=config.ListPreviewsRequ 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_previews(request) @@ -13333,6 +13368,7 @@ def test_list_previews_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_previews(**mock_args) @@ -13525,6 +13561,7 @@ def test_delete_preview_rest_required_fields(request_type=config.DeletePreviewRe 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_preview(request) @@ -13568,6 +13605,7 @@ def test_delete_preview_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.delete_preview(**mock_args) @@ -13704,6 +13742,7 @@ def test_export_preview_result_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.export_preview_result(request) @@ -13837,6 +13876,7 @@ def test_list_terraform_versions_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.list_terraform_versions(request) @@ -13892,6 +13932,7 @@ def test_list_terraform_versions_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_terraform_versions(**mock_args) @@ -14091,6 +14132,7 @@ def test_get_terraform_version_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_terraform_version(request) @@ -14138,6 +14180,7 @@ def test_get_terraform_version_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_terraform_version(**mock_args) @@ -15486,6 +15529,7 @@ def test_list_deployments_rest_bad_request(request_type=config.ListDeploymentsRe 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_deployments(request) @@ -15522,6 +15566,7 @@ def test_list_deployments_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_deployments(request) # Establish that the response is the type that we expect. @@ -15559,6 +15604,7 @@ def test_list_deployments_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 = config.ListDeploymentsResponse.to_json( config.ListDeploymentsResponse() ) @@ -15603,6 +15649,7 @@ def test_get_deployment_rest_bad_request(request_type=config.GetDeploymentReques 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_deployment(request) @@ -15653,6 +15700,7 @@ def test_get_deployment_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_deployment(request) # Establish that the response is the type that we expect. @@ -15704,6 +15752,7 @@ def test_get_deployment_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 = config.Deployment.to_json(config.Deployment()) req.return_value.content = return_value @@ -15748,6 +15797,7 @@ def test_create_deployment_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.create_deployment(request) @@ -15898,6 +15948,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_deployment(request) # Establish that the response is the type that we expect. @@ -15935,6 +15986,7 @@ def test_create_deployment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15981,6 +16033,7 @@ def test_update_deployment_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.update_deployment(request) @@ -16133,6 +16186,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_deployment(request) # Establish that the response is the type that we expect. @@ -16170,6 +16224,7 @@ def test_update_deployment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -16214,6 +16269,7 @@ def test_delete_deployment_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.delete_deployment(request) @@ -16244,6 +16300,7 @@ def test_delete_deployment_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.delete_deployment(request) # Establish that the response is the type that we expect. @@ -16281,6 +16338,7 @@ def test_delete_deployment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -16323,6 +16381,7 @@ def test_list_revisions_rest_bad_request(request_type=config.ListRevisionsReques 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_revisions(request) @@ -16359,6 +16418,7 @@ def test_list_revisions_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_revisions(request) # Establish that the response is the type that we expect. @@ -16396,6 +16456,7 @@ def test_list_revisions_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 = config.ListRevisionsResponse.to_json( config.ListRevisionsResponse() ) @@ -16442,6 +16503,7 @@ def test_get_revision_rest_bad_request(request_type=config.GetRevisionRequest): 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_revision(request) @@ -16493,6 +16555,7 @@ def test_get_revision_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_revision(request) # Establish that the response is the type that we expect. @@ -16545,6 +16608,7 @@ def test_get_revision_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 = config.Revision.to_json(config.Revision()) req.return_value.content = return_value @@ -16589,6 +16653,7 @@ def test_get_resource_rest_bad_request(request_type=config.GetResourceRequest): 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_resource(request) @@ -16628,6 +16693,7 @@ def test_get_resource_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_resource(request) # Establish that the response is the type that we expect. @@ -16666,6 +16732,7 @@ def test_get_resource_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 = config.Resource.to_json(config.Resource()) req.return_value.content = return_value @@ -16710,6 +16777,7 @@ def test_list_resources_rest_bad_request(request_type=config.ListResourcesReques 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_resources(request) @@ -16748,6 +16816,7 @@ def test_list_resources_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_resources(request) # Establish that the response is the type that we expect. @@ -16785,6 +16854,7 @@ def test_list_resources_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 = config.ListResourcesResponse.to_json( config.ListResourcesResponse() ) @@ -16831,6 +16901,7 @@ def test_export_deployment_statefile_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.export_deployment_statefile(request) @@ -16866,6 +16937,7 @@ def test_export_deployment_statefile_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.export_deployment_statefile(request) # Establish that the response is the type that we expect. @@ -16904,6 +16976,7 @@ def test_export_deployment_statefile_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 = config.Statefile.to_json(config.Statefile()) req.return_value.content = return_value @@ -16950,6 +17023,7 @@ def test_export_revision_statefile_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.export_revision_statefile(request) @@ -16987,6 +17061,7 @@ def test_export_revision_statefile_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.export_revision_statefile(request) # Establish that the response is the type that we expect. @@ -17025,6 +17100,7 @@ def test_export_revision_statefile_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 = config.Statefile.to_json(config.Statefile()) req.return_value.content = return_value @@ -17067,6 +17143,7 @@ def test_import_statefile_rest_bad_request(request_type=config.ImportStatefileRe 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.import_statefile(request) @@ -17102,6 +17179,7 @@ def test_import_statefile_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.import_statefile(request) # Establish that the response is the type that we expect. @@ -17138,6 +17216,7 @@ def test_import_statefile_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 = config.Statefile.to_json(config.Statefile()) req.return_value.content = return_value @@ -17180,6 +17259,7 @@ def test_delete_statefile_rest_bad_request(request_type=config.DeleteStatefileRe 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_statefile(request) @@ -17210,6 +17290,7 @@ def test_delete_statefile_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_statefile(request) # Establish that the response is the type that we expect. @@ -17242,6 +17323,7 @@ def test_delete_statefile_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 = config.DeleteStatefileRequest() metadata = [ @@ -17280,6 +17362,7 @@ def test_lock_deployment_rest_bad_request(request_type=config.LockDeploymentRequ 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.lock_deployment(request) @@ -17310,6 +17393,7 @@ def test_lock_deployment_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.lock_deployment(request) # Establish that the response is the type that we expect. @@ -17347,6 +17431,7 @@ def test_lock_deployment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17391,6 +17476,7 @@ def test_unlock_deployment_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.unlock_deployment(request) @@ -17421,6 +17507,7 @@ def test_unlock_deployment_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.unlock_deployment(request) # Establish that the response is the type that we expect. @@ -17458,6 +17545,7 @@ def test_unlock_deployment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17500,6 +17588,7 @@ def test_export_lock_info_rest_bad_request(request_type=config.ExportLockInfoReq 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.export_lock_info(request) @@ -17539,6 +17628,7 @@ def test_export_lock_info_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.export_lock_info(request) # Establish that the response is the type that we expect. @@ -17579,6 +17669,7 @@ def test_export_lock_info_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 = config.LockInfo.to_json(config.LockInfo()) req.return_value.content = return_value @@ -17621,6 +17712,7 @@ def test_create_preview_rest_bad_request(request_type=config.CreatePreviewReques 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_preview(request) @@ -17685,6 +17777,7 @@ def test_create_preview_rest_call_success(request_type): "logs": "logs_value", "tf_version": "tf_version_value", "tf_version_constraint": "tf_version_constraint_value", + "annotations": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -17766,6 +17859,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_preview(request) # Establish that the response is the type that we expect. @@ -17803,6 +17897,7 @@ def test_create_preview_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17845,6 +17940,7 @@ def test_get_preview_rest_bad_request(request_type=config.GetPreviewRequest): 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_preview(request) @@ -17892,6 +17988,7 @@ def test_get_preview_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_preview(request) # Establish that the response is the type that we expect. @@ -17940,6 +18037,7 @@ def test_get_preview_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 = config.Preview.to_json(config.Preview()) req.return_value.content = return_value @@ -17982,6 +18080,7 @@ def test_list_previews_rest_bad_request(request_type=config.ListPreviewsRequest) 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_previews(request) @@ -18018,6 +18117,7 @@ def test_list_previews_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_previews(request) # Establish that the response is the type that we expect. @@ -18055,6 +18155,7 @@ def test_list_previews_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 = config.ListPreviewsResponse.to_json( config.ListPreviewsResponse() ) @@ -18099,6 +18200,7 @@ def test_delete_preview_rest_bad_request(request_type=config.DeletePreviewReques 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_preview(request) @@ -18129,6 +18231,7 @@ def test_delete_preview_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.delete_preview(request) # Establish that the response is the type that we expect. @@ -18166,6 +18269,7 @@ def test_delete_preview_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -18210,6 +18314,7 @@ def test_export_preview_result_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.export_preview_result(request) @@ -18243,6 +18348,7 @@ def test_export_preview_result_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.export_preview_result(request) # Establish that the response is the type that we expect. @@ -18280,6 +18386,7 @@ def test_export_preview_result_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 = config.ExportPreviewResultResponse.to_json( config.ExportPreviewResultResponse() ) @@ -18326,6 +18433,7 @@ def test_list_terraform_versions_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.list_terraform_versions(request) @@ -18362,6 +18470,7 @@ def test_list_terraform_versions_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_terraform_versions(request) # Establish that the response is the type that we expect. @@ -18401,6 +18510,7 @@ def test_list_terraform_versions_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 = config.ListTerraformVersionsResponse.to_json( config.ListTerraformVersionsResponse() ) @@ -18449,6 +18559,7 @@ def test_get_terraform_version_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_terraform_version(request) @@ -18487,6 +18598,7 @@ def test_get_terraform_version_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_terraform_version(request) # Establish that the response is the type that we expect. @@ -18526,6 +18638,7 @@ def test_get_terraform_version_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 = config.TerraformVersion.to_json(config.TerraformVersion()) req.return_value.content = return_value @@ -18570,6 +18683,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) @@ -18600,6 +18714,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) @@ -18628,6 +18743,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) @@ -18658,6 +18774,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) @@ -18688,6 +18805,7 @@ def test_get_iam_policy_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.get_iam_policy(request) @@ -18720,6 +18838,7 @@ def test_get_iam_policy_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_iam_policy(request) @@ -18750,6 +18869,7 @@ def test_set_iam_policy_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.set_iam_policy(request) @@ -18782,6 +18902,7 @@ def test_set_iam_policy_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.set_iam_policy(request) @@ -18812,6 +18933,7 @@ def test_test_iam_permissions_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.test_iam_permissions(request) @@ -18844,6 +18966,7 @@ def test_test_iam_permissions_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.test_iam_permissions(request) @@ -18874,6 +18997,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -18904,6 +19028,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -18934,6 +19059,7 @@ def test_delete_operation_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.delete_operation(request) @@ -18964,6 +19090,7 @@ def test_delete_operation_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.delete_operation(request) @@ -18994,6 +19121,7 @@ def test_get_operation_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.get_operation(request) @@ -19024,6 +19152,7 @@ def test_get_operation_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_operation(request) @@ -19054,6 +19183,7 @@ def test_list_operations_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_operations(request) @@ -19084,6 +19214,7 @@ def test_list_operations_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_operations(request) From 9dc3d4ac473823860bb27172c0d05a37643c794a 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 18:09:04 +0500 Subject: [PATCH 07/16] feat: [google-cloud-service-management] Add support for opt-in debug logging (#13329) 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 feat: add service renaming to GoSettings 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtbWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT feat: [google-cloud-service-management] add service renaming to GoSettings PiperOrigin-RevId: 703180693 Source-Link: https://github.com/googleapis/googleapis/commit/895f2b502c7ff477c7d812b5206ec214bf1b6636 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ea2721881099c85e34656ca022d016babfd823b0 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtbWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiZWEyNzIxODgxMDk5Yzg1ZTM0NjU2Y2EwMjJkMDE2YmFiZmQ4MjNiMCJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../cloud/servicemanagement/gapic_version.py | 2 +- .../servicemanagement_v1/gapic_version.py | 2 +- .../services/service_manager/async_client.py | 168 ++- .../services/service_manager/client.py | 173 ++- .../services/service_manager/pagers.py | 48 +- .../service_manager/transports/grpc.py | 128 +- .../transports/grpc_asyncio.py | 125 +- .../service_manager/transports/rest.py | 1109 +++++++++++++++-- ...adata_google.api.servicemanagement.v1.json | 54 +- .../test_service_manager.py | 74 +- 10 files changed, 1607 insertions(+), 276 deletions(-) diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement/gapic_version.py b/packages/google-cloud-service-management/google/cloud/servicemanagement/gapic_version.py index 50d842f376d0..558c8aab67c5 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement/gapic_version.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/gapic_version.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/gapic_version.py index 50d842f376d0..558c8aab67c5 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/gapic_version.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/async_client.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/async_client.py index f715c89a98d4..b2682a175589 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/async_client.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/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, @@ -80,6 +81,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ServiceManagerTransport from .transports.grpc_asyncio import ServiceManagerGrpcAsyncIOTransport +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 ServiceManagerAsyncClient: """`Google Service Management @@ -285,6 +295,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.api.servicemanagement_v1.ServiceManagerAsyncClient`.", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "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.api.servicemanagement.v1.ServiceManager", + "credentialsType": None, + }, + ) + async def list_services( self, request: Optional[Union[servicemanager.ListServicesRequest, dict]] = None, @@ -293,7 +325,7 @@ async def list_services( consumer_id: 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.ListServicesAsyncPager: r"""Lists managed services. @@ -351,8 +383,10 @@ async def sample_list_services(): 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.servicemanagement_v1.services.service_manager.pagers.ListServicesAsyncPager: @@ -422,7 +456,7 @@ async def get_service( service_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]]] = (), ) -> resources.ManagedService: r"""Gets a managed service. Authentication is required unless the service is public. @@ -467,8 +501,10 @@ async def sample_get_service(): 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.servicemanagement_v1.types.ManagedService: @@ -532,7 +568,7 @@ async def create_service( service: Optional[resources.ManagedService] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new managed service. @@ -590,8 +626,10 @@ async def sample_create_service(): 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.api_core.operation_async.AsyncOperation: @@ -656,7 +694,7 @@ async def delete_service( service_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a managed service. This method will change the service to the ``Soft-Delete`` state for 30 days. Within this period, @@ -713,8 +751,10 @@ async def sample_delete_service(): 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.api_core.operation_async.AsyncOperation: @@ -795,7 +835,7 @@ async def undelete_service( service_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]]] = (), ) -> operation_async.AsyncOperation: r"""Revives a previously deleted managed service. The method restores the service using the configuration at @@ -851,8 +891,10 @@ async def sample_undelete_service(): 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.api_core.operation_async.AsyncOperation: @@ -926,7 +968,7 @@ async def list_service_configs( service_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]]] = (), ) -> pagers.ListServiceConfigsAsyncPager: r"""Lists the history of the service configuration for a managed service, from the newest to the oldest. @@ -974,8 +1016,10 @@ async def sample_list_service_configs(): 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.servicemanagement_v1.services.service_manager.pagers.ListServiceConfigsAsyncPager: @@ -1054,7 +1098,7 @@ async def get_service_config( view: Optional[servicemanager.GetServiceConfigRequest.ConfigView] = 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]]] = (), ) -> service_pb2.Service: r"""Gets a service configuration (version) for a managed service. @@ -1119,8 +1163,10 @@ async def sample_get_service_config(): 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.api.service_pb2.Service: @@ -1220,7 +1266,7 @@ async def create_service_config( service_config: Optional[service_pb2.Service] = 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]]] = (), ) -> service_pb2.Service: r"""Creates a new service configuration (version) for a managed service. This method only stores the service configuration. To @@ -1281,8 +1327,10 @@ async def sample_create_service_config(): 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.api.service_pb2.Service: @@ -1376,7 +1424,7 @@ async def submit_config_source( validate_only: Optional[bool] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new service configuration (version) for a managed service based on user-supplied configuration source files (for @@ -1454,8 +1502,10 @@ async def sample_submit_config_source(): 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.api_core.operation_async.AsyncOperation: @@ -1536,7 +1586,7 @@ async def list_service_rollouts( filter: 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.ListServiceRolloutsAsyncPager: r"""Lists the history of the service configuration rollouts for a managed service, from the newest to the @@ -1601,8 +1651,10 @@ async def sample_list_service_rollouts(): 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.servicemanagement_v1.services.service_manager.pagers.ListServiceRolloutsAsyncPager: @@ -1682,7 +1734,7 @@ async def get_service_rollout( rollout_id: 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]]] = (), ) -> resources.Rollout: r"""Gets a service configuration [rollout][google.api.servicemanagement.v1.Rollout]. @@ -1737,8 +1789,10 @@ async def sample_get_service_rollout(): 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.servicemanagement_v1.types.Rollout: @@ -1813,7 +1867,7 @@ async def create_service_rollout( rollout: Optional[resources.Rollout] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new service configuration rollout. Based on rollout, the Google Service Management will roll out the @@ -1886,8 +1940,10 @@ async def sample_create_service_rollout(): 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.api_core.operation_async.AsyncOperation: @@ -1967,7 +2023,7 @@ async def generate_config_report( old_config: Optional[any_pb2.Any] = 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]]] = (), ) -> servicemanager.GenerateConfigReportResponse: r"""Generates and returns a report (errors, warnings and changes from existing configurations) associated with @@ -2036,8 +2092,10 @@ async def sample_generate_config_report(): 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.servicemanagement_v1.types.GenerateConfigReportResponse: @@ -2093,7 +2151,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2104,8 +2162,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2146,7 +2206,7 @@ async def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -2159,8 +2219,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2265,7 +2327,7 @@ async def get_iam_policy( *, 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 IAM access control policy for a function. @@ -2279,8 +2341,10 @@ async def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2385,7 +2449,7 @@ async def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -2400,8 +2464,10 @@ async def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/client.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/client.py index 43b423e379fd..e9fd8b453b90 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/client.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/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.api import auth_pb2 # type: ignore from google.api import backend_pb2 # type: ignore from google.api import billing_pb2 # type: ignore @@ -589,6 +599,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( @@ -654,6 +668,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.api.servicemanagement_v1.ServiceManagerClient`.", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "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.api.servicemanagement.v1.ServiceManager", + "credentialsType": None, + }, + ) + def list_services( self, request: Optional[Union[servicemanager.ListServicesRequest, dict]] = None, @@ -662,7 +699,7 @@ def list_services( consumer_id: 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.ListServicesPager: r"""Lists managed services. @@ -720,8 +757,10 @@ def sample_list_services(): 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.servicemanagement_v1.services.service_manager.pagers.ListServicesPager: @@ -788,7 +827,7 @@ def get_service( service_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]]] = (), ) -> resources.ManagedService: r"""Gets a managed service. Authentication is required unless the service is public. @@ -833,8 +872,10 @@ def sample_get_service(): 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.servicemanagement_v1.types.ManagedService: @@ -895,7 +936,7 @@ def create_service( service: Optional[resources.ManagedService] = 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]]] = (), ) -> operation.Operation: r"""Creates a new managed service. @@ -953,8 +994,10 @@ def sample_create_service(): 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.api_core.operation.Operation: @@ -1016,7 +1059,7 @@ def delete_service( service_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]]] = (), ) -> operation.Operation: r"""Deletes a managed service. This method will change the service to the ``Soft-Delete`` state for 30 days. Within this period, @@ -1073,8 +1116,10 @@ def sample_delete_service(): 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.api_core.operation.Operation: @@ -1152,7 +1197,7 @@ def undelete_service( service_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]]] = (), ) -> operation.Operation: r"""Revives a previously deleted managed service. The method restores the service using the configuration at @@ -1208,8 +1253,10 @@ def sample_undelete_service(): 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.api_core.operation.Operation: @@ -1280,7 +1327,7 @@ def list_service_configs( service_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]]] = (), ) -> pagers.ListServiceConfigsPager: r"""Lists the history of the service configuration for a managed service, from the newest to the oldest. @@ -1328,8 +1375,10 @@ def sample_list_service_configs(): 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.servicemanagement_v1.services.service_manager.pagers.ListServiceConfigsPager: @@ -1405,7 +1454,7 @@ def get_service_config( view: Optional[servicemanager.GetServiceConfigRequest.ConfigView] = 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]]] = (), ) -> service_pb2.Service: r"""Gets a service configuration (version) for a managed service. @@ -1470,8 +1519,10 @@ def sample_get_service_config(): 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.api.service_pb2.Service: @@ -1568,7 +1619,7 @@ def create_service_config( service_config: Optional[service_pb2.Service] = 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]]] = (), ) -> service_pb2.Service: r"""Creates a new service configuration (version) for a managed service. This method only stores the service configuration. To @@ -1629,8 +1680,10 @@ def sample_create_service_config(): 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.api.service_pb2.Service: @@ -1721,7 +1774,7 @@ def submit_config_source( validate_only: Optional[bool] = 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]]] = (), ) -> operation.Operation: r"""Creates a new service configuration (version) for a managed service based on user-supplied configuration source files (for @@ -1799,8 +1852,10 @@ def sample_submit_config_source(): 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.api_core.operation.Operation: @@ -1878,7 +1933,7 @@ def list_service_rollouts( filter: 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.ListServiceRolloutsPager: r"""Lists the history of the service configuration rollouts for a managed service, from the newest to the @@ -1943,8 +1998,10 @@ def sample_list_service_rollouts(): 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.servicemanagement_v1.services.service_manager.pagers.ListServiceRolloutsPager: @@ -2021,7 +2078,7 @@ def get_service_rollout( rollout_id: 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]]] = (), ) -> resources.Rollout: r"""Gets a service configuration [rollout][google.api.servicemanagement.v1.Rollout]. @@ -2076,8 +2133,10 @@ def sample_get_service_rollout(): 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.servicemanagement_v1.types.Rollout: @@ -2149,7 +2208,7 @@ def create_service_rollout( rollout: Optional[resources.Rollout] = 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]]] = (), ) -> operation.Operation: r"""Creates a new service configuration rollout. Based on rollout, the Google Service Management will roll out the @@ -2222,8 +2281,10 @@ def sample_create_service_rollout(): 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.api_core.operation.Operation: @@ -2300,7 +2361,7 @@ def generate_config_report( old_config: Optional[any_pb2.Any] = 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]]] = (), ) -> servicemanager.GenerateConfigReportResponse: r"""Generates and returns a report (errors, warnings and changes from existing configurations) associated with @@ -2369,8 +2430,10 @@ def sample_generate_config_report(): 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.servicemanagement_v1.types.GenerateConfigReportResponse: @@ -2436,7 +2499,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2447,8 +2510,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2489,7 +2554,7 @@ def set_iam_policy( *, 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 IAM access control policy on the specified function. @@ -2502,8 +2567,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2608,7 +2675,7 @@ def get_iam_policy( *, 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 IAM access control policy for a function. @@ -2622,8 +2689,10 @@ def 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: ~.policy_pb2.Policy: Defines an Identity and Access Management (IAM) policy. @@ -2728,7 +2797,7 @@ def test_iam_permissions( *, 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"""Tests the specified IAM permissions against the IAM access control policy for a function. @@ -2743,8 +2812,10 @@ def 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: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/pagers.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/pagers.py index 10cabfe9ddc7..e73be0df9ad7 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/pagers.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/pagers.py @@ -69,7 +69,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. @@ -83,8 +83,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 = servicemanager.ListServicesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = servicemanager.ListServicesRequest(request) @@ -221,7 +225,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. @@ -235,8 +239,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 = servicemanager.ListServiceConfigsRequest(request) @@ -295,7 +301,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. @@ -309,8 +315,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 = servicemanager.ListServiceConfigsRequest(request) @@ -373,7 +381,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. @@ -387,8 +395,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 = servicemanager.ListServiceRolloutsRequest(request) @@ -447,7 +457,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. @@ -461,8 +471,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 = servicemanager.ListServiceRolloutsRequest(request) diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py index dfa7d8015709..5e1080796ceb 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/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,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.servicemanagement_v1.types import resources, servicemanager from .base import DEFAULT_CLIENT_INFO, ServiceManagerTransport +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.api.servicemanagement.v1.ServiceManager", + "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.api.servicemanagement.v1.ServiceManager", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceManagerGrpcTransport(ServiceManagerTransport): """gRPC backend transport for ServiceManager. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServices", request_serializer=servicemanager.ListServicesRequest.serialize, response_deserializer=servicemanager.ListServicesResponse.deserialize, @@ -306,7 +394,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetService", request_serializer=servicemanager.GetServiceRequest.serialize, response_deserializer=resources.ManagedService.deserialize, @@ -343,7 +431,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateService", request_serializer=servicemanager.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DeleteService", request_serializer=servicemanager.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def undelete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_service" not in self._stubs: - self._stubs["undelete_service"] = self.grpc_channel.unary_unary( + self._stubs["undelete_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/UndeleteService", request_serializer=servicemanager.UndeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -438,7 +526,7 @@ def list_service_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_service_configs" not in self._stubs: - self._stubs["list_service_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_service_configs"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServiceConfigs", request_serializer=servicemanager.ListServiceConfigsRequest.serialize, response_deserializer=servicemanager.ListServiceConfigsResponse.deserialize, @@ -465,7 +553,7 @@ def get_service_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service_config" not in self._stubs: - self._stubs["get_service_config"] = self.grpc_channel.unary_unary( + self._stubs["get_service_config"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceConfig", request_serializer=servicemanager.GetServiceConfigRequest.serialize, response_deserializer=service_pb2.Service.FromString, @@ -499,7 +587,7 @@ def create_service_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service_config" not in self._stubs: - self._stubs["create_service_config"] = self.grpc_channel.unary_unary( + self._stubs["create_service_config"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceConfig", request_serializer=servicemanager.CreateServiceConfigRequest.serialize, response_deserializer=service_pb2.Service.FromString, @@ -537,7 +625,7 @@ def submit_config_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_config_source" not in self._stubs: - self._stubs["submit_config_source"] = self.grpc_channel.unary_unary( + self._stubs["submit_config_source"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/SubmitConfigSource", request_serializer=servicemanager.SubmitConfigSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -568,7 +656,7 @@ def list_service_rollouts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_service_rollouts" not in self._stubs: - self._stubs["list_service_rollouts"] = self.grpc_channel.unary_unary( + self._stubs["list_service_rollouts"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServiceRollouts", request_serializer=servicemanager.ListServiceRolloutsRequest.serialize, response_deserializer=servicemanager.ListServiceRolloutsResponse.deserialize, @@ -595,7 +683,7 @@ def get_service_rollout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service_rollout" not in self._stubs: - self._stubs["get_service_rollout"] = self.grpc_channel.unary_unary( + self._stubs["get_service_rollout"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceRollout", request_serializer=servicemanager.GetServiceRolloutRequest.serialize, response_deserializer=resources.Rollout.deserialize, @@ -639,7 +727,7 @@ def create_service_rollout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service_rollout" not in self._stubs: - self._stubs["create_service_rollout"] = self.grpc_channel.unary_unary( + self._stubs["create_service_rollout"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceRollout", request_serializer=servicemanager.CreateServiceRolloutRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +767,7 @@ def generate_config_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_config_report" not in self._stubs: - self._stubs["generate_config_report"] = self.grpc_channel.unary_unary( + self._stubs["generate_config_report"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GenerateConfigReport", request_serializer=servicemanager.GenerateConfigReportRequest.serialize, response_deserializer=servicemanager.GenerateConfigReportResponse.deserialize, @@ -687,7 +775,7 @@ def generate_config_report( return self._stubs["generate_config_report"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_operations( @@ -701,7 +789,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -726,7 +814,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -752,7 +840,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -781,7 +869,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py index 938812c9266e..789141a54a3e 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/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,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_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.servicemanagement_v1.types import resources, servicemanager from .base import DEFAULT_CLIENT_INFO, ServiceManagerTransport from .grpc import ServiceManagerGrpcTransport +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.api.servicemanagement.v1.ServiceManager", + "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.api.servicemanagement.v1.ServiceManager", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServiceManagerGrpcAsyncIOTransport(ServiceManagerTransport): """gRPC AsyncIO backend transport for ServiceManager. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -290,7 +375,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServices", request_serializer=servicemanager.ListServicesRequest.serialize, response_deserializer=servicemanager.ListServicesResponse.deserialize, @@ -319,7 +404,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetService", request_serializer=servicemanager.GetServiceRequest.serialize, response_deserializer=resources.ManagedService.deserialize, @@ -358,7 +443,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateService", request_serializer=servicemanager.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +478,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DeleteService", request_serializer=servicemanager.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +512,7 @@ def undelete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_service" not in self._stubs: - self._stubs["undelete_service"] = self.grpc_channel.unary_unary( + self._stubs["undelete_service"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/UndeleteService", request_serializer=servicemanager.UndeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +542,7 @@ def list_service_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_service_configs" not in self._stubs: - self._stubs["list_service_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_service_configs"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServiceConfigs", request_serializer=servicemanager.ListServiceConfigsRequest.serialize, response_deserializer=servicemanager.ListServiceConfigsResponse.deserialize, @@ -486,7 +571,7 @@ def get_service_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service_config" not in self._stubs: - self._stubs["get_service_config"] = self.grpc_channel.unary_unary( + self._stubs["get_service_config"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceConfig", request_serializer=servicemanager.GetServiceConfigRequest.serialize, response_deserializer=service_pb2.Service.FromString, @@ -522,7 +607,7 @@ def create_service_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service_config" not in self._stubs: - self._stubs["create_service_config"] = self.grpc_channel.unary_unary( + self._stubs["create_service_config"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceConfig", request_serializer=servicemanager.CreateServiceConfigRequest.serialize, response_deserializer=service_pb2.Service.FromString, @@ -562,7 +647,7 @@ def submit_config_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_config_source" not in self._stubs: - self._stubs["submit_config_source"] = self.grpc_channel.unary_unary( + self._stubs["submit_config_source"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/SubmitConfigSource", request_serializer=servicemanager.SubmitConfigSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -593,7 +678,7 @@ def list_service_rollouts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_service_rollouts" not in self._stubs: - self._stubs["list_service_rollouts"] = self.grpc_channel.unary_unary( + self._stubs["list_service_rollouts"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/ListServiceRollouts", request_serializer=servicemanager.ListServiceRolloutsRequest.serialize, response_deserializer=servicemanager.ListServiceRolloutsResponse.deserialize, @@ -622,7 +707,7 @@ def get_service_rollout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service_rollout" not in self._stubs: - self._stubs["get_service_rollout"] = self.grpc_channel.unary_unary( + self._stubs["get_service_rollout"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceRollout", request_serializer=servicemanager.GetServiceRolloutRequest.serialize, response_deserializer=resources.Rollout.deserialize, @@ -667,7 +752,7 @@ def create_service_rollout( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service_rollout" not in self._stubs: - self._stubs["create_service_rollout"] = self.grpc_channel.unary_unary( + self._stubs["create_service_rollout"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceRollout", request_serializer=servicemanager.CreateServiceRolloutRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +792,7 @@ def generate_config_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_config_report" not in self._stubs: - self._stubs["generate_config_report"] = self.grpc_channel.unary_unary( + self._stubs["generate_config_report"] = self._logged_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GenerateConfigReport", request_serializer=servicemanager.GenerateConfigReportRequest.serialize, response_deserializer=servicemanager.GenerateConfigReportResponse.deserialize, @@ -810,7 +895,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: @@ -828,7 +913,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -853,7 +938,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.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -879,7 +964,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.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -908,7 +993,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.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/rest.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/rest.py index 12252f7cd1f8..08da19ee9a40 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/rest.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/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 @@ -41,6 +41,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, @@ -177,8 +185,10 @@ def post_undelete_service(self, response): def pre_create_service( self, request: servicemanager.CreateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.CreateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.CreateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_service Override in a subclass to manipulate the request or metadata @@ -200,8 +210,11 @@ def post_create_service( def pre_create_service_config( self, request: servicemanager.CreateServiceConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.CreateServiceConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.CreateServiceConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_service_config Override in a subclass to manipulate the request or metadata @@ -223,8 +236,11 @@ def post_create_service_config( def pre_create_service_rollout( self, request: servicemanager.CreateServiceRolloutRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.CreateServiceRolloutRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.CreateServiceRolloutRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_service_rollout Override in a subclass to manipulate the request or metadata @@ -246,8 +262,10 @@ def post_create_service_rollout( def pre_delete_service( self, request: servicemanager.DeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.DeleteServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -269,8 +287,11 @@ def post_delete_service( def pre_generate_config_report( self, request: servicemanager.GenerateConfigReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.GenerateConfigReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.GenerateConfigReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_config_report Override in a subclass to manipulate the request or metadata @@ -292,8 +313,10 @@ def post_generate_config_report( def pre_get_service( self, request: servicemanager.GetServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.GetServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -315,8 +338,10 @@ def post_get_service( def pre_get_service_config( self, request: servicemanager.GetServiceConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.GetServiceConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.GetServiceConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service_config Override in a subclass to manipulate the request or metadata @@ -338,8 +363,10 @@ def post_get_service_config( def pre_get_service_rollout( self, request: servicemanager.GetServiceRolloutRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.GetServiceRolloutRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.GetServiceRolloutRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service_rollout Override in a subclass to manipulate the request or metadata @@ -361,8 +388,11 @@ def post_get_service_rollout( def pre_list_service_configs( self, request: servicemanager.ListServiceConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.ListServiceConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.ListServiceConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_service_configs Override in a subclass to manipulate the request or metadata @@ -384,8 +414,11 @@ def post_list_service_configs( def pre_list_service_rollouts( self, request: servicemanager.ListServiceRolloutsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.ListServiceRolloutsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.ListServiceRolloutsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_service_rollouts Override in a subclass to manipulate the request or metadata @@ -407,8 +440,10 @@ def post_list_service_rollouts( def pre_list_services( self, request: servicemanager.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -430,8 +465,11 @@ def post_list_services( def pre_submit_config_source( self, request: servicemanager.SubmitConfigSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.SubmitConfigSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.SubmitConfigSourceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for submit_config_source Override in a subclass to manipulate the request or metadata @@ -453,8 +491,10 @@ def post_submit_config_source( def pre_undelete_service( self, request: servicemanager.UndeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[servicemanager.UndeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + servicemanager.UndeleteServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for undelete_service Override in a subclass to manipulate the request or metadata @@ -476,8 +516,10 @@ def post_undelete_service( 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 @@ -497,8 +539,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: 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 @@ -518,8 +562,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 @@ -541,8 +588,10 @@ def post_test_iam_permissions( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -719,7 +768,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create service method over HTTP. @@ -730,8 +779,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: ~.operations_pb2.Operation: @@ -744,6 +795,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseCreateService._get_http_options() ) + request, metadata = self._interceptor.pre_create_service(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseCreateService._get_transcoded_request( http_options, request @@ -758,6 +810,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.api.servicemanagement_v1.ServiceManagerClient.CreateService", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._CreateService._get_response( self._host, @@ -777,7 +856,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service(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.api.servicemanagement_v1.ServiceManagerClient.create_service", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServiceConfig( @@ -816,7 +917,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]]] = (), ) -> service_pb2.Service: r"""Call the create service config method over HTTP. @@ -827,8 +928,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: ~.service_pb2.Service: @@ -875,6 +978,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseCreateServiceConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_service_config( request, metadata ) @@ -891,6 +995,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.api.servicemanagement_v1.ServiceManagerClient.CreateServiceConfig", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateServiceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._CreateServiceConfig._get_response( self._host, @@ -912,7 +1043,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service_config(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.api.servicemanagement_v1.ServiceManagerClient.create_service_config", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateServiceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServiceRollout( @@ -951,7 +1104,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create service rollout method over HTTP. @@ -962,8 +1115,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: ~.operations_pb2.Operation: @@ -976,6 +1131,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseCreateServiceRollout._get_http_options() ) + request, metadata = self._interceptor.pre_create_service_rollout( request, metadata ) @@ -992,6 +1148,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.api.servicemanagement_v1.ServiceManagerClient.CreateServiceRollout", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateServiceRollout", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._CreateServiceRollout._get_response( self._host, @@ -1011,7 +1194,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service_rollout(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.api.servicemanagement_v1.ServiceManagerClient.create_service_rollout", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "CreateServiceRollout", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteService( @@ -1048,7 +1253,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete service method over HTTP. @@ -1059,8 +1264,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: ~.operations_pb2.Operation: @@ -1073,6 +1280,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseDeleteService._get_transcoded_request( http_options, request @@ -1083,6 +1291,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.api.servicemanagement_v1.ServiceManagerClient.DeleteService", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._DeleteService._get_response( self._host, @@ -1101,7 +1336,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_service(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.api.servicemanagement_v1.ServiceManagerClient.delete_service", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "DeleteService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateConfigReport( @@ -1140,7 +1397,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]]] = (), ) -> servicemanager.GenerateConfigReportResponse: r"""Call the generate config report method over HTTP. @@ -1151,8 +1408,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: ~.servicemanager.GenerateConfigReportResponse: @@ -1164,6 +1423,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseGenerateConfigReport._get_http_options() ) + request, metadata = self._interceptor.pre_generate_config_report( request, metadata ) @@ -1180,6 +1440,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 = 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.api.servicemanagement_v1.ServiceManagerClient.GenerateConfigReport", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GenerateConfigReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._GenerateConfigReport._get_response( self._host, @@ -1201,7 +1488,31 @@ def __call__( pb_resp = servicemanager.GenerateConfigReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_config_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + servicemanager.GenerateConfigReportResponse.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.api.servicemanagement_v1.ServiceManagerClient.generate_config_report", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GenerateConfigReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService( @@ -1238,7 +1549,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]]] = (), ) -> resources.ManagedService: r"""Call the get service method over HTTP. @@ -1248,8 +1559,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: ~.resources.ManagedService: @@ -1262,6 +1575,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseGetService._get_transcoded_request( http_options, request @@ -1274,6 +1588,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.api.servicemanagement_v1.ServiceManagerClient.GetService", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._GetService._get_response( self._host, @@ -1294,7 +1635,29 @@ def __call__( pb_resp = resources.ManagedService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ManagedService.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.api.servicemanagement_v1.ServiceManagerClient.get_service", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetServiceConfig( @@ -1331,7 +1694,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]]] = (), ) -> service_pb2.Service: r"""Call the get service config method over HTTP. @@ -1342,8 +1705,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: ~.service_pb2.Service: @@ -1390,6 +1755,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseGetServiceConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_service_config( request, metadata ) @@ -1402,6 +1768,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.api.servicemanagement_v1.ServiceManagerClient.GetServiceConfig", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetServiceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._GetServiceConfig._get_response( self._host, @@ -1422,7 +1815,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service_config(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.api.servicemanagement_v1.ServiceManagerClient.get_service_config", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetServiceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetServiceRollout( @@ -1459,7 +1874,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]]] = (), ) -> resources.Rollout: r"""Call the get service rollout method over HTTP. @@ -1470,8 +1885,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: ~.resources.Rollout: @@ -1487,6 +1904,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseGetServiceRollout._get_http_options() ) + request, metadata = self._interceptor.pre_get_service_rollout( request, metadata ) @@ -1499,6 +1917,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 = 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.api.servicemanagement_v1.ServiceManagerClient.GetServiceRollout", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetServiceRollout", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._GetServiceRollout._get_response( self._host, @@ -1519,7 +1964,29 @@ def __call__( pb_resp = resources.Rollout.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service_rollout(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Rollout.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.api.servicemanagement_v1.ServiceManagerClient.get_service_rollout", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetServiceRollout", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServiceConfigs( @@ -1556,7 +2023,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]]] = (), ) -> servicemanager.ListServiceConfigsResponse: r"""Call the list service configs method over HTTP. @@ -1567,8 +2034,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: ~.servicemanager.ListServiceConfigsResponse: @@ -1580,6 +2049,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseListServiceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_service_configs( request, metadata ) @@ -1592,6 +2062,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 = 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.api.servicemanagement_v1.ServiceManagerClient.ListServiceConfigs", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServiceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._ListServiceConfigs._get_response( self._host, @@ -1612,7 +2109,31 @@ def __call__( pb_resp = servicemanager.ListServiceConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_service_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + servicemanager.ListServiceConfigsResponse.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.api.servicemanagement_v1.ServiceManagerClient.list_service_configs", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServiceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServiceRollouts( @@ -1650,7 +2171,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]]] = (), ) -> servicemanager.ListServiceRolloutsResponse: r"""Call the list service rollouts method over HTTP. @@ -1661,8 +2182,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: ~.servicemanager.ListServiceRolloutsResponse: @@ -1674,6 +2197,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseListServiceRollouts._get_http_options() ) + request, metadata = self._interceptor.pre_list_service_rollouts( request, metadata ) @@ -1686,6 +2210,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 = 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.api.servicemanagement_v1.ServiceManagerClient.ListServiceRollouts", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServiceRollouts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._ListServiceRollouts._get_response( self._host, @@ -1706,7 +2257,31 @@ def __call__( pb_resp = servicemanager.ListServiceRolloutsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_service_rollouts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + servicemanager.ListServiceRolloutsResponse.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.api.servicemanagement_v1.ServiceManagerClient.list_service_rollouts", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServiceRollouts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices( @@ -1743,7 +2318,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]]] = (), ) -> servicemanager.ListServicesResponse: r"""Call the list services method over HTTP. @@ -1753,8 +2328,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: ~.servicemanager.ListServicesResponse: @@ -1764,6 +2341,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseListServices._get_transcoded_request( http_options, request @@ -1774,6 +2352,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 = 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.api.servicemanagement_v1.ServiceManagerClient.ListServices", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._ListServices._get_response( self._host, @@ -1794,7 +2399,31 @@ def __call__( pb_resp = servicemanager.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = servicemanager.ListServicesResponse.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.api.servicemanagement_v1.ServiceManagerClient.list_services", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SubmitConfigSource( @@ -1832,7 +2461,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]]] = (), ) -> operations_pb2.Operation: r"""Call the submit config source method over HTTP. @@ -1843,8 +2472,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: ~.operations_pb2.Operation: @@ -1857,6 +2488,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseSubmitConfigSource._get_http_options() ) + request, metadata = self._interceptor.pre_submit_config_source( request, metadata ) @@ -1873,6 +2505,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.api.servicemanagement_v1.ServiceManagerClient.SubmitConfigSource", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "SubmitConfigSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._SubmitConfigSource._get_response( self._host, @@ -1892,7 +2551,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_submit_config_source(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.api.servicemanagement_v1.ServiceManagerClient.submit_config_source", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "SubmitConfigSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteService( @@ -1929,7 +2610,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]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete service method over HTTP. @@ -1940,8 +2621,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: ~.operations_pb2.Operation: @@ -1954,6 +2637,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseUndeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_service( request, metadata ) @@ -1966,6 +2650,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.api.servicemanagement_v1.ServiceManagerClient.UndeleteService", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "UndeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._UndeleteService._get_response( self._host, @@ -1984,7 +2695,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undelete_service(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.api.servicemanagement_v1.ServiceManagerClient.undelete_service", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "UndeleteService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2143,7 +2876,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. @@ -2153,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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -2163,6 +2898,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -2177,6 +2913,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.api.servicemanagement_v1.ServiceManagerClient.GetIamPolicy", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._GetIamPolicy._get_response( self._host, @@ -2197,6 +2960,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) 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.api.servicemanagement_v1.ServiceManagerAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2238,7 +3022,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. @@ -2248,8 +3032,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: Response from SetIamPolicy method. @@ -2258,6 +3044,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2272,6 +3059,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.api.servicemanagement_v1.ServiceManagerClient.SetIamPolicy", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._SetIamPolicy._get_response( self._host, @@ -2292,6 +3106,27 @@ def __call__( resp = policy_pb2.Policy() resp = json_format.Parse(content, resp) 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.api.servicemanagement_v1.ServiceManagerAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2333,7 +3168,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. @@ -2343,8 +3178,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: Response from TestIamPermissions method. @@ -2353,6 +3190,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2369,6 +3207,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.api.servicemanagement_v1.ServiceManagerClient.TestIamPermissions", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._TestIamPermissions._get_response( self._host, @@ -2389,6 +3254,27 @@ def __call__( resp = iam_policy_pb2.TestIamPermissionsResponse() resp = json_format.Parse(content, resp) 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.api.servicemanagement_v1.ServiceManagerAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2429,7 +3315,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2439,8 +3325,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2449,6 +3337,7 @@ def __call__( http_options = ( _BaseServiceManagerRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseServiceManagerRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2459,6 +3348,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.api.servicemanagement_v1.ServiceManagerClient.ListOperations", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceManagerRestTransport._ListOperations._get_response( self._host, @@ -2478,6 +3394,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.api.servicemanagement_v1.ServiceManagerAsyncClient.ListOperations", + extra={ + "serviceName": "google.api.servicemanagement.v1.ServiceManager", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-service-management/samples/generated_samples/snippet_metadata_google.api.servicemanagement.v1.json b/packages/google-cloud-service-management/samples/generated_samples/snippet_metadata_google.api.servicemanagement.v1.json index efcefc0c6ed6..fb37827cecec 100644 --- a/packages/google-cloud-service-management/samples/generated_samples/snippet_metadata_google.api.servicemanagement.v1.json +++ b/packages/google-cloud-service-management/samples/generated_samples/snippet_metadata_google.api.servicemanagement.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-service-management", - "version": "1.11.0" + "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.api.service_pb2.Service", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.service_pb2.Service", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.GenerateConfigReportResponse", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.GenerateConfigReportResponse", @@ -884,7 +884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.service_pb2.Service", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.service_pb2.Service", @@ -1057,7 +1057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.Rollout", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.Rollout", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.ManagedService", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.types.ManagedService", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServiceConfigsAsyncPager", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServiceConfigsPager", @@ -1548,7 +1548,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServiceRolloutsAsyncPager", @@ -1632,7 +1632,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServiceRolloutsPager", @@ -1717,7 +1717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServicesAsyncPager", @@ -1801,7 +1801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.servicemanagement_v1.services.service_manager.pagers.ListServicesPager", @@ -1890,7 +1890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1978,7 +1978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2059,7 +2059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2139,7 +2139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py b/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py index 68a0bf437e46..f453ccc8db3f 100644 --- a/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py +++ b/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py @@ -6115,6 +6115,7 @@ def test_list_services_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_services(**mock_args) @@ -6308,6 +6309,7 @@ def test_get_service_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_service(request) @@ -6353,6 +6355,7 @@ def test_get_service_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_service(**mock_args) @@ -6479,6 +6482,7 @@ def test_create_service_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.create_service(request) @@ -6522,6 +6526,7 @@ def test_create_service_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_service(**mock_args) @@ -6652,6 +6657,7 @@ def test_delete_service_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.delete_service(request) @@ -6695,6 +6701,7 @@ def test_delete_service_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.delete_service(**mock_args) @@ -6827,6 +6834,7 @@ def test_undelete_service_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.undelete_service(request) @@ -6870,6 +6878,7 @@ def test_undelete_service_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.undelete_service(**mock_args) @@ -7010,6 +7019,7 @@ def test_list_service_configs_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.list_service_configs(request) @@ -7063,6 +7073,7 @@ def test_list_service_configs_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_service_configs(**mock_args) @@ -7263,6 +7274,7 @@ def test_get_service_config_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_service_config(request) @@ -7316,6 +7328,7 @@ def test_get_service_config_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_service_config(**mock_args) @@ -7453,6 +7466,7 @@ def test_create_service_config_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.create_service_config(request) @@ -7505,6 +7519,7 @@ def test_create_service_config_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_service_config(**mock_args) @@ -7641,6 +7656,7 @@ def test_submit_config_source_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.submit_config_source(request) @@ -7694,6 +7710,7 @@ def test_submit_config_source_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.submit_config_source(**mock_args) @@ -7846,6 +7863,7 @@ def test_list_service_rollouts_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.list_service_rollouts(request) @@ -7912,6 +7930,7 @@ def test_list_service_rollouts_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_service_rollouts(**mock_args) @@ -8113,6 +8132,7 @@ def test_get_service_rollout_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_service_rollout(request) @@ -8167,6 +8187,7 @@ def test_get_service_rollout_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_service_rollout(**mock_args) @@ -8306,6 +8327,7 @@ def test_create_service_rollout_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.create_service_rollout(request) @@ -8358,6 +8380,7 @@ def test_create_service_rollout_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_service_rollout(**mock_args) @@ -8489,6 +8512,7 @@ def test_generate_config_report_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.generate_config_report(request) @@ -8539,6 +8563,7 @@ def test_generate_config_report_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.generate_config_report(**mock_args) @@ -9376,6 +9401,7 @@ def test_list_services_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.list_services(request) @@ -9411,6 +9437,7 @@ def test_list_services_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_services(request) # Establish that the response is the type that we expect. @@ -9451,6 +9478,7 @@ def test_list_services_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 = servicemanager.ListServicesResponse.to_json( servicemanager.ListServicesResponse() ) @@ -9495,6 +9523,7 @@ def test_get_service_rest_bad_request(request_type=servicemanager.GetServiceRequ 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_service(request) @@ -9531,6 +9560,7 @@ def test_get_service_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_service(request) # Establish that the response is the type that we expect. @@ -9572,6 +9602,7 @@ def test_get_service_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 = resources.ManagedService.to_json(resources.ManagedService()) req.return_value.content = return_value @@ -9616,6 +9647,7 @@ def test_create_service_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.create_service(request) @@ -9717,6 +9749,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_service(request) # Establish that the response is the type that we expect. @@ -9758,6 +9791,7 @@ def test_create_service_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -9802,6 +9836,7 @@ def test_delete_service_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.delete_service(request) @@ -9832,6 +9867,7 @@ def test_delete_service_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.delete_service(request) # Establish that the response is the type that we expect. @@ -9873,6 +9909,7 @@ def test_delete_service_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -9917,6 +9954,7 @@ def test_undelete_service_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.undelete_service(request) @@ -9947,6 +9985,7 @@ def test_undelete_service_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.undelete_service(request) # Establish that the response is the type that we expect. @@ -9988,6 +10027,7 @@ def test_undelete_service_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10032,6 +10072,7 @@ def test_list_service_configs_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.list_service_configs(request) @@ -10067,6 +10108,7 @@ def test_list_service_configs_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_service_configs(request) # Establish that the response is the type that we expect. @@ -10107,6 +10149,7 @@ def test_list_service_configs_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 = servicemanager.ListServiceConfigsResponse.to_json( servicemanager.ListServiceConfigsResponse() ) @@ -10153,6 +10196,7 @@ def test_get_service_config_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_service_config(request) @@ -10188,6 +10232,7 @@ def test_get_service_config_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_service_config(request) # Establish that the response is the type that we expect. @@ -10231,6 +10276,7 @@ def test_get_service_config_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(service_pb2.Service()) req.return_value.content = return_value @@ -10275,6 +10321,7 @@ def test_create_service_config_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.create_service_config(request) @@ -10667,7 +10714,7 @@ def test_create_service_config_rest_call_success(request_type): ], }, "ruby_settings": {"common": {}}, - "go_settings": {"common": {}}, + "go_settings": {"common": {}, "renamed_services": {}}, } ], "proto_reference_documentation_uri": "proto_reference_documentation_uri_value", @@ -10760,6 +10807,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_service_config(request) # Establish that the response is the type that we expect. @@ -10803,6 +10851,7 @@ def test_create_service_config_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(service_pb2.Service()) req.return_value.content = return_value @@ -10847,6 +10896,7 @@ def test_submit_config_source_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.submit_config_source(request) @@ -10877,6 +10927,7 @@ def test_submit_config_source_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.submit_config_source(request) # Establish that the response is the type that we expect. @@ -10918,6 +10969,7 @@ def test_submit_config_source_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -10962,6 +11014,7 @@ def test_list_service_rollouts_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.list_service_rollouts(request) @@ -10997,6 +11050,7 @@ def test_list_service_rollouts_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_service_rollouts(request) # Establish that the response is the type that we expect. @@ -11037,6 +11091,7 @@ def test_list_service_rollouts_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 = servicemanager.ListServiceRolloutsResponse.to_json( servicemanager.ListServiceRolloutsResponse() ) @@ -11083,6 +11138,7 @@ def test_get_service_rollout_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_service_rollout(request) @@ -11121,6 +11177,7 @@ def test_get_service_rollout_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_service_rollout(request) # Establish that the response is the type that we expect. @@ -11164,6 +11221,7 @@ def test_get_service_rollout_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 = resources.Rollout.to_json(resources.Rollout()) req.return_value.content = return_value @@ -11208,6 +11266,7 @@ def test_create_service_rollout_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.create_service_rollout(request) @@ -11314,6 +11373,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_service_rollout(request) # Establish that the response is the type that we expect. @@ -11355,6 +11415,7 @@ def test_create_service_rollout_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -11399,6 +11460,7 @@ def test_generate_config_report_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.generate_config_report(request) @@ -11435,6 +11497,7 @@ def test_generate_config_report_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.generate_config_report(request) # Establish that the response is the type that we expect. @@ -11476,6 +11539,7 @@ def test_generate_config_report_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 = servicemanager.GenerateConfigReportResponse.to_json( servicemanager.GenerateConfigReportResponse() ) @@ -11522,6 +11586,7 @@ def test_get_iam_policy_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.get_iam_policy(request) @@ -11552,6 +11617,7 @@ def test_get_iam_policy_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_iam_policy(request) @@ -11580,6 +11646,7 @@ def test_set_iam_policy_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.set_iam_policy(request) @@ -11610,6 +11677,7 @@ def test_set_iam_policy_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.set_iam_policy(request) @@ -11638,6 +11706,7 @@ def test_test_iam_permissions_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.test_iam_permissions(request) @@ -11668,6 +11737,7 @@ def test_test_iam_permissions_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.test_iam_permissions(request) @@ -11696,6 +11766,7 @@ def test_list_operations_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_operations(request) @@ -11726,6 +11797,7 @@ def test_list_operations_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_operations(request) From d406707a668e2dcbc80bda91cbe08ef9bf06b5b7 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 18:13:23 +0500 Subject: [PATCH 08/16] feat: [google-cloud-parallelstore] Add support for opt-in debug logging (#13327) 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 feat: A new enum `DeploymentType` is added feat: A new field `deployment_type` is added to message `.google.cloud.parallelstore.v1beta.Instance` 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBhcmFsbGVsc3RvcmUvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== BEGIN_NESTED_COMMIT feat: [google-cloud-parallelstore] A new enum `DeploymentType` is added feat: A new field `deployment_type` is added to message `.google.cloud.parallelstore.v1beta.Instance` PiperOrigin-RevId: 702831788 Source-Link: https://github.com/googleapis/googleapis/commit/9ea2c56cb70d70f10fd2bef310ac9febe8d42d30 Source-Link: https://github.com/googleapis/googleapis-gen/commit/75e81055a97f04ef53e5b3f4703981f3de8852a2 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBhcmFsbGVsc3RvcmUvLk93bEJvdC55YW1sIiwiaCI6Ijc1ZTgxMDU1YTk3ZjA0ZWY1M2U1YjNmNDcwMzk4MWYzZGU4ODUyYTIifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/parallelstore/__init__.py | 2 + .../cloud/parallelstore/gapic_version.py | 2 +- .../cloud/parallelstore_v1/gapic_version.py | 2 +- .../services/parallelstore/async_client.py | 136 ++- .../services/parallelstore/client.py | 141 +++- .../services/parallelstore/pagers.py | 16 +- .../services/parallelstore/transports/grpc.py | 120 ++- .../parallelstore/transports/grpc_asyncio.py | 117 ++- .../services/parallelstore/transports/rest.py | 796 ++++++++++++++++-- .../cloud/parallelstore_v1beta/__init__.py | 2 + .../parallelstore_v1beta/gapic_version.py | 2 +- .../services/parallelstore/async_client.py | 136 ++- .../services/parallelstore/client.py | 141 +++- .../services/parallelstore/pagers.py | 16 +- .../services/parallelstore/transports/grpc.py | 120 ++- .../parallelstore/transports/grpc_asyncio.py | 117 ++- .../services/parallelstore/transports/rest.py | 796 ++++++++++++++++-- .../parallelstore_v1beta/types/__init__.py | 2 + .../types/parallelstore.py | 29 + ...etadata_google.cloud.parallelstore.v1.json | 30 +- ...ata_google.cloud.parallelstore.v1beta.json | 30 +- .../parallelstore_v1/test_parallelstore.py | 45 + .../test_parallelstore.py | 54 ++ 23 files changed, 2455 insertions(+), 397 deletions(-) diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore/__init__.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore/__init__.py index 616e8202e0bb..d1e7b045c801 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore/__init__.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore/__init__.py @@ -27,6 +27,7 @@ from google.cloud.parallelstore_v1beta.types.parallelstore import ( CreateInstanceRequest, DeleteInstanceRequest, + DeploymentType, DestinationGcsBucket, DestinationParallelstore, DirectoryStripeLevel, @@ -73,6 +74,7 @@ "TransferCounters", "TransferOperationMetadata", "UpdateInstanceRequest", + "DeploymentType", "DirectoryStripeLevel", "FileStripeLevel", "TransferType", diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore/gapic_version.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore/gapic_version.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/gapic_version.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/gapic_version.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/async_client.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/async_client.py index eb4209c23bd5..aea5749ca6ff 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/async_client.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ParallelstoreTransport from .transports.grpc_asyncio import ParallelstoreGrpcAsyncIOTransport +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 ParallelstoreAsyncClient: """Service describing handlers for resources Configures and manages @@ -291,6 +301,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.parallelstore_v1.ParallelstoreAsyncClient`.", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "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.parallelstore.v1.Parallelstore", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[parallelstore.ListInstancesRequest, dict]] = None, @@ -298,7 +330,7 @@ async def list_instances( 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.ListInstancesAsyncPager: r"""Lists all instances in a given project and location. @@ -346,8 +378,10 @@ async def sample_list_instances(): 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.parallelstore_v1.services.parallelstore.pagers.ListInstancesAsyncPager: @@ -422,7 +456,7 @@ async def get_instance( 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]]] = (), ) -> parallelstore.Instance: r"""Gets details of a single instance. @@ -465,8 +499,10 @@ async def sample_get_instance(): 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.parallelstore_v1.types.Instance: @@ -527,7 +563,7 @@ async def create_instance( instance_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Parallelstore instance in a given project and location. @@ -600,8 +636,10 @@ async def sample_create_instance(): 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.api_core.operation_async.AsyncOperation: @@ -678,7 +716,7 @@ async def update_instance( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single instance. @@ -737,8 +775,10 @@ async def sample_update_instance(): 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.api_core.operation_async.AsyncOperation: @@ -814,7 +854,7 @@ async def delete_instance( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single instance. @@ -859,8 +899,10 @@ async def sample_delete_instance(): 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.api_core.operation_async.AsyncOperation: @@ -938,7 +980,7 @@ async def import_data( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Copies data from Cloud Storage to Parallelstore. @@ -983,8 +1025,10 @@ async def sample_import_data(): 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.api_core.operation_async.AsyncOperation: @@ -1042,7 +1086,7 @@ async def export_data( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Copies data from Parallelstore to Cloud Storage. @@ -1087,8 +1131,10 @@ async def sample_export_data(): 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.api_core.operation_async.AsyncOperation: @@ -1146,7 +1192,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1157,8 +1203,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1199,7 +1247,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1210,8 +1258,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1252,7 +1302,7 @@ async def delete_operation( *, 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 long-running operation. @@ -1268,8 +1318,10 @@ async def delete_operation( 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: None """ @@ -1306,7 +1358,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1321,8 +1373,10 @@ async def cancel_operation( 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: None """ @@ -1359,7 +1413,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. @@ -1370,8 +1424,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. @@ -1412,7 +1468,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. @@ -1423,8 +1479,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-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/client.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/client.py index 865722baceb5..fbe525296e31 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/client.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -666,6 +676,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( @@ -731,6 +745,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.parallelstore_v1.ParallelstoreClient`.", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "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.parallelstore.v1.Parallelstore", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[parallelstore.ListInstancesRequest, dict]] = None, @@ -738,7 +775,7 @@ def list_instances( 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.ListInstancesPager: r"""Lists all instances in a given project and location. @@ -786,8 +823,10 @@ def sample_list_instances(): 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.parallelstore_v1.services.parallelstore.pagers.ListInstancesPager: @@ -859,7 +898,7 @@ def get_instance( 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]]] = (), ) -> parallelstore.Instance: r"""Gets details of a single instance. @@ -902,8 +941,10 @@ def sample_get_instance(): 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.parallelstore_v1.types.Instance: @@ -961,7 +1002,7 @@ def create_instance( instance_id: 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]]] = (), ) -> operation.Operation: r"""Creates a Parallelstore instance in a given project and location. @@ -1034,8 +1075,10 @@ def sample_create_instance(): 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.api_core.operation.Operation: @@ -1109,7 +1152,7 @@ def update_instance( 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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single instance. @@ -1168,8 +1211,10 @@ def sample_update_instance(): 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.api_core.operation.Operation: @@ -1242,7 +1287,7 @@ def delete_instance( 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]]] = (), ) -> operation.Operation: r"""Deletes a single instance. @@ -1287,8 +1332,10 @@ def sample_delete_instance(): 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.api_core.operation.Operation: @@ -1363,7 +1410,7 @@ def import_data( *, 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]]] = (), ) -> operation.Operation: r"""Copies data from Cloud Storage to Parallelstore. @@ -1408,8 +1455,10 @@ def sample_import_data(): 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.api_core.operation.Operation: @@ -1465,7 +1514,7 @@ def export_data( *, 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]]] = (), ) -> operation.Operation: r"""Copies data from Parallelstore to Cloud Storage. @@ -1510,8 +1559,10 @@ def sample_export_data(): 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.api_core.operation.Operation: @@ -1580,7 +1631,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1591,8 +1642,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1633,7 +1686,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1644,8 +1697,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1686,7 +1741,7 @@ def delete_operation( *, 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 long-running operation. @@ -1702,8 +1757,10 @@ def delete_operation( 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: None """ @@ -1740,7 +1797,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1755,8 +1812,10 @@ def cancel_operation( 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: None """ @@ -1793,7 +1852,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. @@ -1804,8 +1863,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. @@ -1846,7 +1907,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. @@ -1857,8 +1918,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-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/pagers.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/pagers.py index d70d39fd27ac..5656dec9d07a 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/pagers.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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 = parallelstore.ListInstancesRequest(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 = parallelstore.ListInstancesRequest(request) diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc.py index 3f3073c101af..fa376b74aea7 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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 @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.parallelstore_v1.types import parallelstore from .base import DEFAULT_CLIENT_INFO, ParallelstoreTransport +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.parallelstore.v1.Parallelstore", + "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.parallelstore.v1.Parallelstore", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParallelstoreGrpcTransport(ParallelstoreTransport): """gRPC backend transport for Parallelstore. @@ -202,7 +283,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 @@ -266,7 +352,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -292,7 +380,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ListInstances", request_serializer=parallelstore.ListInstancesRequest.serialize, response_deserializer=parallelstore.ListInstancesResponse.deserialize, @@ -318,7 +406,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/GetInstance", request_serializer=parallelstore.GetInstanceRequest.serialize, response_deserializer=parallelstore.Instance.deserialize, @@ -345,7 +433,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/CreateInstance", request_serializer=parallelstore.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +459,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/UpdateInstance", request_serializer=parallelstore.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +485,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/DeleteInstance", request_serializer=parallelstore.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +511,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ImportData", request_serializer=parallelstore.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -449,7 +537,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ExportData", request_serializer=parallelstore.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +545,7 @@ def export_data( return self._stubs["export_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -469,7 +557,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -486,7 +574,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -503,7 +591,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -522,7 +610,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -541,7 +629,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, @@ -558,7 +646,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-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc_asyncio.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc_asyncio.py index a11015f77620..d7bfb51f662e 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/grpc_asyncio.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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 @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.parallelstore_v1.types import parallelstore from .base import DEFAULT_CLIENT_INFO, ParallelstoreTransport from .grpc import ParallelstoreGrpcTransport +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.parallelstore.v1.Parallelstore", + "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.parallelstore.v1.Parallelstore", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParallelstoreGrpcAsyncIOTransport(ParallelstoreTransport): """gRPC AsyncIO backend transport for Parallelstore. @@ -249,10 +331,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 @@ -275,7 +360,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -303,7 +388,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ListInstances", request_serializer=parallelstore.ListInstancesRequest.serialize, response_deserializer=parallelstore.ListInstancesResponse.deserialize, @@ -331,7 +416,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/GetInstance", request_serializer=parallelstore.GetInstanceRequest.serialize, response_deserializer=parallelstore.Instance.deserialize, @@ -360,7 +445,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/CreateInstance", request_serializer=parallelstore.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +473,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/UpdateInstance", request_serializer=parallelstore.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +501,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/DeleteInstance", request_serializer=parallelstore.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -444,7 +529,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ImportData", request_serializer=parallelstore.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +557,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1.Parallelstore/ExportData", request_serializer=parallelstore.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -555,7 +640,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: @@ -571,7 +656,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -588,7 +673,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -605,7 +690,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -643,7 +728,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, @@ -660,7 +745,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-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/rest.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/rest.py index 4e4f50cf6b09..ba98e45637d5 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/transports/rest.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/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 @@ -39,6 +39,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, @@ -127,8 +135,10 @@ def post_update_instance(self, response): def pre_create_instance( self, request: parallelstore.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -150,8 +160,10 @@ def post_create_instance( def pre_delete_instance( self, request: parallelstore.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -173,8 +185,10 @@ def post_delete_instance( def pre_export_data( self, request: parallelstore.ExportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ExportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -196,8 +210,10 @@ def post_export_data( def pre_get_instance( self, request: parallelstore.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -219,8 +235,10 @@ def post_get_instance( def pre_import_data( self, request: parallelstore.ImportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ImportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -242,8 +260,10 @@ def post_import_data( def pre_list_instances( self, request: parallelstore.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -265,8 +285,10 @@ def post_list_instances( def pre_update_instance( self, request: parallelstore.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -288,8 +310,10 @@ def post_update_instance( 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 @@ -311,8 +335,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 @@ -334,8 +360,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -355,8 +383,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -376,8 +406,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -399,8 +431,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -615,7 +649,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -625,8 +659,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: ~.operations_pb2.Operation: @@ -639,6 +675,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -653,6 +690,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.parallelstore_v1.ParallelstoreClient.CreateInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._CreateInstance._get_response( self._host, @@ -672,7 +736,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(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.parallelstore_v1.ParallelstoreClient.create_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -709,7 +795,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -719,8 +805,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: ~.operations_pb2.Operation: @@ -733,6 +821,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -743,6 +832,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.parallelstore_v1.ParallelstoreClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._DeleteInstance._get_response( self._host, @@ -761,7 +877,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(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.parallelstore_v1.ParallelstoreClient.delete_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData( @@ -799,7 +937,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export data method over HTTP. @@ -810,8 +948,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: ~.operations_pb2.Operation: @@ -824,6 +964,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseExportData._get_http_options() ) + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = ( _BaseParallelstoreRestTransport._BaseExportData._get_transcoded_request( @@ -844,6 +985,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.parallelstore_v1.ParallelstoreClient.ExportData", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ExportData._get_response( self._host, @@ -863,7 +1031,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_data(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.parallelstore_v1.ParallelstoreClient.export_data", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -900,7 +1090,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]]] = (), ) -> parallelstore.Instance: r"""Call the get instance method over HTTP. @@ -910,8 +1100,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: ~.parallelstore.Instance: @@ -921,6 +1113,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetInstance._get_transcoded_request( http_options, request @@ -933,6 +1126,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.parallelstore_v1.ParallelstoreClient.GetInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetInstance._get_response( self._host, @@ -953,7 +1173,29 @@ def __call__( pb_resp = parallelstore.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = parallelstore.Instance.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.parallelstore_v1.ParallelstoreClient.get_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData( @@ -991,7 +1233,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import data method over HTTP. @@ -1002,8 +1244,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: ~.operations_pb2.Operation: @@ -1016,6 +1260,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseImportData._get_http_options() ) + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = ( _BaseParallelstoreRestTransport._BaseImportData._get_transcoded_request( @@ -1036,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 = 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.parallelstore_v1.ParallelstoreClient.ImportData", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ImportData._get_response( self._host, @@ -1055,7 +1327,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_data(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.parallelstore_v1.ParallelstoreClient.import_data", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -1092,7 +1386,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]]] = (), ) -> parallelstore.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -1102,8 +1396,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: ~.parallelstore.ListInstancesResponse: @@ -1115,6 +1411,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -1125,6 +1422,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 = 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.parallelstore_v1.ParallelstoreClient.ListInstances", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListInstances._get_response( self._host, @@ -1145,7 +1469,31 @@ def __call__( pb_resp = parallelstore.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = parallelstore.ListInstancesResponse.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.parallelstore_v1.ParallelstoreClient.list_instances", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -1183,7 +1531,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -1193,8 +1541,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: ~.operations_pb2.Operation: @@ -1207,6 +1557,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -1221,6 +1572,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.parallelstore_v1.ParallelstoreClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._UpdateInstance._get_response( self._host, @@ -1240,7 +1618,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(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.parallelstore_v1.ParallelstoreClient.update_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1339,7 +1739,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. @@ -1349,8 +1749,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. @@ -1359,6 +1761,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1371,6 +1774,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.parallelstore_v1.ParallelstoreClient.GetLocation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetLocation._get_response( self._host, @@ -1390,6 +1820,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.parallelstore_v1.ParallelstoreAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1430,7 +1881,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. @@ -1440,8 +1891,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. @@ -1450,6 +1903,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1460,6 +1914,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.parallelstore_v1.ParallelstoreClient.ListLocations", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListLocations._get_response( self._host, @@ -1479,6 +1960,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.parallelstore_v1.ParallelstoreAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1520,7 +2022,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1530,13 +2032,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 = ( _BaseParallelstoreRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1553,6 +2058,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.parallelstore_v1.ParallelstoreClient.CancelOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._CancelOperation._get_response( self._host, @@ -1609,7 +2141,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1619,13 +2151,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 = ( _BaseParallelstoreRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1638,6 +2173,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.parallelstore_v1.ParallelstoreClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._DeleteOperation._get_response( self._host, @@ -1693,7 +2255,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1703,8 +2265,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: operations_pb2.Operation: Response from GetOperation method. @@ -1713,6 +2277,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1723,6 +2288,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.parallelstore_v1.ParallelstoreClient.GetOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetOperation._get_response( self._host, @@ -1742,6 +2334,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.parallelstore_v1.ParallelstoreAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1782,7 +2395,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1792,8 +2405,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1802,6 +2417,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1812,6 +2428,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.parallelstore_v1.ParallelstoreClient.ListOperations", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListOperations._get_response( self._host, @@ -1831,6 +2474,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.parallelstore_v1.ParallelstoreAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.parallelstore.v1.Parallelstore", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/__init__.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/__init__.py index 07f11e978a5f..7a70dde6761a 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/__init__.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/__init__.py @@ -22,6 +22,7 @@ from .types.parallelstore import ( CreateInstanceRequest, DeleteInstanceRequest, + DeploymentType, DestinationGcsBucket, DestinationParallelstore, DirectoryStripeLevel, @@ -49,6 +50,7 @@ "ParallelstoreAsyncClient", "CreateInstanceRequest", "DeleteInstanceRequest", + "DeploymentType", "DestinationGcsBucket", "DestinationParallelstore", "DirectoryStripeLevel", diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/gapic_version.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/gapic_version.py index ed547981b7d6..558c8aab67c5 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/gapic_version.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/async_client.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/async_client.py index c91c4594822a..cb8b5406a983 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/async_client.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ParallelstoreTransport from .transports.grpc_asyncio import ParallelstoreGrpcAsyncIOTransport +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 ParallelstoreAsyncClient: """Service describing handlers for resources Configures and manages @@ -291,6 +301,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.parallelstore_v1beta.ParallelstoreAsyncClient`.", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "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.parallelstore.v1beta.Parallelstore", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[parallelstore.ListInstancesRequest, dict]] = None, @@ -298,7 +330,7 @@ async def list_instances( 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.ListInstancesAsyncPager: r"""Lists all instances in a given project and location. @@ -346,8 +378,10 @@ async def sample_list_instances(): 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.parallelstore_v1beta.services.parallelstore.pagers.ListInstancesAsyncPager: @@ -422,7 +456,7 @@ async def get_instance( 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]]] = (), ) -> parallelstore.Instance: r"""Gets details of a single instance. @@ -465,8 +499,10 @@ async def sample_get_instance(): 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.parallelstore_v1beta.types.Instance: @@ -527,7 +563,7 @@ async def create_instance( instance_id: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Parallelstore instance in a given project and location. @@ -600,8 +636,10 @@ async def sample_create_instance(): 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.api_core.operation_async.AsyncOperation: @@ -678,7 +716,7 @@ async def update_instance( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single instance. @@ -737,8 +775,10 @@ async def sample_update_instance(): 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.api_core.operation_async.AsyncOperation: @@ -814,7 +854,7 @@ async def delete_instance( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single instance. @@ -859,8 +899,10 @@ async def sample_delete_instance(): 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.api_core.operation_async.AsyncOperation: @@ -938,7 +980,7 @@ async def import_data( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Copies data from Cloud Storage to Parallelstore. @@ -983,8 +1025,10 @@ async def sample_import_data(): 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.api_core.operation_async.AsyncOperation: @@ -1042,7 +1086,7 @@ async def export_data( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Copies data from Parallelstore to Cloud Storage. @@ -1087,8 +1131,10 @@ async def sample_export_data(): 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.api_core.operation_async.AsyncOperation: @@ -1146,7 +1192,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1157,8 +1203,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1199,7 +1247,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1210,8 +1258,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1252,7 +1302,7 @@ async def delete_operation( *, 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 long-running operation. @@ -1268,8 +1318,10 @@ async def delete_operation( 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: None """ @@ -1306,7 +1358,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1321,8 +1373,10 @@ async def cancel_operation( 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: None """ @@ -1359,7 +1413,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. @@ -1370,8 +1424,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. @@ -1412,7 +1468,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. @@ -1423,8 +1479,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-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/client.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/client.py index 87c084eb9853..c6506c60be4a 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/client.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -666,6 +676,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( @@ -731,6 +745,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.parallelstore_v1beta.ParallelstoreClient`.", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "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.parallelstore.v1beta.Parallelstore", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[parallelstore.ListInstancesRequest, dict]] = None, @@ -738,7 +775,7 @@ def list_instances( 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.ListInstancesPager: r"""Lists all instances in a given project and location. @@ -786,8 +823,10 @@ def sample_list_instances(): 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.parallelstore_v1beta.services.parallelstore.pagers.ListInstancesPager: @@ -859,7 +898,7 @@ def get_instance( 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]]] = (), ) -> parallelstore.Instance: r"""Gets details of a single instance. @@ -902,8 +941,10 @@ def sample_get_instance(): 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.parallelstore_v1beta.types.Instance: @@ -961,7 +1002,7 @@ def create_instance( instance_id: 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]]] = (), ) -> operation.Operation: r"""Creates a Parallelstore instance in a given project and location. @@ -1034,8 +1075,10 @@ def sample_create_instance(): 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.api_core.operation.Operation: @@ -1109,7 +1152,7 @@ def update_instance( 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]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single instance. @@ -1168,8 +1211,10 @@ def sample_update_instance(): 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.api_core.operation.Operation: @@ -1242,7 +1287,7 @@ def delete_instance( 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]]] = (), ) -> operation.Operation: r"""Deletes a single instance. @@ -1287,8 +1332,10 @@ def sample_delete_instance(): 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.api_core.operation.Operation: @@ -1363,7 +1410,7 @@ def import_data( *, 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]]] = (), ) -> operation.Operation: r"""Copies data from Cloud Storage to Parallelstore. @@ -1408,8 +1455,10 @@ def sample_import_data(): 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.api_core.operation.Operation: @@ -1465,7 +1514,7 @@ def export_data( *, 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]]] = (), ) -> operation.Operation: r"""Copies data from Parallelstore to Cloud Storage. @@ -1510,8 +1559,10 @@ def sample_export_data(): 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.api_core.operation.Operation: @@ -1580,7 +1631,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1591,8 +1642,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1633,7 +1686,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1644,8 +1697,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1686,7 +1741,7 @@ def delete_operation( *, 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 long-running operation. @@ -1702,8 +1757,10 @@ def delete_operation( 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: None """ @@ -1740,7 +1797,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1755,8 +1812,10 @@ def cancel_operation( 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: None """ @@ -1793,7 +1852,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. @@ -1804,8 +1863,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. @@ -1846,7 +1907,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. @@ -1857,8 +1918,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-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/pagers.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/pagers.py index 895bbf055c5d..944a6bd2f216 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/pagers.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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 = parallelstore.ListInstancesRequest(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 = parallelstore.ListInstancesRequest(request) diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py index a57745ff945c..9c38aa1b1674 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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 @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.parallelstore_v1beta.types import parallelstore from .base import DEFAULT_CLIENT_INFO, ParallelstoreTransport +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.parallelstore.v1beta.Parallelstore", + "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.parallelstore.v1beta.Parallelstore", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParallelstoreGrpcTransport(ParallelstoreTransport): """gRPC backend transport for Parallelstore. @@ -202,7 +283,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 @@ -266,7 +352,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -292,7 +380,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ListInstances", request_serializer=parallelstore.ListInstancesRequest.serialize, response_deserializer=parallelstore.ListInstancesResponse.deserialize, @@ -318,7 +406,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/GetInstance", request_serializer=parallelstore.GetInstanceRequest.serialize, response_deserializer=parallelstore.Instance.deserialize, @@ -345,7 +433,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/CreateInstance", request_serializer=parallelstore.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +459,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/UpdateInstance", request_serializer=parallelstore.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +485,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/DeleteInstance", request_serializer=parallelstore.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +511,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ImportData", request_serializer=parallelstore.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -449,7 +537,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ExportData", request_serializer=parallelstore.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +545,7 @@ def export_data( return self._stubs["export_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -469,7 +557,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -486,7 +574,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -503,7 +591,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -522,7 +610,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -541,7 +629,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, @@ -558,7 +646,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-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py index 05b70a49fd18..7f8b5faaf848 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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 @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.parallelstore_v1beta.types import parallelstore from .base import DEFAULT_CLIENT_INFO, ParallelstoreTransport from .grpc import ParallelstoreGrpcTransport +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.parallelstore.v1beta.Parallelstore", + "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.parallelstore.v1beta.Parallelstore", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParallelstoreGrpcAsyncIOTransport(ParallelstoreTransport): """gRPC AsyncIO backend transport for Parallelstore. @@ -249,10 +331,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 @@ -275,7 +360,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -303,7 +388,7 @@ def list_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_instances" not in self._stubs: - self._stubs["list_instances"] = self.grpc_channel.unary_unary( + self._stubs["list_instances"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ListInstances", request_serializer=parallelstore.ListInstancesRequest.serialize, response_deserializer=parallelstore.ListInstancesResponse.deserialize, @@ -331,7 +416,7 @@ def get_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_instance" not in self._stubs: - self._stubs["get_instance"] = self.grpc_channel.unary_unary( + self._stubs["get_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/GetInstance", request_serializer=parallelstore.GetInstanceRequest.serialize, response_deserializer=parallelstore.Instance.deserialize, @@ -360,7 +445,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/CreateInstance", request_serializer=parallelstore.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +473,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/UpdateInstance", request_serializer=parallelstore.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +501,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/DeleteInstance", request_serializer=parallelstore.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -444,7 +529,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ImportData", request_serializer=parallelstore.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +557,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.parallelstore.v1beta.Parallelstore/ExportData", request_serializer=parallelstore.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -555,7 +640,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: @@ -571,7 +656,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -588,7 +673,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -605,7 +690,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -624,7 +709,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -643,7 +728,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, @@ -660,7 +745,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-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/rest.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/rest.py index 7000804f99e0..7e78fd1c3282 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/rest.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/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 @@ -39,6 +39,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, @@ -127,8 +135,10 @@ def post_update_instance(self, response): def pre_create_instance( self, request: parallelstore.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -150,8 +160,10 @@ def post_create_instance( def pre_delete_instance( self, request: parallelstore.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -173,8 +185,10 @@ def post_delete_instance( def pre_export_data( self, request: parallelstore.ExportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ExportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -196,8 +210,10 @@ def post_export_data( def pre_get_instance( self, request: parallelstore.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -219,8 +235,10 @@ def post_get_instance( def pre_import_data( self, request: parallelstore.ImportDataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ImportDataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -242,8 +260,10 @@ def post_import_data( def pre_list_instances( self, request: parallelstore.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -265,8 +285,10 @@ def post_list_instances( def pre_update_instance( self, request: parallelstore.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[parallelstore.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + parallelstore.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -288,8 +310,10 @@ def post_update_instance( 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 @@ -311,8 +335,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 @@ -334,8 +360,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -355,8 +383,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -376,8 +406,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -399,8 +431,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -614,7 +648,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -624,8 +658,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: ~.operations_pb2.Operation: @@ -638,6 +674,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -652,6 +689,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.parallelstore_v1beta.ParallelstoreClient.CreateInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._CreateInstance._get_response( self._host, @@ -671,7 +735,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(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.parallelstore_v1beta.ParallelstoreClient.create_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -708,7 +794,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -718,8 +804,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: ~.operations_pb2.Operation: @@ -732,6 +820,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -742,6 +831,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.parallelstore_v1beta.ParallelstoreClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._DeleteInstance._get_response( self._host, @@ -760,7 +876,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(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.parallelstore_v1beta.ParallelstoreClient.delete_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData( @@ -798,7 +936,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export data method over HTTP. @@ -809,8 +947,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: ~.operations_pb2.Operation: @@ -823,6 +963,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseExportData._get_http_options() ) + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = ( _BaseParallelstoreRestTransport._BaseExportData._get_transcoded_request( @@ -843,6 +984,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.parallelstore_v1beta.ParallelstoreClient.ExportData", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ExportData._get_response( self._host, @@ -862,7 +1030,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_data(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.parallelstore_v1beta.ParallelstoreClient.export_data", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -899,7 +1089,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]]] = (), ) -> parallelstore.Instance: r"""Call the get instance method over HTTP. @@ -909,8 +1099,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: ~.parallelstore.Instance: @@ -920,6 +1112,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetInstance._get_transcoded_request( http_options, request @@ -932,6 +1125,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.parallelstore_v1beta.ParallelstoreClient.GetInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetInstance._get_response( self._host, @@ -952,7 +1172,29 @@ def __call__( pb_resp = parallelstore.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = parallelstore.Instance.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.parallelstore_v1beta.ParallelstoreClient.get_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData( @@ -990,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import data method over HTTP. @@ -1001,8 +1243,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: ~.operations_pb2.Operation: @@ -1015,6 +1259,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseImportData._get_http_options() ) + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = ( _BaseParallelstoreRestTransport._BaseImportData._get_transcoded_request( @@ -1035,6 +1280,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.parallelstore_v1beta.ParallelstoreClient.ImportData", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ImportData._get_response( self._host, @@ -1054,7 +1326,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_data(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.parallelstore_v1beta.ParallelstoreClient.import_data", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -1091,7 +1385,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]]] = (), ) -> parallelstore.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -1101,8 +1395,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: ~.parallelstore.ListInstancesResponse: @@ -1114,6 +1410,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -1124,6 +1421,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 = 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.parallelstore_v1beta.ParallelstoreClient.ListInstances", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListInstances._get_response( self._host, @@ -1144,7 +1468,31 @@ def __call__( pb_resp = parallelstore.ListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = parallelstore.ListInstancesResponse.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.parallelstore_v1beta.ParallelstoreClient.list_instances", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -1182,7 +1530,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -1192,8 +1540,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: ~.operations_pb2.Operation: @@ -1206,6 +1556,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -1220,6 +1571,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.parallelstore_v1beta.ParallelstoreClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._UpdateInstance._get_response( self._host, @@ -1239,7 +1617,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(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.parallelstore_v1beta.ParallelstoreClient.update_instance", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1338,7 +1738,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. @@ -1348,8 +1748,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. @@ -1358,6 +1760,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1370,6 +1773,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.parallelstore_v1beta.ParallelstoreClient.GetLocation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetLocation._get_response( self._host, @@ -1389,6 +1819,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.parallelstore_v1beta.ParallelstoreAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1429,7 +1880,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. @@ -1439,8 +1890,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. @@ -1449,6 +1902,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1459,6 +1913,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.parallelstore_v1beta.ParallelstoreClient.ListLocations", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListLocations._get_response( self._host, @@ -1478,6 +1959,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.parallelstore_v1beta.ParallelstoreAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1518,7 +2020,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1528,13 +2030,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 = ( _BaseParallelstoreRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1547,6 +2052,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.parallelstore_v1beta.ParallelstoreClient.CancelOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._CancelOperation._get_response( self._host, @@ -1602,7 +2134,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1612,13 +2144,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 = ( _BaseParallelstoreRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1631,6 +2166,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.parallelstore_v1beta.ParallelstoreClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._DeleteOperation._get_response( self._host, @@ -1686,7 +2248,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1696,8 +2258,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: operations_pb2.Operation: Response from GetOperation method. @@ -1706,6 +2270,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1716,6 +2281,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.parallelstore_v1beta.ParallelstoreClient.GetOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._GetOperation._get_response( self._host, @@ -1735,6 +2327,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.parallelstore_v1beta.ParallelstoreAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1775,7 +2388,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1785,8 +2398,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1795,6 +2410,7 @@ def __call__( http_options = ( _BaseParallelstoreRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseParallelstoreRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1805,6 +2421,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.parallelstore_v1beta.ParallelstoreClient.ListOperations", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParallelstoreRestTransport._ListOperations._get_response( self._host, @@ -1824,6 +2467,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.parallelstore_v1beta.ParallelstoreAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.parallelstore.v1beta.Parallelstore", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/__init__.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/__init__.py index faadce2e0eff..0c066a384cb9 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/__init__.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/__init__.py @@ -16,6 +16,7 @@ from .parallelstore import ( CreateInstanceRequest, DeleteInstanceRequest, + DeploymentType, DestinationGcsBucket, DestinationParallelstore, DirectoryStripeLevel, @@ -60,6 +61,7 @@ "TransferCounters", "TransferOperationMetadata", "UpdateInstanceRequest", + "DeploymentType", "DirectoryStripeLevel", "FileStripeLevel", "TransferType", diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/parallelstore.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/parallelstore.py index 7d28780d668e..26eb73f09432 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/parallelstore.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/types/parallelstore.py @@ -27,6 +27,7 @@ "TransferType", "FileStripeLevel", "DirectoryStripeLevel", + "DeploymentType", "Instance", "ListInstancesRequest", "ListInstancesResponse", @@ -107,6 +108,23 @@ class DirectoryStripeLevel(proto.Enum): DIRECTORY_STRIPE_LEVEL_MAX = 3 +class DeploymentType(proto.Enum): + r"""Represents the deployment type for the instance. + + Values: + DEPLOYMENT_TYPE_UNSPECIFIED (0): + Default Deployment Type + It is equivalent to SCRATCH + SCRATCH (1): + Scratch + PERSISTENT (2): + Persistent + """ + DEPLOYMENT_TYPE_UNSPECIFIED = 0 + SCRATCH = 1 + PERSISTENT = 2 + + class Instance(proto.Message): r"""A Parallelstore instance. @@ -178,6 +196,12 @@ class Instance(proto.Message): directories. - ``DIRECTORY_STRIPE_LEVEL_MAX``: recommended for directories with a large number of files. + deployment_type (google.cloud.parallelstore_v1beta.types.DeploymentType): + Optional. The deployment type of the instance. Allowed + values are: + + - ``SCRATCH``: the instance is a scratch instance. + - ``PERSISTENT``: the instance is a persistent instance. """ class State(proto.Enum): @@ -266,6 +290,11 @@ class State(proto.Enum): number=16, enum="DirectoryStripeLevel", ) + deployment_type: "DeploymentType" = proto.Field( + proto.ENUM, + number=17, + enum="DeploymentType", + ) class ListInstancesRequest(proto.Message): diff --git a/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1.json b/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1.json index 3bc974c48784..30bc2a5b8355 100644 --- a/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1.json +++ b/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-parallelstore", - "version": "0.2.6" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -381,7 +381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1.types.Instance", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1.types.Instance", @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1.services.parallelstore.pagers.ListInstancesAsyncPager", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1.services.parallelstore.pagers.ListInstancesPager", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1101,7 +1101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1beta.json b/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1beta.json index c432a6a1b69d..db5492278bf9 100644 --- a/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1beta.json +++ b/packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-parallelstore", - "version": "0.2.6" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -381,7 +381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1beta.types.Instance", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1beta.types.Instance", @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1beta.services.parallelstore.pagers.ListInstancesAsyncPager", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.parallelstore_v1beta.services.parallelstore.pagers.ListInstancesPager", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1101,7 +1101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1/test_parallelstore.py b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1/test_parallelstore.py index e2161b9b9b5a..7486ac09e56f 100644 --- a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1/test_parallelstore.py +++ b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1/test_parallelstore.py @@ -3594,6 +3594,7 @@ def test_list_instances_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.list_instances(request) @@ -3649,6 +3650,7 @@ def test_list_instances_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_instances(**mock_args) @@ -3842,6 +3844,7 @@ def test_get_instance_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_instance(request) @@ -3889,6 +3892,7 @@ def test_get_instance_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_instance(**mock_args) @@ -4035,6 +4039,7 @@ def test_create_instance_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.create_instance(request) @@ -4100,6 +4105,7 @@ def test_create_instance_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_instance(**mock_args) @@ -4236,6 +4242,7 @@ def test_update_instance_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.update_instance(request) @@ -4295,6 +4302,7 @@ def test_update_instance_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_instance(**mock_args) @@ -4430,6 +4438,7 @@ def test_delete_instance_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.delete_instance(request) @@ -4475,6 +4484,7 @@ def test_delete_instance_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.delete_instance(**mock_args) @@ -4605,6 +4615,7 @@ def test_import_data_rest_required_fields(request_type=parallelstore.ImportDataR 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.import_data(request) @@ -4724,6 +4735,7 @@ def test_export_data_rest_required_fields(request_type=parallelstore.ExportDataR 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.export_data(request) @@ -5226,6 +5238,7 @@ def test_list_instances_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.list_instances(request) @@ -5262,6 +5275,7 @@ def test_list_instances_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_instances(request) # Establish that the response is the type that we expect. @@ -5303,6 +5317,7 @@ def test_list_instances_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 = parallelstore.ListInstancesResponse.to_json( parallelstore.ListInstancesResponse() ) @@ -5347,6 +5362,7 @@ def test_get_instance_rest_bad_request(request_type=parallelstore.GetInstanceReq 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_instance(request) @@ -5392,6 +5408,7 @@ def test_get_instance_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_instance(request) # Establish that the response is the type that we expect. @@ -5448,6 +5465,7 @@ def test_get_instance_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 = parallelstore.Instance.to_json(parallelstore.Instance()) req.return_value.content = return_value @@ -5492,6 +5510,7 @@ def test_create_instance_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.create_instance(request) @@ -5605,6 +5624,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_instance(request) # Establish that the response is the type that we expect. @@ -5646,6 +5666,7 @@ def test_create_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5692,6 +5713,7 @@ def test_update_instance_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.update_instance(request) @@ -5807,6 +5829,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_instance(request) # Establish that the response is the type that we expect. @@ -5848,6 +5871,7 @@ def test_update_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5892,6 +5916,7 @@ def test_delete_instance_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.delete_instance(request) @@ -5922,6 +5947,7 @@ def test_delete_instance_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.delete_instance(request) # Establish that the response is the type that we expect. @@ -5963,6 +5989,7 @@ def test_delete_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6005,6 +6032,7 @@ def test_import_data_rest_bad_request(request_type=parallelstore.ImportDataReque 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.import_data(request) @@ -6035,6 +6063,7 @@ def test_import_data_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.import_data(request) # Establish that the response is the type that we expect. @@ -6076,6 +6105,7 @@ def test_import_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6118,6 +6148,7 @@ def test_export_data_rest_bad_request(request_type=parallelstore.ExportDataReque 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.export_data(request) @@ -6148,6 +6179,7 @@ def test_export_data_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.export_data(request) # Establish that the response is the type that we expect. @@ -6189,6 +6221,7 @@ def test_export_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6233,6 +6266,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) @@ -6263,6 +6297,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) @@ -6291,6 +6326,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) @@ -6321,6 +6357,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) @@ -6351,6 +6388,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6381,6 +6419,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6411,6 +6450,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6441,6 +6481,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6471,6 +6512,7 @@ def test_get_operation_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.get_operation(request) @@ -6501,6 +6543,7 @@ def test_get_operation_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_operation(request) @@ -6531,6 +6574,7 @@ def test_list_operations_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_operations(request) @@ -6561,6 +6605,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py index 9d1b6174d9da..933dcda7380b 100644 --- a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py +++ b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py @@ -1629,6 +1629,7 @@ def test_get_instance(request_type, transport: str = "grpc"): effective_reserved_ip_range="effective_reserved_ip_range_value", file_stripe_level=parallelstore.FileStripeLevel.FILE_STRIPE_LEVEL_MIN, directory_stripe_level=parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN, + deployment_type=parallelstore.DeploymentType.SCRATCH, ) response = client.get_instance(request) @@ -1657,6 +1658,7 @@ def test_get_instance(request_type, transport: str = "grpc"): response.directory_stripe_level == parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN ) + assert response.deployment_type == parallelstore.DeploymentType.SCRATCH def test_get_instance_non_empty_request_with_auto_populated_field(): @@ -1793,6 +1795,7 @@ async def test_get_instance_async( effective_reserved_ip_range="effective_reserved_ip_range_value", file_stripe_level=parallelstore.FileStripeLevel.FILE_STRIPE_LEVEL_MIN, directory_stripe_level=parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN, + deployment_type=parallelstore.DeploymentType.SCRATCH, ) ) response = await client.get_instance(request) @@ -1822,6 +1825,7 @@ async def test_get_instance_async( response.directory_stripe_level == parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN ) + assert response.deployment_type == parallelstore.DeploymentType.SCRATCH @pytest.mark.asyncio @@ -3594,6 +3598,7 @@ def test_list_instances_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.list_instances(request) @@ -3649,6 +3654,7 @@ def test_list_instances_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_instances(**mock_args) @@ -3843,6 +3849,7 @@ def test_get_instance_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_instance(request) @@ -3890,6 +3897,7 @@ def test_get_instance_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_instance(**mock_args) @@ -4037,6 +4045,7 @@ def test_create_instance_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.create_instance(request) @@ -4102,6 +4111,7 @@ def test_create_instance_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_instance(**mock_args) @@ -4239,6 +4249,7 @@ def test_update_instance_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.update_instance(request) @@ -4298,6 +4309,7 @@ def test_update_instance_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_instance(**mock_args) @@ -4433,6 +4445,7 @@ def test_delete_instance_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.delete_instance(request) @@ -4478,6 +4491,7 @@ def test_delete_instance_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.delete_instance(**mock_args) @@ -4609,6 +4623,7 @@ def test_import_data_rest_required_fields(request_type=parallelstore.ImportDataR 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.import_data(request) @@ -4728,6 +4743,7 @@ def test_export_data_rest_required_fields(request_type=parallelstore.ExportDataR 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.export_data(request) @@ -5065,6 +5081,7 @@ async def test_get_instance_empty_call_grpc_asyncio(): effective_reserved_ip_range="effective_reserved_ip_range_value", file_stripe_level=parallelstore.FileStripeLevel.FILE_STRIPE_LEVEL_MIN, directory_stripe_level=parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN, + deployment_type=parallelstore.DeploymentType.SCRATCH, ) ) await client.get_instance(request=None) @@ -5230,6 +5247,7 @@ def test_list_instances_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.list_instances(request) @@ -5266,6 +5284,7 @@ def test_list_instances_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_instances(request) # Establish that the response is the type that we expect. @@ -5307,6 +5326,7 @@ def test_list_instances_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 = parallelstore.ListInstancesResponse.to_json( parallelstore.ListInstancesResponse() ) @@ -5351,6 +5371,7 @@ def test_get_instance_rest_bad_request(request_type=parallelstore.GetInstanceReq 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_instance(request) @@ -5385,6 +5406,7 @@ def test_get_instance_rest_call_success(request_type): effective_reserved_ip_range="effective_reserved_ip_range_value", file_stripe_level=parallelstore.FileStripeLevel.FILE_STRIPE_LEVEL_MIN, directory_stripe_level=parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN, + deployment_type=parallelstore.DeploymentType.SCRATCH, ) # Wrap the value into a proper Response obj @@ -5396,6 +5418,7 @@ def test_get_instance_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_instance(request) # Establish that the response is the type that we expect. @@ -5417,6 +5440,7 @@ def test_get_instance_rest_call_success(request_type): response.directory_stripe_level == parallelstore.DirectoryStripeLevel.DIRECTORY_STRIPE_LEVEL_MIN ) + assert response.deployment_type == parallelstore.DeploymentType.SCRATCH @pytest.mark.parametrize("null_interceptor", [True, False]) @@ -5452,6 +5476,7 @@ def test_get_instance_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 = parallelstore.Instance.to_json(parallelstore.Instance()) req.return_value.content = return_value @@ -5496,6 +5521,7 @@ def test_create_instance_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.create_instance(request) @@ -5528,6 +5554,7 @@ def test_create_instance_rest_call_success(request_type): "effective_reserved_ip_range": "effective_reserved_ip_range_value", "file_stripe_level": 1, "directory_stripe_level": 1, + "deployment_type": 1, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -5609,6 +5636,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_instance(request) # Establish that the response is the type that we expect. @@ -5650,6 +5678,7 @@ def test_create_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5696,6 +5725,7 @@ def test_update_instance_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.update_instance(request) @@ -5730,6 +5760,7 @@ def test_update_instance_rest_call_success(request_type): "effective_reserved_ip_range": "effective_reserved_ip_range_value", "file_stripe_level": 1, "directory_stripe_level": 1, + "deployment_type": 1, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -5811,6 +5842,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_instance(request) # Establish that the response is the type that we expect. @@ -5852,6 +5884,7 @@ def test_update_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5896,6 +5929,7 @@ def test_delete_instance_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.delete_instance(request) @@ -5926,6 +5960,7 @@ def test_delete_instance_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.delete_instance(request) # Establish that the response is the type that we expect. @@ -5967,6 +6002,7 @@ def test_delete_instance_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6009,6 +6045,7 @@ def test_import_data_rest_bad_request(request_type=parallelstore.ImportDataReque 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.import_data(request) @@ -6039,6 +6076,7 @@ def test_import_data_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.import_data(request) # Establish that the response is the type that we expect. @@ -6080,6 +6118,7 @@ def test_import_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6122,6 +6161,7 @@ def test_export_data_rest_bad_request(request_type=parallelstore.ExportDataReque 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.export_data(request) @@ -6152,6 +6192,7 @@ def test_export_data_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.export_data(request) # Establish that the response is the type that we expect. @@ -6193,6 +6234,7 @@ def test_export_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6237,6 +6279,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) @@ -6267,6 +6310,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) @@ -6295,6 +6339,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) @@ -6325,6 +6370,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) @@ -6355,6 +6401,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6385,6 +6432,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6415,6 +6463,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6445,6 +6494,7 @@ def test_delete_operation_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.delete_operation(request) @@ -6475,6 +6525,7 @@ def test_get_operation_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.get_operation(request) @@ -6505,6 +6556,7 @@ def test_get_operation_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_operation(request) @@ -6535,6 +6587,7 @@ def test_list_operations_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_operations(request) @@ -6565,6 +6618,7 @@ def test_list_operations_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_operations(request) From ce5c35ad8b98f548a3dc8bd862646702b1d9974b 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 18:17:44 +0500 Subject: [PATCH 09/16] feat: [google-shopping-merchant-products] Add support for opt-in debug logging (#13333) 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 fix!: Changed repeated flag of an existing field `gtin` in message `.google.shopping.merchant.products.v1beta.Attributes` fix!: An existing field `gtin` is moved out of oneof in message `.google.shopping.merchant.products.v1beta.Attributes` docs: A comment for message `ProductInput` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.ProductInput` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.DeleteProductInputRequest` is changed docs: A comment for message `Product` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.Product` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.GetProductRequest` is changed docs: A comment for field `page_size` in message `.google.shopping.merchant.products.v1beta.ListProductsRequest` is changed docs: A comment for field `gtin` in message `.google.shopping.merchant.products.v1beta.Attributes` is changed docs: A comment for field `tax_category` in message `.google.shopping.merchant.products.v1beta.Attributes` is changed docs: A comment for field `min_handling_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `max_handling_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `min_transit_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `max_transit_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed feat: A new field `member_price_effective_date` is added to message `.google.shopping.merchant.products.v1beta.LoyaltyProgram` feat: A new field `shipping_label` is added to message `.google.shopping.merchant.products.v1beta.LoyaltyProgram` 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLW1lcmNoYW50LXByb2R1Y3RzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= BEGIN_NESTED_COMMIT fix!: [google-shopping-merchant-products] Changed repeated flag of an existing field `gtin` in message `.google.shopping.merchant.products.v1beta.Attributes` fix!: An existing field `gtin` is moved out of oneof in message `.google.shopping.merchant.products.v1beta.Attributes` docs: A comment for message `ProductInput` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.ProductInput` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.DeleteProductInputRequest` is changed docs: A comment for message `Product` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.Product` is changed docs: A comment for field `name` in message `.google.shopping.merchant.products.v1beta.GetProductRequest` is changed docs: A comment for field `page_size` in message `.google.shopping.merchant.products.v1beta.ListProductsRequest` is changed docs: A comment for field `gtin` in message `.google.shopping.merchant.products.v1beta.Attributes` is changed docs: A comment for field `tax_category` in message `.google.shopping.merchant.products.v1beta.Attributes` is changed docs: A comment for field `min_handling_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `max_handling_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `min_transit_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed docs: A comment for field `max_transit_time` in message `.google.shopping.merchant.products.v1beta.Shipping` is changed feat: A new field `member_price_effective_date` is added to message `.google.shopping.merchant.products.v1beta.LoyaltyProgram` feat: A new field `shipping_label` is added to message `.google.shopping.merchant.products.v1beta.LoyaltyProgram` PiperOrigin-RevId: 704281512 Source-Link: https://github.com/googleapis/googleapis/commit/0f1beb9507162a4cbe3a2b1437922a6289ae5f24 Source-Link: https://github.com/googleapis/googleapis-gen/commit/5429d7d40b248ad0347e916defee17ba51164011 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLXNob3BwaW5nLW1lcmNoYW50LXByb2R1Y3RzLy5Pd2xCb3QueWFtbCIsImgiOiI1NDI5ZDdkNDBiMjQ4YWQwMzQ3ZTkxNmRlZmVlMTdiYTUxMTY0MDExIn0= END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../merchant_products/gapic_version.py | 2 +- .../merchant_products_v1beta/gapic_version.py | 2 +- .../product_inputs_service/async_client.py | 66 +++++++-- .../services/product_inputs_service/client.py | 71 +++++++-- .../product_inputs_service/transports/grpc.py | 94 +++++++++++- .../transports/grpc_asyncio.py | 93 +++++++++++- .../product_inputs_service/transports/rest.py | 124 ++++++++++++++-- .../services/products_service/async_client.py | 56 ++++++- .../services/products_service/client.py | 61 +++++++- .../services/products_service/pagers.py | 16 +- .../products_service/transports/grpc.py | 94 +++++++++++- .../transports/grpc_asyncio.py | 93 +++++++++++- .../products_service/transports/rest.py | 140 ++++++++++++++++-- .../types/productinputs.py | 22 ++- .../types/products.py | 20 ++- .../types/products_common.py | 70 ++++++--- ...gle.shopping.merchant.products.v1beta.json | 18 +-- .../test_product_inputs_service.py | 15 +- .../test_products_service.py | 10 ++ 19 files changed, 925 insertions(+), 142 deletions(-) diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products/gapic_version.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products/gapic_version.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/gapic_version.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/gapic_version.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/async_client.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/async_client.py index 54aac15fa95d..5bab64ae87db 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/async_client.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductInputsServiceTransport from .transports.grpc_asyncio import ProductInputsServiceGrpcAsyncIOTransport +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 ProductInputsServiceAsyncClient: """Service to use ProductInput resource. @@ -268,13 +278,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.shopping.merchant.products_v1beta.ProductInputsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService", + "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.shopping.merchant.products.v1beta.ProductInputsService", + "credentialsType": None, + }, + ) + async def insert_product_input( self, request: Optional[Union[productinputs.InsertProductInputRequest, dict]] = 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]]] = (), ) -> productinputs.ProductInput: r"""Uploads a product input to your Merchant Center account. If an input with the same contentLanguage, @@ -326,8 +358,10 @@ async def sample_insert_product_input(): 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.shopping.merchant_products_v1beta.types.ProductInput: @@ -336,7 +370,7 @@ async def sample_insert_product_input(): Shopping ads, or across Google surfaces. Product inputs, rules and supplemental data source data are combined to create the processed - [product][google.shopping.content.bundles.Products.Product]. + [Product][google.shopping.merchant.products.v1beta.Product]. Required product input attributes to pass data validation checks are primarily defined in the @@ -344,10 +378,10 @@ async def sample_insert_product_input(): Specification](\ https://support.google.com/merchants/answer/188494). The following attributes are required: - [feedLabel][google.shopping.content.bundles.Products.feed_label], - [contentLanguage][google.shopping.content.bundles.Products.content_language] + [feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label], + [contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language] and - [offerId][google.shopping.content.bundles.Products.offer_id]. + [offerId][google.shopping.merchant.products.v1beta.Product.offer_id]. After inserting, updating, or deleting a product input, it may take several minutes before the @@ -398,7 +432,7 @@ async def delete_product_input( 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 product input from your Merchant Center account. @@ -435,9 +469,13 @@ async def sample_delete_product_input(): The request object. Request message for the DeleteProductInput method. name (:class:`str`): - Required. The name of the product - input resource to delete. Format: - accounts/{account}/productInputs/{product} + Required. The name of the product input resource to + delete. Format: + accounts/{account}/productInputs/{product} where the + last section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is + "accounts/123/productInputs/online~en~US~sku123" This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -445,8 +483,10 @@ async def sample_delete_product_input(): 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 diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/client.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/client.py index d6f5db5701d4..86a77b8d40d5 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/client.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/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.shopping.type.types import types from google.shopping.merchant_products_v1beta.types import ( @@ -602,6 +612,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( @@ -668,13 +682,36 @@ 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.shopping.merchant.products_v1beta.ProductInputsServiceClient`.", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService", + "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.shopping.merchant.products.v1beta.ProductInputsService", + "credentialsType": None, + }, + ) + def insert_product_input( self, request: Optional[Union[productinputs.InsertProductInputRequest, dict]] = 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]]] = (), ) -> productinputs.ProductInput: r"""Uploads a product input to your Merchant Center account. If an input with the same contentLanguage, @@ -726,8 +763,10 @@ def sample_insert_product_input(): 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.shopping.merchant_products_v1beta.types.ProductInput: @@ -736,7 +775,7 @@ def sample_insert_product_input(): Shopping ads, or across Google surfaces. Product inputs, rules and supplemental data source data are combined to create the processed - [product][google.shopping.content.bundles.Products.Product]. + [Product][google.shopping.merchant.products.v1beta.Product]. Required product input attributes to pass data validation checks are primarily defined in the @@ -744,10 +783,10 @@ def sample_insert_product_input(): Specification](\ https://support.google.com/merchants/answer/188494). The following attributes are required: - [feedLabel][google.shopping.content.bundles.Products.feed_label], - [contentLanguage][google.shopping.content.bundles.Products.content_language] + [feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label], + [contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language] and - [offerId][google.shopping.content.bundles.Products.offer_id]. + [offerId][google.shopping.merchant.products.v1beta.Product.offer_id]. After inserting, updating, or deleting a product input, it may take several minutes before the @@ -796,7 +835,7 @@ def delete_product_input( 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 product input from your Merchant Center account. @@ -833,9 +872,13 @@ def sample_delete_product_input(): The request object. Request message for the DeleteProductInput method. name (str): - Required. The name of the product - input resource to delete. Format: - accounts/{account}/productInputs/{product} + Required. The name of the product input resource to + delete. Format: + accounts/{account}/productInputs/{product} where the + last section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is + "accounts/123/productInputs/online~en~US~sku123" This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -843,8 +886,10 @@ def sample_delete_product_input(): 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 diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc.py index 1045506e096b..da67945e49ec 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.merchant_products_v1beta.types import productinputs from .base import DEFAULT_CLIENT_INFO, ProductInputsServiceTransport +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.shopping.merchant.products.v1beta.ProductInputsService", + "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.shopping.merchant.products.v1beta.ProductInputsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductInputsServiceGrpcTransport(ProductInputsServiceTransport): """gRPC backend transport for ProductInputsService. @@ -181,7 +262,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 insert_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "insert_product_input" not in self._stubs: - self._stubs["insert_product_input"] = self.grpc_channel.unary_unary( + self._stubs["insert_product_input"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductInputsService/InsertProductInput", request_serializer=productinputs.InsertProductInputRequest.serialize, response_deserializer=productinputs.ProductInput.deserialize, @@ -294,7 +380,7 @@ def delete_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_input" not in self._stubs: - self._stubs["delete_product_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_input"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductInputsService/DeleteProductInput", request_serializer=productinputs.DeleteProductInputRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -302,7 +388,7 @@ def delete_product_input( return self._stubs["delete_product_input"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc_asyncio.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc_asyncio.py index 27866595f4d4..822b20c4e4df 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.merchant_products_v1beta.types import productinputs from .base import DEFAULT_CLIENT_INFO, ProductInputsServiceTransport from .grpc import ProductInputsServiceGrpcTransport +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.shopping.merchant.products.v1beta.ProductInputsService", + "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.shopping.merchant.products.v1beta.ProductInputsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductInputsServiceGrpcAsyncIOTransport(ProductInputsServiceTransport): """gRPC AsyncIO backend transport for ProductInputsService. @@ -228,10 +310,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 @@ -272,7 +357,7 @@ def insert_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "insert_product_input" not in self._stubs: - self._stubs["insert_product_input"] = self.grpc_channel.unary_unary( + self._stubs["insert_product_input"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductInputsService/InsertProductInput", request_serializer=productinputs.InsertProductInputRequest.serialize, response_deserializer=productinputs.ProductInput.deserialize, @@ -304,7 +389,7 @@ def delete_product_input( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_product_input" not in self._stubs: - self._stubs["delete_product_input"] = self.grpc_channel.unary_unary( + self._stubs["delete_product_input"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductInputsService/DeleteProductInput", request_serializer=productinputs.DeleteProductInputRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -332,7 +417,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: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/rest.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/rest.py index d473a49ec5aa..983e5ffa9fbc 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/transports/rest.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/product_inputs_service/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 @@ -38,6 +38,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, @@ -82,8 +90,10 @@ def post_insert_product_input(self, response): def pre_delete_product_input( self, request: productinputs.DeleteProductInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[productinputs.DeleteProductInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + productinputs.DeleteProductInputRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_product_input Override in a subclass to manipulate the request or metadata @@ -94,8 +104,10 @@ def pre_delete_product_input( def pre_insert_product_input( self, request: productinputs.InsertProductInputRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[productinputs.InsertProductInputRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + productinputs.InsertProductInputRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert_product_input Override in a subclass to manipulate the request or metadata @@ -237,7 +249,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 product input method over HTTP. @@ -248,13 +260,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 = ( _BaseProductInputsServiceRestTransport._BaseDeleteProductInput._get_http_options() ) + request, metadata = self._interceptor.pre_delete_product_input( request, metadata ) @@ -267,6 +282,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.shopping.merchant.products_v1beta.ProductInputsServiceClient.DeleteProductInput", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService", + "rpcName": "DeleteProductInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductInputsServiceRestTransport._DeleteProductInput._get_response( @@ -320,7 +362,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]]] = (), ) -> productinputs.ProductInput: r"""Call the insert product input method over HTTP. @@ -331,8 +373,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: ~.productinputs.ProductInput: @@ -341,7 +385,7 @@ def __call__( Merchant Center, in Shopping ads, or across Google surfaces. Product inputs, rules and supplemental data source data are combined to create the processed - [product][google.shopping.content.bundles.Products.Product]. + [Product][google.shopping.merchant.products.v1beta.Product]. Required product input attributes to pass data validation checks are primarily defined in the `Products @@ -349,10 +393,10 @@ def __call__( Specification `__. The following attributes are required: - [feedLabel][google.shopping.content.bundles.Products.feed_label], - [contentLanguage][google.shopping.content.bundles.Products.content_language] + [feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label], + [contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language] and - [offerId][google.shopping.content.bundles.Products.offer_id]. + [offerId][google.shopping.merchant.products.v1beta.Product.offer_id]. After inserting, updating, or deleting a product input, it may take several minutes before the processed product @@ -368,6 +412,7 @@ def __call__( http_options = ( _BaseProductInputsServiceRestTransport._BaseInsertProductInput._get_http_options() ) + request, metadata = self._interceptor.pre_insert_product_input( request, metadata ) @@ -384,6 +429,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 = 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.shopping.merchant.products_v1beta.ProductInputsServiceClient.InsertProductInput", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService", + "rpcName": "InsertProductInput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ProductInputsServiceRestTransport._InsertProductInput._get_response( @@ -407,7 +479,29 @@ def __call__( pb_resp = productinputs.ProductInput.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert_product_input(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = productinputs.ProductInput.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.shopping.merchant.products_v1beta.ProductInputsServiceClient.insert_product_input", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductInputsService", + "rpcName": "InsertProductInput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/async_client.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/async_client.py index ee17f6207ae3..4a9b4e9369fc 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/async_client.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ProductsServiceTransport from .transports.grpc_asyncio import ProductsServiceGrpcAsyncIOTransport +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 ProductsServiceAsyncClient: """Service to use Product resource. @@ -260,6 +270,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.shopping.merchant.products_v1beta.ProductsServiceAsyncClient`.", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "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.shopping.merchant.products.v1beta.ProductsService", + "credentialsType": None, + }, + ) + async def get_product( self, request: Optional[Union[products.GetProductRequest, dict]] = None, @@ -267,7 +299,7 @@ async def get_product( 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]]] = (), ) -> products.Product: r"""Retrieves the processed product from your Merchant Center account. @@ -307,7 +339,11 @@ async def sample_get_product(): method. name (:class:`str`): Required. The name of the product to retrieve. Format: - ``accounts/{account}/products/{product}`` + ``accounts/{account}/products/{product}`` where the last + section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is + "accounts/123/products/online~en~US~sku123" This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -315,13 +351,15 @@ async def sample_get_product(): 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.shopping.merchant_products_v1beta.types.Product: The processed product, built from multiple [product - inputs][[google.shopping.content.bundles.Products.ProductInput] + inputs][google.shopping.merchant.products.v1main.ProductInput] after applying rules and supplemental data sources. This processed product matches what is shown in your Merchant Center account and in Shopping ads and other @@ -392,7 +430,7 @@ async def list_products( 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.ListProductsAsyncPager: r"""Lists the processed products in your Merchant Center account. The response might contain fewer items than @@ -445,8 +483,10 @@ async def sample_list_products(): 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.shopping.merchant_products_v1beta.services.products_service.pagers.ListProductsAsyncPager: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/client.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/client.py index d89f2b0499b5..3bfbf848b272 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/client.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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.shopping.type.types import types from google.shopping.merchant_products_v1beta.services.products_service import pagers @@ -579,6 +589,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( @@ -644,6 +658,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.shopping.merchant.products_v1beta.ProductsServiceClient`.", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "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.shopping.merchant.products.v1beta.ProductsService", + "credentialsType": None, + }, + ) + def get_product( self, request: Optional[Union[products.GetProductRequest, dict]] = None, @@ -651,7 +688,7 @@ def get_product( 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]]] = (), ) -> products.Product: r"""Retrieves the processed product from your Merchant Center account. @@ -691,7 +728,11 @@ def sample_get_product(): method. name (str): Required. The name of the product to retrieve. Format: - ``accounts/{account}/products/{product}`` + ``accounts/{account}/products/{product}`` where the last + section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is + "accounts/123/products/online~en~US~sku123" This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -699,13 +740,15 @@ def sample_get_product(): 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.shopping.merchant_products_v1beta.types.Product: The processed product, built from multiple [product - inputs][[google.shopping.content.bundles.Products.ProductInput] + inputs][google.shopping.merchant.products.v1main.ProductInput] after applying rules and supplemental data sources. This processed product matches what is shown in your Merchant Center account and in Shopping ads and other @@ -773,7 +816,7 @@ def list_products( 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.ListProductsPager: r"""Lists the processed products in your Merchant Center account. The response might contain fewer items than @@ -826,8 +869,10 @@ def sample_list_products(): 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.shopping.merchant_products_v1beta.services.products_service.pagers.ListProductsPager: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/pagers.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/pagers.py index 642d245ae435..232dde288431 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/pagers.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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 = products.ListProductsRequest(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 = products.ListProductsRequest(request) diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc.py index 8cbbc07b5762..6cbbd9082df7 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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 @@ -20,12 +23,90 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.shopping.merchant_products_v1beta.types import products from .base import DEFAULT_CLIENT_INFO, ProductsServiceTransport +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.shopping.merchant.products.v1beta.ProductsService", + "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.shopping.merchant.products.v1beta.ProductsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductsServiceGrpcTransport(ProductsServiceTransport): """gRPC backend transport for ProductsService. @@ -180,7 +261,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 @@ -256,7 +342,7 @@ def get_product(self) -> Callable[[products.GetProductRequest], products.Product # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductsService/GetProduct", request_serializer=products.GetProductRequest.serialize, response_deserializer=products.Product.deserialize, @@ -289,7 +375,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductsService/ListProducts", request_serializer=products.ListProductsRequest.serialize, response_deserializer=products.ListProductsResponse.deserialize, @@ -297,7 +383,7 @@ def list_products( return self._stubs["list_products"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc_asyncio.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc_asyncio.py index e7c30db8e068..ed7f9b400c5d 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/grpc_asyncio.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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 @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.shopping.merchant_products_v1beta.types import products from .base import DEFAULT_CLIENT_INFO, ProductsServiceTransport from .grpc import ProductsServiceGrpcTransport +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.shopping.merchant.products.v1beta.ProductsService", + "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.shopping.merchant.products.v1beta.ProductsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProductsServiceGrpcAsyncIOTransport(ProductsServiceTransport): """gRPC AsyncIO backend transport for ProductsService. @@ -227,10 +309,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 @@ -266,7 +351,7 @@ def get_product( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_product" not in self._stubs: - self._stubs["get_product"] = self.grpc_channel.unary_unary( + self._stubs["get_product"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductsService/GetProduct", request_serializer=products.GetProductRequest.serialize, response_deserializer=products.Product.deserialize, @@ -301,7 +386,7 @@ def list_products( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_products" not in self._stubs: - self._stubs["list_products"] = self.grpc_channel.unary_unary( + self._stubs["list_products"] = self._logged_channel.unary_unary( "/google.shopping.merchant.products.v1beta.ProductsService/ListProducts", request_serializer=products.ListProductsRequest.serialize, response_deserializer=products.ListProductsResponse.deserialize, @@ -329,7 +414,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: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/rest.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/rest.py index 1f3b93a3bd8f..2b0e1087d62f 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/transports/rest.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/services/products_service/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 @@ -37,6 +37,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, @@ -83,8 +91,10 @@ def post_list_products(self, response): """ def pre_get_product( - self, request: products.GetProductRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[products.GetProductRequest, Sequence[Tuple[str, str]]]: + self, + request: products.GetProductRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[products.GetProductRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_product Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_get_product(self, response: products.Product) -> products.Product: return response def pre_list_products( - self, request: products.ListProductsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[products.ListProductsRequest, Sequence[Tuple[str, str]]]: + self, + request: products.ListProductsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[products.ListProductsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_products Override in a subclass to manipulate the request or metadata @@ -244,7 +256,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]]] = (), ) -> products.Product: r"""Call the get product method over HTTP. @@ -255,13 +267,15 @@ 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: ~.products.Product: The processed product, built from multiple [product - inputs][[google.shopping.content.bundles.Products.ProductInput] + inputs][google.shopping.merchant.products.v1main.ProductInput] after applying rules and supplemental data sources. This processed product matches what is shown in your Merchant Center account and in Shopping ads and other surfaces @@ -283,6 +297,7 @@ def __call__( http_options = ( _BaseProductsServiceRestTransport._BaseGetProduct._get_http_options() ) + request, metadata = self._interceptor.pre_get_product(request, metadata) transcoded_request = _BaseProductsServiceRestTransport._BaseGetProduct._get_transcoded_request( http_options, request @@ -293,6 +308,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 = 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.shopping.merchant.products_v1beta.ProductsServiceClient.GetProduct", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "rpcName": "GetProduct", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductsServiceRestTransport._GetProduct._get_response( self._host, @@ -313,7 +355,29 @@ def __call__( pb_resp = products.Product.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_product(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = products.Product.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.shopping.merchant.products_v1beta.ProductsServiceClient.get_product", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "rpcName": "GetProduct", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProducts( @@ -350,7 +414,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]]] = (), ) -> products.ListProductsResponse: r"""Call the list products method over HTTP. @@ -361,8 +425,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: ~.products.ListProductsResponse: @@ -374,6 +440,7 @@ def __call__( http_options = ( _BaseProductsServiceRestTransport._BaseListProducts._get_http_options() ) + request, metadata = self._interceptor.pre_list_products(request, metadata) transcoded_request = _BaseProductsServiceRestTransport._BaseListProducts._get_transcoded_request( http_options, request @@ -384,6 +451,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 = 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.shopping.merchant.products_v1beta.ProductsServiceClient.ListProducts", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "rpcName": "ListProducts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProductsServiceRestTransport._ListProducts._get_response( self._host, @@ -404,7 +498,29 @@ def __call__( pb_resp = products.ListProductsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_products(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = products.ListProductsResponse.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.shopping.merchant.products_v1beta.ProductsServiceClient.list_products", + extra={ + "serviceName": "google.shopping.merchant.products.v1beta.ProductsService", + "rpcName": "ListProducts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/productinputs.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/productinputs.py index 15947bd03bfb..45850fc9cc4d 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/productinputs.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/productinputs.py @@ -37,16 +37,17 @@ class ProductInput(proto.Message): the processed product that you see in Merchant Center, in Shopping ads, or across Google surfaces. Product inputs, rules and supplemental data source data are combined to create the processed - [product][google.shopping.content.bundles.Products.Product]. + [Product][google.shopping.merchant.products.v1beta.Product]. Required product input attributes to pass data validation checks are primarily defined in the `Products Data Specification `__. The following attributes are required: - [feedLabel][google.shopping.content.bundles.Products.feed_label], - [contentLanguage][google.shopping.content.bundles.Products.content_language] - and [offerId][google.shopping.content.bundles.Products.offer_id]. + [feedLabel][google.shopping.merchant.products.v1beta.Product.feed_label], + [contentLanguage][google.shopping.merchant.products.v1beta.Product.content_language] + and + [offerId][google.shopping.merchant.products.v1beta.Product.offer_id]. After inserting, updating, or deleting a product input, it may take several minutes before the processed product can be retrieved. @@ -63,6 +64,10 @@ class ProductInput(proto.Message): name (str): Identifier. The name of the product input. Format: ``"{productinput.name=accounts/{account}/productInputs/{productinput}}"`` + where the last section ``productinput`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product input name is + "accounts/123/productInputs/online~en~US~sku123". product (str): Output only. The name of the processed product. Format: ``"{product.name=accounts/{account}/products/{product}}"`` @@ -197,9 +202,12 @@ class DeleteProductInputRequest(proto.Message): Attributes: name (str): - Required. The name of the product input - resource to delete. Format: - accounts/{account}/productInputs/{product} + Required. The name of the product input resource to delete. + Format: accounts/{account}/productInputs/{product} where the + last section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is + "accounts/123/productInputs/online~en~US~sku123". data_source (str): Required. The primary or supplemental data source from which the product input should be deleted. Format: diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products.py index ba579989dfe0..1efb043b6f0d 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products.py @@ -35,9 +35,9 @@ class Product(proto.Message): r"""The processed product, built from multiple [product - inputs][[google.shopping.content.bundles.Products.ProductInput] - after applying rules and supplemental data sources. This processed - product matches what is shown in your Merchant Center account and in + inputs][google.shopping.merchant.products.v1main.ProductInput] after + applying rules and supplemental data sources. This processed product + matches what is shown in your Merchant Center account and in Shopping ads and other surfaces across Google. Each product is built from exactly one primary data source product input, and multiple supplemental data source inputs. After inserting, updating, or @@ -56,6 +56,9 @@ class Product(proto.Message): name (str): The name of the product. Format: ``"{product.name=accounts/{account}/products/{product}}"`` + where the last section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is "accounts/123/products/online~en~US~sku123". channel (google.shopping.type.types.Channel.ChannelEnum): Output only. The `channel `__ @@ -162,7 +165,10 @@ class GetProductRequest(proto.Message): Attributes: name (str): Required. The name of the product to retrieve. Format: - ``accounts/{account}/products/{product}`` + ``accounts/{account}/products/{product}`` where the last + section ``product`` consists of 4 parts: + channel~content_language~feed_label~offer_id example for + product name is "accounts/123/products/online~en~US~sku123". """ name: str = proto.Field( @@ -181,9 +187,9 @@ class ListProductsRequest(proto.Message): page_size (int): The maximum number of products to return. The service may return fewer than this value. - The maximum value is 1000; values above 1000 - will be coerced to 1000. If unspecified, the - maximum number of products will be returned. + The maximum value is 250; values above 250 will + be coerced to 250. If unspecified, the maximum + number of products will be returned. page_token (str): A page token, received from a previous ``ListProducts`` call. Provide this to retrieve the subsequent page. diff --git a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products_common.py b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products_common.py index 258eb79ef48a..1dbe69b9cddc 100644 --- a/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products_common.py +++ b/packages/google-shopping-merchant-products/google/shopping/merchant_products_v1beta/types/products_common.py @@ -176,12 +176,10 @@ class Attributes(proto.Message): auto assigned google product categories through the API. This field is a member of `oneof`_ ``_google_product_category``. - gtin (str): - Global Trade Item Number + gtin (MutableSequence[str]): + Global Trade Item Numbers (`GTIN `__) - of the item. - - This field is a member of `oneof`_ ``_gtin``. + of the item. You can provide up to 10 GTINs. item_group_id (str): Shared identifier for all variants of the same product. @@ -305,9 +303,7 @@ class Attributes(proto.Message): taxes (MutableSequence[google.shopping.merchant_products_v1beta.types.Tax]): Tax information. tax_category (str): - The tax category of the product, used to - configure detailed tax nexus in account-level - tax settings. + The tax category of the product. This field is a member of `oneof`_ ``_tax_category``. energy_efficiency_class (str): @@ -591,10 +587,9 @@ class Attributes(proto.Message): number=25, optional=True, ) - gtin: str = proto.Field( + gtin: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=26, - optional=True, ) item_group_id: str = proto.Field( proto.STRING, @@ -1236,6 +1231,22 @@ class LoyaltyProgram(proto.Message): purchase. This field is a member of `oneof`_ ``_loyalty_points``. + member_price_effective_date (google.type.interval_pb2.Interval): + A date range during which the item is + eligible for member price. If not specified, the + member price is always applicable. The date + range is represented by a pair of ISO 8601 dates + separated by a space, comma, or slash. + + This field is a member of `oneof`_ ``_member_price_effective_date``. + shipping_label (str): + The label of the shipping benefit. If the + field has value, this offer has loyalty shipping + benefit. If the field value isn't provided, the + item is not eligible for loyalty shipping for + the given loyalty tier. + + This field is a member of `oneof`_ ``_shipping_label``. """ program_label: str = proto.Field( @@ -1265,6 +1276,17 @@ class LoyaltyProgram(proto.Message): number=5, optional=True, ) + member_price_effective_date: interval_pb2.Interval = proto.Field( + proto.MESSAGE, + number=6, + optional=True, + message=interval_pb2.Interval, + ) + shipping_label: str = proto.Field( + proto.STRING, + number=7, + optional=True, + ) class Shipping(proto.Message): @@ -1305,11 +1327,11 @@ class Shipping(proto.Message): received and shipped in business days. 0 means that the order is shipped on the same day as it is received if it happens before the cut-off time. - [minHandlingTime][google.shopping.content.bundles.Products.Shipping.min_handling_time] + [minHandlingTime][google.shopping.merchant.products.v1beta.Shipping.min_handling_time] can only be present together with - [maxHandlingTime][google.shopping.content.bundles.Products.Shipping.max_handling_time]; + [maxHandlingTime][google.shopping.merchant.products.v1beta.Shipping.max_handling_time]; but it is not required if - [maxHandlingTime][google.shopping.content.bundles.Products.Shipping.max_handling_time] + [maxHandlingTime][google.shopping.merchant.products.v1beta.Shipping.max_handling_time] is present. This field is a member of `oneof`_ ``_min_handling_time``. @@ -1318,13 +1340,13 @@ class Shipping(proto.Message): received and shipped in business days. 0 means that the order is shipped on the same day as it is received if it happens before the cut-off time. Both - [maxHandlingTime][google.shopping.content.bundles.Products.Shipping.max_handling_time] + [maxHandlingTime][google.shopping.merchant.products.v1beta.Shipping.max_handling_time] and - [maxTransitTime][google.shopping.content.bundles.Products.Shipping.max_transit_time] + [maxTransitTime][google.shopping.merchant.products.v1beta.Shipping.max_transit_time] are required if providing shipping speeds. - [minHandlingTime][google.shopping.content.bundles.Products.Shipping.min_handling_time] + [minHandlingTime][google.shopping.merchant.products.v1beta.Shipping.min_handling_time] is optional if - [maxHandlingTime][google.shopping.content.bundles.Products.Shipping.max_handling_time] + [maxHandlingTime][google.shopping.merchant.products.v1beta.Shipping.max_handling_time] is present. This field is a member of `oneof`_ ``_max_handling_time``. @@ -1332,11 +1354,11 @@ class Shipping(proto.Message): Minimum transit time (inclusive) between when the order has shipped and when it is delivered in business days. 0 means that the order is delivered on the same day as it ships. - [minTransitTime][google.shopping.content.bundles.Products.Shipping.min_transit_time] + [minTransitTime][google.shopping.merchant.products.v1beta.Shipping.min_transit_time] can only be present together with - [maxTransitTime][google.shopping.content.bundles.Products.Shipping.max_transit_time]; + [maxTransitTime][google.shopping.merchant.products.v1beta.Shipping.max_transit_time]; but it is not required if - [maxTransitTime][google.shopping.content.bundles.Products.Shipping.max_transit_time] + [maxTransitTime][google.shopping.merchant.products.v1beta.Shipping.max_transit_time] is present. This field is a member of `oneof`_ ``_min_transit_time``. @@ -1345,13 +1367,13 @@ class Shipping(proto.Message): shipped and when it is delivered in business days. 0 means that the order is delivered on the same day as it ships. Both - [maxHandlingTime][google.shopping.content.bundles.Products.Shipping.max_handling_time] + [maxHandlingTime][google.shopping.merchant.products.v1beta.Shipping.max_handling_time] and - [maxTransitTime][google.shopping.content.bundles.Products.Shipping.max_transit_time] + [maxTransitTime][google.shopping.merchant.products.v1beta.Shipping.max_transit_time] are required if providing shipping speeds. - [minTransitTime][google.shopping.content.bundles.Products.Shipping.min_transit_time] + [minTransitTime][google.shopping.merchant.products.v1beta.Shipping.min_transit_time] is optional if - [maxTransitTime][google.shopping.content.bundles.Products.Shipping.max_transit_time] + [maxTransitTime][google.shopping.merchant.products.v1beta.Shipping.max_transit_time] is present. This field is a member of `oneof`_ ``_max_transit_time``. diff --git a/packages/google-shopping-merchant-products/samples/generated_samples/snippet_metadata_google.shopping.merchant.products.v1beta.json b/packages/google-shopping-merchant-products/samples/generated_samples/snippet_metadata_google.shopping.merchant.products.v1beta.json index 249e890dbab1..c50174f47a66 100644 --- a/packages/google-shopping-merchant-products/samples/generated_samples/snippet_metadata_google.shopping.merchant.products.v1beta.json +++ b/packages/google-shopping-merchant-products/samples/generated_samples/snippet_metadata_google.shopping.merchant.products.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-shopping-merchant-products", - "version": "0.1.4" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_input" @@ -124,7 +124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_product_input" @@ -198,7 +198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.types.ProductInput", @@ -274,7 +274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.types.ProductInput", @@ -355,7 +355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.types.Product", @@ -435,7 +435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.types.Product", @@ -516,7 +516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.services.products_service.pagers.ListProductsAsyncPager", @@ -596,7 +596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.shopping.merchant_products_v1beta.services.products_service.pagers.ListProductsPager", diff --git a/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_product_inputs_service.py b/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_product_inputs_service.py index b716981424d6..5db6b4a1099f 100644 --- a/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_product_inputs_service.py +++ b/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_product_inputs_service.py @@ -1855,6 +1855,7 @@ def test_insert_product_input_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.insert_product_input(request) @@ -1999,6 +2000,7 @@ def test_delete_product_input_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.delete_product_input(request) @@ -2056,6 +2058,7 @@ def test_delete_product_input_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_product_input(**mock_args) @@ -2339,6 +2342,7 @@ def test_insert_product_input_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.insert_product_input(request) @@ -2388,7 +2392,7 @@ def test_insert_product_input_rest_call_success(request_type): "condition": "condition_value", "gender": "gender_value", "google_product_category": "google_product_category_value", - "gtin": "gtin_value", + "gtin": ["gtin_value1", "gtin_value2"], "item_group_id": "item_group_id_value", "material": "material_value", "mpn": "mpn_value", @@ -2413,11 +2417,13 @@ def test_insert_product_input_rest_call_success(request_type): "price": {}, "cashback_for_future_use": {}, "loyalty_points": 1546, + "member_price_effective_date": {"start_time": {}, "end_time": {}}, + "shipping_label": "shipping_label_value", } ], "product_types": ["product_types_value1", "product_types_value2"], "sale_price": {}, - "sale_price_effective_date": {"start_time": {}, "end_time": {}}, + "sale_price_effective_date": {}, "sell_on_google_quantity": 2470, "product_height": {"value": 0.541, "unit": "unit_value"}, "product_length": {}, @@ -2646,6 +2652,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.insert_product_input(request) # Establish that the response is the type that we expect. @@ -2692,6 +2699,7 @@ def test_insert_product_input_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 = productinputs.ProductInput.to_json(productinputs.ProductInput()) req.return_value.content = return_value @@ -2736,6 +2744,7 @@ def test_delete_product_input_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.delete_product_input(request) @@ -2766,6 +2775,7 @@ def test_delete_product_input_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_product_input(request) # Establish that the response is the type that we expect. @@ -2802,6 +2812,7 @@ def test_delete_product_input_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 = productinputs.DeleteProductInputRequest() metadata = [ diff --git a/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_products_service.py b/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_products_service.py index e5fc50cdba72..42d2656ad559 100644 --- a/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_products_service.py +++ b/packages/google-shopping-merchant-products/tests/unit/gapic/merchant_products_v1beta/test_products_service.py @@ -2047,6 +2047,7 @@ def test_get_product_rest_required_fields(request_type=products.GetProductReques 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_product(request) @@ -2092,6 +2093,7 @@ def test_get_product_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_product(**mock_args) @@ -2227,6 +2229,7 @@ def test_list_products_rest_required_fields(request_type=products.ListProductsRe 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_products(request) @@ -2280,6 +2283,7 @@ def test_list_products_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_products(**mock_args) @@ -2617,6 +2621,7 @@ def test_get_product_rest_bad_request(request_type=products.GetProductRequest): 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_product(request) @@ -2658,6 +2663,7 @@ def test_get_product_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_product(request) # Establish that the response is the type that we expect. @@ -2702,6 +2708,7 @@ def test_get_product_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 = products.Product.to_json(products.Product()) req.return_value.content = return_value @@ -2744,6 +2751,7 @@ def test_list_products_rest_bad_request(request_type=products.ListProductsReques 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_products(request) @@ -2779,6 +2787,7 @@ def test_list_products_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_products(request) # Establish that the response is the type that we expect. @@ -2817,6 +2826,7 @@ def test_list_products_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 = products.ListProductsResponse.to_json( products.ListProductsResponse() ) From 4fe968a7e807633afb274cca5a196494b7a85aa2 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 18:24:17 +0500 Subject: [PATCH 10/16] feat: [google-cloud-oracledatabase] Add support for opt-in debug logging (#13337) 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 docs: A comment for field `cpu_count` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed docs: A comment for field `memory_size_gb` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed docs: A comment for field `db_node_storage_size_gb` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yYWNsZWRhdGFiYXNlLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= BEGIN_NESTED_COMMIT docs: [google-cloud-oracledatabase] A comment for field `cpu_count` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed docs: A comment for field `memory_size_gb` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed docs: A comment for field `db_node_storage_size_gb` in message `.google.cloud.oracledatabase.v1.CloudExadataInfrastructureProperties` is changed PiperOrigin-RevId: 704818011 Source-Link: https://github.com/googleapis/googleapis/commit/bd2042802bd4bb77f57eb31cec90d4d30a96ec20 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ad156292b585635af329f3e6f6ba2e6444a71da Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yYWNsZWRhdGFiYXNlLy5Pd2xCb3QueWFtbCIsImgiOiIyYWQxNTYyOTJiNTg1NjM1YWYzMjlmM2U2ZjZiYTJlNjQ0NGE3MWRhIn0= END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../cloud/oracledatabase/gapic_version.py | 2 +- .../cloud/oracledatabase_v1/gapic_version.py | 2 +- .../services/oracle_database/client.py | 261 ++- .../services/oracle_database/pagers.py | 88 +- .../oracle_database/transports/rest.py | 1779 +++++++++++++++-- .../oracledatabase_v1/types/exadata_infra.py | 8 +- ...tadata_google.cloud.oracledatabase.v1.json | 46 +- .../oracledatabase_v1/test_oracle_database.py | 122 ++ 8 files changed, 2021 insertions(+), 287 deletions(-) diff --git a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase/gapic_version.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase/gapic_version.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/gapic_version.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/gapic_version.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/client.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/client.py index 04b74d50ec07..7a40af2a57fa 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/client.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -842,6 +852,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( @@ -907,6 +921,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.oracledatabase_v1.OracleDatabaseClient`.", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "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.oracledatabase.v1.OracleDatabase", + "credentialsType": None, + }, + ) + def list_cloud_exadata_infrastructures( self, request: Optional[ @@ -916,7 +953,7 @@ def list_cloud_exadata_infrastructures( 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.ListCloudExadataInfrastructuresPager: r"""Lists Exadata Infrastructures in a given project and location. @@ -963,8 +1000,10 @@ def sample_list_cloud_exadata_infrastructures(): 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.oracledatabase_v1.services.oracle_database.pagers.ListCloudExadataInfrastructuresPager: @@ -1041,7 +1080,7 @@ def get_cloud_exadata_infrastructure( 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]]] = (), ) -> exadata_infra.CloudExadataInfrastructure: r"""Gets details of a single Exadata Infrastructure. @@ -1085,8 +1124,10 @@ def sample_get_cloud_exadata_infrastructure(): 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.oracledatabase_v1.types.CloudExadataInfrastructure: @@ -1153,7 +1194,7 @@ def create_cloud_exadata_infrastructure( cloud_exadata_infrastructure_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new Exadata Infrastructure in a given project and location. @@ -1221,8 +1262,10 @@ def sample_create_cloud_exadata_infrastructure(): 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.api_core.operation.Operation: @@ -1304,7 +1347,7 @@ def delete_cloud_exadata_infrastructure( 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]]] = (), ) -> operation.Operation: r"""Deletes a single Exadata Infrastructure. @@ -1352,8 +1395,10 @@ def sample_delete_cloud_exadata_infrastructure(): 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.api_core.operation.Operation: @@ -1435,7 +1480,7 @@ def list_cloud_vm_clusters( 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.ListCloudVmClustersPager: r"""Lists the VM Clusters in a given project and location. @@ -1481,8 +1526,10 @@ def sample_list_cloud_vm_clusters(): 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.oracledatabase_v1.services.oracle_database.pagers.ListCloudVmClustersPager: @@ -1553,7 +1600,7 @@ def get_cloud_vm_cluster( 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]]] = (), ) -> vm_cluster.CloudVmCluster: r"""Gets details of a single VM Cluster. @@ -1597,8 +1644,10 @@ def sample_get_cloud_vm_cluster(): 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.oracledatabase_v1.types.CloudVmCluster: @@ -1661,7 +1710,7 @@ def create_cloud_vm_cluster( cloud_vm_cluster_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new VM Cluster in a given project and location. @@ -1733,8 +1782,10 @@ def sample_create_cloud_vm_cluster(): 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.api_core.operation.Operation: @@ -1808,7 +1859,7 @@ def delete_cloud_vm_cluster( 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]]] = (), ) -> operation.Operation: r"""Deletes a single VM Cluster. @@ -1856,8 +1907,10 @@ def sample_delete_cloud_vm_cluster(): 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.api_core.operation.Operation: @@ -1933,7 +1986,7 @@ def list_entitlements( 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.ListEntitlementsPager: r"""Lists the entitlements in a given project. @@ -1978,8 +2031,10 @@ def sample_list_entitlements(): 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.oracledatabase_v1.services.oracle_database.pagers.ListEntitlementsPager: @@ -2050,7 +2105,7 @@ def list_db_servers( 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.ListDbServersPager: r"""Lists the database servers of an Exadata Infrastructure instance. @@ -2096,8 +2151,10 @@ def sample_list_db_servers(): 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.oracledatabase_v1.services.oracle_database.pagers.ListDbServersPager: @@ -2168,7 +2225,7 @@ def list_db_nodes( 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.ListDbNodesPager: r"""Lists the database nodes of a VM Cluster. @@ -2213,8 +2270,10 @@ def sample_list_db_nodes(): 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.oracledatabase_v1.services.oracle_database.pagers.ListDbNodesPager: @@ -2285,7 +2344,7 @@ def list_gi_versions( 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.ListGiVersionsPager: r"""Lists all the valid Oracle Grid Infrastructure (GI) versions for the given project and location. @@ -2332,8 +2391,10 @@ def sample_list_gi_versions(): 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.oracledatabase_v1.services.oracle_database.pagers.ListGiVersionsPager: @@ -2404,7 +2465,7 @@ def list_db_system_shapes( 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.ListDbSystemShapesPager: r"""Lists the database system shapes available for the project and location. @@ -2451,8 +2512,10 @@ def sample_list_db_system_shapes(): 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.oracledatabase_v1.services.oracle_database.pagers.ListDbSystemShapesPager: @@ -2525,7 +2588,7 @@ def list_autonomous_databases( 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.ListAutonomousDatabasesPager: r"""Lists the Autonomous Databases in a given project and location. @@ -2572,8 +2635,10 @@ def sample_list_autonomous_databases(): 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.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabasesPager: @@ -2648,7 +2713,7 @@ def get_autonomous_database( 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]]] = (), ) -> autonomous_database.AutonomousDatabase: r"""Gets the details of a single Autonomous Database. @@ -2692,8 +2757,10 @@ def sample_get_autonomous_database(): 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.oracledatabase_v1.types.AutonomousDatabase: @@ -2758,7 +2825,7 @@ def create_autonomous_database( autonomous_database_id: 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]]] = (), ) -> operation.Operation: r"""Creates a new Autonomous Database in a given project and location. @@ -2830,8 +2897,10 @@ def sample_create_autonomous_database(): 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.api_core.operation.Operation: @@ -2909,7 +2978,7 @@ def delete_autonomous_database( 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]]] = (), ) -> operation.Operation: r"""Deletes a single Autonomous Database. @@ -2957,8 +3026,10 @@ def sample_delete_autonomous_database(): 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.api_core.operation.Operation: @@ -3039,7 +3110,7 @@ def restore_autonomous_database( restore_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]]] = (), ) -> operation.Operation: r"""Restores a single Autonomous Database. @@ -3094,8 +3165,10 @@ def sample_restore_autonomous_database(): 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.api_core.operation.Operation: @@ -3172,7 +3245,7 @@ def generate_autonomous_database_wallet( password: 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]]] = (), ) -> oracledatabase.GenerateAutonomousDatabaseWalletResponse: r"""Generates a wallet for an Autonomous Database. @@ -3243,8 +3316,10 @@ def sample_generate_autonomous_database_wallet(): 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.oracledatabase_v1.types.GenerateAutonomousDatabaseWalletResponse: @@ -3312,7 +3387,7 @@ def list_autonomous_db_versions( 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.ListAutonomousDbVersionsPager: r"""Lists all the available Autonomous Database versions for a project and location. @@ -3359,8 +3434,10 @@ def sample_list_autonomous_db_versions(): 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.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDbVersionsPager: @@ -3435,7 +3512,7 @@ def list_autonomous_database_character_sets( 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.ListAutonomousDatabaseCharacterSetsPager: r"""Lists Autonomous Database Character Sets in a given project and location. @@ -3482,8 +3559,10 @@ def sample_list_autonomous_database_character_sets(): 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.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabaseCharacterSetsPager: @@ -3560,7 +3639,7 @@ def list_autonomous_database_backups( 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.ListAutonomousDatabaseBackupsPager: r"""Lists the long-term and automatic backups of an Autonomous Database. @@ -3607,8 +3686,10 @@ def sample_list_autonomous_database_backups(): 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.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabaseBackupsPager: @@ -3693,7 +3774,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3704,8 +3785,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3746,7 +3829,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3757,8 +3840,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3799,7 +3884,7 @@ def delete_operation( *, 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 long-running operation. @@ -3815,8 +3900,10 @@ def delete_operation( 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: None """ @@ -3853,7 +3940,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -3868,8 +3955,10 @@ def cancel_operation( 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: None """ @@ -3906,7 +3995,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. @@ -3917,8 +4006,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. @@ -3959,7 +4050,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. @@ -3970,8 +4061,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-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/pagers.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/pagers.py index 111ec9a9d392..a498619ed04b 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/pagers.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/pagers.py @@ -80,7 +80,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. @@ -94,8 +94,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 = oracledatabase.ListCloudExadataInfrastructuresRequest(request) @@ -154,7 +156,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. @@ -168,8 +170,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 = oracledatabase.ListCloudVmClustersRequest(request) @@ -228,7 +232,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. @@ -242,8 +246,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 = oracledatabase.ListEntitlementsRequest(request) @@ -302,7 +308,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. @@ -316,8 +322,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 = oracledatabase.ListDbServersRequest(request) @@ -376,7 +384,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. @@ -390,8 +398,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 = oracledatabase.ListDbNodesRequest(request) @@ -450,7 +460,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. @@ -464,8 +474,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 = oracledatabase.ListGiVersionsRequest(request) @@ -524,7 +536,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. @@ -538,8 +550,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 = oracledatabase.ListDbSystemShapesRequest(request) @@ -598,7 +612,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. @@ -612,8 +626,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 = oracledatabase.ListAutonomousDatabasesRequest(request) @@ -672,7 +688,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. @@ -686,8 +702,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 = oracledatabase.ListAutonomousDbVersionsRequest(request) @@ -748,7 +766,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. @@ -762,8 +780,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 = oracledatabase.ListAutonomousDatabaseCharacterSetsRequest( @@ -828,7 +848,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. @@ -842,8 +862,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 = oracledatabase.ListAutonomousDatabaseBackupsRequest(request) diff --git a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/transports/rest.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/transports/rest.py index ceb3f4537d42..b831203b177b 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/transports/rest.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/services/oracle_database/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 @@ -44,6 +44,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, @@ -252,9 +260,10 @@ def post_restore_autonomous_database(self, response): def pre_create_autonomous_database( self, request: oracledatabase.CreateAutonomousDatabaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.CreateAutonomousDatabaseRequest, Sequence[Tuple[str, str]] + oracledatabase.CreateAutonomousDatabaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_autonomous_database @@ -277,10 +286,10 @@ def post_create_autonomous_database( def pre_create_cloud_exadata_infrastructure( self, request: oracledatabase.CreateCloudExadataInfrastructureRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ oracledatabase.CreateCloudExadataInfrastructureRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_cloud_exadata_infrastructure @@ -303,8 +312,11 @@ def post_create_cloud_exadata_infrastructure( def pre_create_cloud_vm_cluster( self, request: oracledatabase.CreateCloudVmClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.CreateCloudVmClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.CreateCloudVmClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_cloud_vm_cluster Override in a subclass to manipulate the request or metadata @@ -326,9 +338,10 @@ def post_create_cloud_vm_cluster( def pre_delete_autonomous_database( self, request: oracledatabase.DeleteAutonomousDatabaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.DeleteAutonomousDatabaseRequest, Sequence[Tuple[str, str]] + oracledatabase.DeleteAutonomousDatabaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_autonomous_database @@ -351,10 +364,10 @@ def post_delete_autonomous_database( def pre_delete_cloud_exadata_infrastructure( self, request: oracledatabase.DeleteCloudExadataInfrastructureRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ oracledatabase.DeleteCloudExadataInfrastructureRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_cloud_exadata_infrastructure @@ -377,8 +390,11 @@ def post_delete_cloud_exadata_infrastructure( def pre_delete_cloud_vm_cluster( self, request: oracledatabase.DeleteCloudVmClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.DeleteCloudVmClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.DeleteCloudVmClusterRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_cloud_vm_cluster Override in a subclass to manipulate the request or metadata @@ -400,10 +416,10 @@ def post_delete_cloud_vm_cluster( def pre_generate_autonomous_database_wallet( self, request: oracledatabase.GenerateAutonomousDatabaseWalletRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ oracledatabase.GenerateAutonomousDatabaseWalletRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_autonomous_database_wallet @@ -426,8 +442,11 @@ def post_generate_autonomous_database_wallet( def pre_get_autonomous_database( self, request: oracledatabase.GetAutonomousDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.GetAutonomousDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.GetAutonomousDatabaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_autonomous_database Override in a subclass to manipulate the request or metadata @@ -449,9 +468,10 @@ def post_get_autonomous_database( def pre_get_cloud_exadata_infrastructure( self, request: oracledatabase.GetCloudExadataInfrastructureRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.GetCloudExadataInfrastructureRequest, Sequence[Tuple[str, str]] + oracledatabase.GetCloudExadataInfrastructureRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_cloud_exadata_infrastructure @@ -474,8 +494,10 @@ def post_get_cloud_exadata_infrastructure( def pre_get_cloud_vm_cluster( self, request: oracledatabase.GetCloudVmClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.GetCloudVmClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.GetCloudVmClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cloud_vm_cluster Override in a subclass to manipulate the request or metadata @@ -497,9 +519,10 @@ def post_get_cloud_vm_cluster( def pre_list_autonomous_database_backups( self, request: oracledatabase.ListAutonomousDatabaseBackupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.ListAutonomousDatabaseBackupsRequest, Sequence[Tuple[str, str]] + oracledatabase.ListAutonomousDatabaseBackupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_autonomous_database_backups @@ -522,10 +545,10 @@ def post_list_autonomous_database_backups( def pre_list_autonomous_database_character_sets( self, request: oracledatabase.ListAutonomousDatabaseCharacterSetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ oracledatabase.ListAutonomousDatabaseCharacterSetsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_autonomous_database_character_sets @@ -548,9 +571,10 @@ def post_list_autonomous_database_character_sets( def pre_list_autonomous_databases( self, request: oracledatabase.ListAutonomousDatabasesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.ListAutonomousDatabasesRequest, Sequence[Tuple[str, str]] + oracledatabase.ListAutonomousDatabasesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_autonomous_databases @@ -573,9 +597,10 @@ def post_list_autonomous_databases( def pre_list_autonomous_db_versions( self, request: oracledatabase.ListAutonomousDbVersionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.ListAutonomousDbVersionsRequest, Sequence[Tuple[str, str]] + oracledatabase.ListAutonomousDbVersionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_autonomous_db_versions @@ -598,9 +623,10 @@ def post_list_autonomous_db_versions( def pre_list_cloud_exadata_infrastructures( self, request: oracledatabase.ListCloudExadataInfrastructuresRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.ListCloudExadataInfrastructuresRequest, Sequence[Tuple[str, str]] + oracledatabase.ListCloudExadataInfrastructuresRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_cloud_exadata_infrastructures @@ -623,8 +649,11 @@ def post_list_cloud_exadata_infrastructures( def pre_list_cloud_vm_clusters( self, request: oracledatabase.ListCloudVmClustersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListCloudVmClustersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListCloudVmClustersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_cloud_vm_clusters Override in a subclass to manipulate the request or metadata @@ -646,8 +675,10 @@ def post_list_cloud_vm_clusters( def pre_list_db_nodes( self, request: oracledatabase.ListDbNodesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListDbNodesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListDbNodesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_db_nodes Override in a subclass to manipulate the request or metadata @@ -669,8 +700,10 @@ def post_list_db_nodes( def pre_list_db_servers( self, request: oracledatabase.ListDbServersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListDbServersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListDbServersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_db_servers Override in a subclass to manipulate the request or metadata @@ -692,8 +725,11 @@ def post_list_db_servers( def pre_list_db_system_shapes( self, request: oracledatabase.ListDbSystemShapesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListDbSystemShapesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListDbSystemShapesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_db_system_shapes Override in a subclass to manipulate the request or metadata @@ -715,8 +751,10 @@ def post_list_db_system_shapes( def pre_list_entitlements( self, request: oracledatabase.ListEntitlementsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListEntitlementsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListEntitlementsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_entitlements Override in a subclass to manipulate the request or metadata @@ -738,8 +776,10 @@ def post_list_entitlements( def pre_list_gi_versions( self, request: oracledatabase.ListGiVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[oracledatabase.ListGiVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + oracledatabase.ListGiVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_gi_versions Override in a subclass to manipulate the request or metadata @@ -761,9 +801,10 @@ def post_list_gi_versions( def pre_restore_autonomous_database( self, request: oracledatabase.RestoreAutonomousDatabaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - oracledatabase.RestoreAutonomousDatabaseRequest, Sequence[Tuple[str, str]] + oracledatabase.RestoreAutonomousDatabaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for restore_autonomous_database @@ -786,8 +827,10 @@ def post_restore_autonomous_database( 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 @@ -809,8 +852,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 @@ -832,8 +877,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -853,8 +900,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -874,8 +923,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -897,8 +948,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -1094,7 +1147,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create autonomous database method over HTTP. @@ -1105,8 +1158,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: ~.operations_pb2.Operation: @@ -1119,6 +1174,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseCreateAutonomousDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_create_autonomous_database( request, metadata ) @@ -1135,6 +1191,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.oracledatabase_v1.OracleDatabaseClient.CreateAutonomousDatabase", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateAutonomousDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OracleDatabaseRestTransport._CreateAutonomousDatabase._get_response( @@ -1156,7 +1239,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_autonomous_database(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.oracledatabase_v1.OracleDatabaseClient.create_autonomous_database", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateAutonomousDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCloudExadataInfrastructure( @@ -1195,7 +1300,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cloud exadata infrastructure method over HTTP. @@ -1206,8 +1311,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: ~.operations_pb2.Operation: @@ -1220,6 +1327,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseCreateCloudExadataInfrastructure._get_http_options() ) + ( request, metadata, @@ -1239,6 +1347,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.oracledatabase_v1.OracleDatabaseClient.CreateCloudExadataInfrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateCloudExadataInfrastructure", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._CreateCloudExadataInfrastructure._get_response( self._host, @@ -1258,7 +1393,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cloud_exadata_infrastructure(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.oracledatabase_v1.OracleDatabaseClient.create_cloud_exadata_infrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateCloudExadataInfrastructure", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCloudVmCluster( @@ -1297,7 +1454,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cloud vm cluster method over HTTP. @@ -1307,8 +1464,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: ~.operations_pb2.Operation: @@ -1321,6 +1480,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseCreateCloudVmCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cloud_vm_cluster( request, metadata ) @@ -1337,6 +1497,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.oracledatabase_v1.OracleDatabaseClient.CreateCloudVmCluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateCloudVmCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._CreateCloudVmCluster._get_response( self._host, @@ -1356,7 +1543,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cloud_vm_cluster(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.oracledatabase_v1.OracleDatabaseClient.create_cloud_vm_cluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CreateCloudVmCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAutonomousDatabase( @@ -1394,7 +1603,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete autonomous database method over HTTP. @@ -1405,8 +1614,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: ~.operations_pb2.Operation: @@ -1419,6 +1630,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseDeleteAutonomousDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_delete_autonomous_database( request, metadata ) @@ -1431,6 +1643,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.oracledatabase_v1.OracleDatabaseClient.DeleteAutonomousDatabase", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteAutonomousDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OracleDatabaseRestTransport._DeleteAutonomousDatabase._get_response( @@ -1451,7 +1690,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_autonomous_database(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.oracledatabase_v1.OracleDatabaseClient.delete_autonomous_database", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteAutonomousDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCloudExadataInfrastructure( @@ -1489,7 +1750,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cloud exadata infrastructure method over HTTP. @@ -1500,8 +1761,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: ~.operations_pb2.Operation: @@ -1514,6 +1777,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseDeleteCloudExadataInfrastructure._get_http_options() ) + ( request, metadata, @@ -1529,6 +1793,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.oracledatabase_v1.OracleDatabaseClient.DeleteCloudExadataInfrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteCloudExadataInfrastructure", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._DeleteCloudExadataInfrastructure._get_response( self._host, @@ -1547,7 +1838,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cloud_exadata_infrastructure(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.oracledatabase_v1.OracleDatabaseClient.delete_cloud_exadata_infrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteCloudExadataInfrastructure", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCloudVmCluster( @@ -1585,7 +1898,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cloud vm cluster method over HTTP. @@ -1595,8 +1908,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: ~.operations_pb2.Operation: @@ -1609,6 +1924,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseDeleteCloudVmCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cloud_vm_cluster( request, metadata ) @@ -1621,6 +1937,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.oracledatabase_v1.OracleDatabaseClient.DeleteCloudVmCluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteCloudVmCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._DeleteCloudVmCluster._get_response( self._host, @@ -1639,7 +1982,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_cloud_vm_cluster(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.oracledatabase_v1.OracleDatabaseClient.delete_cloud_vm_cluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteCloudVmCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAutonomousDatabaseWallet( @@ -1678,7 +2043,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]]] = (), ) -> oracledatabase.GenerateAutonomousDatabaseWalletResponse: r"""Call the generate autonomous database wallet method over HTTP. @@ -1689,8 +2054,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: ~.oracledatabase.GenerateAutonomousDatabaseWalletResponse: @@ -1700,6 +2067,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGenerateAutonomousDatabaseWallet._get_http_options() ) + ( request, metadata, @@ -1719,6 +2087,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 = 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.oracledatabase_v1.OracleDatabaseClient.GenerateAutonomousDatabaseWallet", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GenerateAutonomousDatabaseWallet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GenerateAutonomousDatabaseWallet._get_response( self._host, @@ -1740,7 +2135,33 @@ def __call__( pb_resp = oracledatabase.GenerateAutonomousDatabaseWalletResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_autonomous_database_wallet(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.GenerateAutonomousDatabaseWalletResponse.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.oracledatabase_v1.OracleDatabaseClient.generate_autonomous_database_wallet", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GenerateAutonomousDatabaseWallet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAutonomousDatabase( @@ -1778,7 +2199,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]]] = (), ) -> autonomous_database.AutonomousDatabase: r"""Call the get autonomous database method over HTTP. @@ -1788,8 +2209,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: ~.autonomous_database.AutonomousDatabase: @@ -1802,6 +2225,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGetAutonomousDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_get_autonomous_database( request, metadata ) @@ -1814,6 +2238,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 = 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.oracledatabase_v1.OracleDatabaseClient.GetAutonomousDatabase", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetAutonomousDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GetAutonomousDatabase._get_response( self._host, @@ -1834,7 +2285,31 @@ def __call__( pb_resp = autonomous_database.AutonomousDatabase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_autonomous_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = autonomous_database.AutonomousDatabase.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.oracledatabase_v1.OracleDatabaseClient.get_autonomous_database", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetAutonomousDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCloudExadataInfrastructure( @@ -1872,7 +2347,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]]] = (), ) -> exadata_infra.CloudExadataInfrastructure: r"""Call the get cloud exadata infrastructure method over HTTP. @@ -1883,8 +2358,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: ~.exadata_infra.CloudExadataInfrastructure: @@ -1897,6 +2374,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGetCloudExadataInfrastructure._get_http_options() ) + request, metadata = self._interceptor.pre_get_cloud_exadata_infrastructure( request, metadata ) @@ -1909,6 +2387,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 = 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.oracledatabase_v1.OracleDatabaseClient.GetCloudExadataInfrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetCloudExadataInfrastructure", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GetCloudExadataInfrastructure._get_response( self._host, @@ -1929,7 +2434,31 @@ def __call__( pb_resp = exadata_infra.CloudExadataInfrastructure.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cloud_exadata_infrastructure(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = exadata_infra.CloudExadataInfrastructure.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.oracledatabase_v1.OracleDatabaseClient.get_cloud_exadata_infrastructure", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetCloudExadataInfrastructure", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCloudVmCluster( @@ -1966,7 +2495,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]]] = (), ) -> vm_cluster.CloudVmCluster: r"""Call the get cloud vm cluster method over HTTP. @@ -1976,8 +2505,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: ~.vm_cluster.CloudVmCluster: @@ -1990,6 +2521,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGetCloudVmCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cloud_vm_cluster( request, metadata ) @@ -2002,6 +2534,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 = 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.oracledatabase_v1.OracleDatabaseClient.GetCloudVmCluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetCloudVmCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GetCloudVmCluster._get_response( self._host, @@ -2022,7 +2581,29 @@ def __call__( pb_resp = vm_cluster.CloudVmCluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cloud_vm_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vm_cluster.CloudVmCluster.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.oracledatabase_v1.OracleDatabaseClient.get_cloud_vm_cluster", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetCloudVmCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAutonomousDatabaseBackups( @@ -2060,7 +2641,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]]] = (), ) -> oracledatabase.ListAutonomousDatabaseBackupsResponse: r"""Call the list autonomous database backups method over HTTP. @@ -2071,8 +2652,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: ~.oracledatabase.ListAutonomousDatabaseBackupsResponse: @@ -2082,6 +2665,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListAutonomousDatabaseBackups._get_http_options() ) + request, metadata = self._interceptor.pre_list_autonomous_database_backups( request, metadata ) @@ -2094,6 +2678,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListAutonomousDatabaseBackups", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabaseBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListAutonomousDatabaseBackups._get_response( self._host, @@ -2114,7 +2725,33 @@ def __call__( pb_resp = oracledatabase.ListAutonomousDatabaseBackupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_autonomous_database_backups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListAutonomousDatabaseBackupsResponse.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.oracledatabase_v1.OracleDatabaseClient.list_autonomous_database_backups", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabaseBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAutonomousDatabaseCharacterSets( @@ -2154,7 +2791,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]]] = (), ) -> oracledatabase.ListAutonomousDatabaseCharacterSetsResponse: r"""Call the list autonomous database character sets method over HTTP. @@ -2165,8 +2802,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: ~.oracledatabase.ListAutonomousDatabaseCharacterSetsResponse: @@ -2178,6 +2817,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListAutonomousDatabaseCharacterSets._get_http_options() ) + ( request, metadata, @@ -2193,6 +2833,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListAutonomousDatabaseCharacterSets", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabaseCharacterSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListAutonomousDatabaseCharacterSets._get_response( self._host, @@ -2215,7 +2882,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_autonomous_database_character_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oracledatabase.ListAutonomousDatabaseCharacterSetsResponse.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.oracledatabase_v1.OracleDatabaseClient.list_autonomous_database_character_sets", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabaseCharacterSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAutonomousDatabases( @@ -2253,7 +2944,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]]] = (), ) -> oracledatabase.ListAutonomousDatabasesResponse: r"""Call the list autonomous databases method over HTTP. @@ -2263,8 +2954,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: ~.oracledatabase.ListAutonomousDatabasesResponse: @@ -2274,6 +2967,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListAutonomousDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_autonomous_databases( request, metadata ) @@ -2286,6 +2980,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListAutonomousDatabases", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OracleDatabaseRestTransport._ListAutonomousDatabases._get_response( @@ -2308,7 +3029,31 @@ def __call__( pb_resp = oracledatabase.ListAutonomousDatabasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_autonomous_databases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListAutonomousDatabasesResponse.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.oracledatabase_v1.OracleDatabaseClient.list_autonomous_databases", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAutonomousDbVersions( @@ -2346,7 +3091,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]]] = (), ) -> oracledatabase.ListAutonomousDbVersionsResponse: r"""Call the list autonomous db versions method over HTTP. @@ -2357,8 +3102,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: ~.oracledatabase.ListAutonomousDbVersionsResponse: @@ -2368,6 +3115,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListAutonomousDbVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_autonomous_db_versions( request, metadata ) @@ -2380,6 +3128,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListAutonomousDbVersions", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDbVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OracleDatabaseRestTransport._ListAutonomousDbVersions._get_response( @@ -2402,7 +3177,33 @@ def __call__( pb_resp = oracledatabase.ListAutonomousDbVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_autonomous_db_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListAutonomousDbVersionsResponse.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.oracledatabase_v1.OracleDatabaseClient.list_autonomous_db_versions", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListAutonomousDbVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCloudExadataInfrastructures( @@ -2440,7 +3241,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]]] = (), ) -> oracledatabase.ListCloudExadataInfrastructuresResponse: r"""Call the list cloud exadata infrastructures method over HTTP. @@ -2451,8 +3252,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: ~.oracledatabase.ListCloudExadataInfrastructuresResponse: @@ -2462,6 +3265,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListCloudExadataInfrastructures._get_http_options() ) + ( request, metadata, @@ -2477,6 +3281,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListCloudExadataInfrastructures", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListCloudExadataInfrastructures", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListCloudExadataInfrastructures._get_response( self._host, @@ -2497,7 +3328,33 @@ def __call__( pb_resp = oracledatabase.ListCloudExadataInfrastructuresResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cloud_exadata_infrastructures(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListCloudExadataInfrastructuresResponse.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.oracledatabase_v1.OracleDatabaseClient.list_cloud_exadata_infrastructures", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListCloudExadataInfrastructures", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCloudVmClusters( @@ -2535,7 +3392,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]]] = (), ) -> oracledatabase.ListCloudVmClustersResponse: r"""Call the list cloud vm clusters method over HTTP. @@ -2545,8 +3402,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: ~.oracledatabase.ListCloudVmClustersResponse: @@ -2556,6 +3415,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListCloudVmClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_cloud_vm_clusters( request, metadata ) @@ -2568,6 +3428,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListCloudVmClusters", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListCloudVmClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListCloudVmClusters._get_response( self._host, @@ -2588,7 +3475,31 @@ def __call__( pb_resp = oracledatabase.ListCloudVmClustersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cloud_vm_clusters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListCloudVmClustersResponse.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.oracledatabase_v1.OracleDatabaseClient.list_cloud_vm_clusters", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListCloudVmClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDbNodes( @@ -2625,7 +3536,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]]] = (), ) -> oracledatabase.ListDbNodesResponse: r"""Call the list db nodes method over HTTP. @@ -2635,8 +3546,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: ~.oracledatabase.ListDbNodesResponse: @@ -2646,6 +3559,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListDbNodes._get_http_options() ) + request, metadata = self._interceptor.pre_list_db_nodes(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseListDbNodes._get_transcoded_request( http_options, request @@ -2656,6 +3570,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListDbNodes", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListDbNodes._get_response( self._host, @@ -2676,7 +3617,31 @@ def __call__( pb_resp = oracledatabase.ListDbNodesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_db_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oracledatabase.ListDbNodesResponse.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.oracledatabase_v1.OracleDatabaseClient.list_db_nodes", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDbServers( @@ -2713,7 +3678,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]]] = (), ) -> oracledatabase.ListDbServersResponse: r"""Call the list db servers method over HTTP. @@ -2723,8 +3688,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: ~.oracledatabase.ListDbServersResponse: @@ -2734,6 +3701,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListDbServers._get_http_options() ) + request, metadata = self._interceptor.pre_list_db_servers(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseListDbServers._get_transcoded_request( http_options, request @@ -2744,6 +3712,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListDbServers", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbServers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListDbServers._get_response( self._host, @@ -2764,7 +3759,31 @@ def __call__( pb_resp = oracledatabase.ListDbServersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_db_servers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oracledatabase.ListDbServersResponse.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.oracledatabase_v1.OracleDatabaseClient.list_db_servers", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbServers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDbSystemShapes( @@ -2801,7 +3820,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]]] = (), ) -> oracledatabase.ListDbSystemShapesResponse: r"""Call the list db system shapes method over HTTP. @@ -2811,8 +3830,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: ~.oracledatabase.ListDbSystemShapesResponse: @@ -2822,6 +3843,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListDbSystemShapes._get_http_options() ) + request, metadata = self._interceptor.pre_list_db_system_shapes( request, metadata ) @@ -2834,6 +3856,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListDbSystemShapes", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbSystemShapes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListDbSystemShapes._get_response( self._host, @@ -2854,7 +3903,31 @@ def __call__( pb_resp = oracledatabase.ListDbSystemShapesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_db_system_shapes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + oracledatabase.ListDbSystemShapesResponse.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.oracledatabase_v1.OracleDatabaseClient.list_db_system_shapes", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListDbSystemShapes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEntitlements( @@ -2891,7 +3964,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]]] = (), ) -> oracledatabase.ListEntitlementsResponse: r"""Call the list entitlements method over HTTP. @@ -2901,8 +3974,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: ~.oracledatabase.ListEntitlementsResponse: @@ -2912,6 +3987,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListEntitlements._get_http_options() ) + request, metadata = self._interceptor.pre_list_entitlements( request, metadata ) @@ -2924,6 +4000,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListEntitlements", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListEntitlements", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListEntitlements._get_response( self._host, @@ -2944,7 +4047,31 @@ def __call__( pb_resp = oracledatabase.ListEntitlementsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_entitlements(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oracledatabase.ListEntitlementsResponse.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.oracledatabase_v1.OracleDatabaseClient.list_entitlements", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListEntitlements", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGiVersions( @@ -2981,7 +4108,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]]] = (), ) -> oracledatabase.ListGiVersionsResponse: r"""Call the list gi versions method over HTTP. @@ -2991,8 +4118,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: ~.oracledatabase.ListGiVersionsResponse: @@ -3002,6 +4131,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListGiVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_gi_versions( request, metadata ) @@ -3014,6 +4144,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 = 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.oracledatabase_v1.OracleDatabaseClient.ListGiVersions", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListGiVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListGiVersions._get_response( self._host, @@ -3034,7 +4191,31 @@ def __call__( pb_resp = oracledatabase.ListGiVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_gi_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = oracledatabase.ListGiVersionsResponse.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.oracledatabase_v1.OracleDatabaseClient.list_gi_versions", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListGiVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreAutonomousDatabase( @@ -3073,7 +4254,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]]] = (), ) -> operations_pb2.Operation: r"""Call the restore autonomous database method over HTTP. @@ -3084,8 +4265,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: ~.operations_pb2.Operation: @@ -3098,6 +4281,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseRestoreAutonomousDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_restore_autonomous_database( request, metadata ) @@ -3114,6 +4298,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.oracledatabase_v1.OracleDatabaseClient.RestoreAutonomousDatabase", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "RestoreAutonomousDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( OracleDatabaseRestTransport._RestoreAutonomousDatabase._get_response( @@ -3135,7 +4346,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_autonomous_database(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.oracledatabase_v1.OracleDatabaseClient.restore_autonomous_database", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "RestoreAutonomousDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3407,7 +4640,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. @@ -3417,8 +4650,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. @@ -3427,6 +4662,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3437,6 +4673,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.oracledatabase_v1.OracleDatabaseClient.GetLocation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GetLocation._get_response( self._host, @@ -3456,6 +4719,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.oracledatabase_v1.OracleDatabaseAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3496,7 +4780,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. @@ -3506,8 +4790,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. @@ -3516,6 +4802,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3526,6 +4813,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.oracledatabase_v1.OracleDatabaseClient.ListLocations", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListLocations._get_response( self._host, @@ -3545,6 +4859,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.oracledatabase_v1.OracleDatabaseAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3586,7 +4921,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -3596,13 +4931,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 = ( _BaseOracleDatabaseRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -3619,6 +4957,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.oracledatabase_v1.OracleDatabaseClient.CancelOperation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._CancelOperation._get_response( self._host, @@ -3675,7 +5040,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3685,13 +5050,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 = ( _BaseOracleDatabaseRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3704,6 +5072,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.oracledatabase_v1.OracleDatabaseClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._DeleteOperation._get_response( self._host, @@ -3759,7 +5154,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3769,8 +5164,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: operations_pb2.Operation: Response from GetOperation method. @@ -3779,6 +5176,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3789,6 +5187,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.oracledatabase_v1.OracleDatabaseClient.GetOperation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._GetOperation._get_response( self._host, @@ -3808,6 +5233,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.oracledatabase_v1.OracleDatabaseAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3848,7 +5294,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3858,8 +5304,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3868,6 +5316,7 @@ def __call__( http_options = ( _BaseOracleDatabaseRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseOracleDatabaseRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3878,6 +5327,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.oracledatabase_v1.OracleDatabaseClient.ListOperations", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OracleDatabaseRestTransport._ListOperations._get_response( self._host, @@ -3897,6 +5373,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.oracledatabase_v1.OracleDatabaseAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.oracledatabase.v1.OracleDatabase", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/types/exadata_infra.py b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/types/exadata_infra.py index 632f3e786112..263d3a4b447f 100644 --- a/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/types/exadata_infra.py +++ b/packages/google-cloud-oracledatabase/google/cloud/oracledatabase_v1/types/exadata_infra.py @@ -131,18 +131,18 @@ class CloudExadataInfrastructureProperties(proto.Message): Output only. Deep link to the OCI console to view this resource. cpu_count (int): - Optional. The number of enabled CPU cores. + Output only. The number of enabled CPU cores. max_cpu_count (int): Output only. The total number of CPU cores available. memory_size_gb (int): - Optional. The memory allocated in GBs. + Output only. The memory allocated in GBs. max_memory_gb (int): Output only. The total memory available in GBs. db_node_storage_size_gb (int): - Optional. The local node storage allocated in - GBs. + Output only. The local node storage allocated + in GBs. max_db_node_storage_size_gb (int): Output only. The total local node storage available in GBs. diff --git a/packages/google-cloud-oracledatabase/samples/generated_samples/snippet_metadata_google.cloud.oracledatabase.v1.json b/packages/google-cloud-oracledatabase/samples/generated_samples/snippet_metadata_google.cloud.oracledatabase.v1.json index ba8c376b241c..741c0c019914 100644 --- a/packages/google-cloud-oracledatabase/samples/generated_samples/snippet_metadata_google.cloud.oracledatabase.v1.json +++ b/packages/google-cloud-oracledatabase/samples/generated_samples/snippet_metadata_google.cloud.oracledatabase.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-oracledatabase", - "version": "0.1.2" + "version": "0.1.0" }, "snippets": [ { @@ -54,7 +54,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -142,7 +142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -230,7 +230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -310,7 +310,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -390,7 +390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -470,7 +470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.types.GenerateAutonomousDatabaseWalletResponse", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.types.AutonomousDatabase", @@ -722,7 +722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.types.CloudExadataInfrastructure", @@ -802,7 +802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.types.CloudVmCluster", @@ -882,7 +882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabaseBackupsPager", @@ -962,7 +962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabaseCharacterSetsPager", @@ -1042,7 +1042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDatabasesPager", @@ -1122,7 +1122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListAutonomousDbVersionsPager", @@ -1202,7 +1202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListCloudExadataInfrastructuresPager", @@ -1282,7 +1282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListCloudVmClustersPager", @@ -1362,7 +1362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListDbNodesPager", @@ -1442,7 +1442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListDbServersPager", @@ -1522,7 +1522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListDbSystemShapesPager", @@ -1602,7 +1602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListEntitlementsPager", @@ -1682,7 +1682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.oracledatabase_v1.services.oracle_database.pagers.ListGiVersionsPager", @@ -1766,7 +1766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-oracledatabase/tests/unit/gapic/oracledatabase_v1/test_oracle_database.py b/packages/google-cloud-oracledatabase/tests/unit/gapic/oracledatabase_v1/test_oracle_database.py index 02632bd7baaf..ce4a0ef02fba 100644 --- a/packages/google-cloud-oracledatabase/tests/unit/gapic/oracledatabase_v1/test_oracle_database.py +++ b/packages/google-cloud-oracledatabase/tests/unit/gapic/oracledatabase_v1/test_oracle_database.py @@ -1046,6 +1046,7 @@ def test_list_cloud_exadata_infrastructures_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.list_cloud_exadata_infrastructures(request) @@ -1103,6 +1104,7 @@ def test_list_cloud_exadata_infrastructures_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_cloud_exadata_infrastructures(**mock_args) @@ -1309,6 +1311,7 @@ def test_get_cloud_exadata_infrastructure_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_cloud_exadata_infrastructure(request) @@ -1358,6 +1361,7 @@ def test_get_cloud_exadata_infrastructure_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_cloud_exadata_infrastructure(**mock_args) @@ -1518,6 +1522,7 @@ def test_create_cloud_exadata_infrastructure_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.create_cloud_exadata_infrastructure(request) @@ -1587,6 +1592,7 @@ def test_create_cloud_exadata_infrastructure_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_cloud_exadata_infrastructure(**mock_args) @@ -1737,6 +1743,7 @@ def test_delete_cloud_exadata_infrastructure_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.delete_cloud_exadata_infrastructure(request) @@ -1792,6 +1799,7 @@ def test_delete_cloud_exadata_infrastructure_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.delete_cloud_exadata_infrastructure(**mock_args) @@ -1938,6 +1946,7 @@ def test_list_cloud_vm_clusters_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.list_cloud_vm_clusters(request) @@ -1992,6 +2001,7 @@ def test_list_cloud_vm_clusters_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_cloud_vm_clusters(**mock_args) @@ -2190,6 +2200,7 @@ def test_get_cloud_vm_cluster_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_cloud_vm_cluster(request) @@ -2237,6 +2248,7 @@ def test_get_cloud_vm_cluster_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_cloud_vm_cluster(**mock_args) @@ -2389,6 +2401,7 @@ def test_create_cloud_vm_cluster_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.create_cloud_vm_cluster(request) @@ -2454,6 +2467,7 @@ def test_create_cloud_vm_cluster_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_cloud_vm_cluster(**mock_args) @@ -2600,6 +2614,7 @@ def test_delete_cloud_vm_cluster_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.delete_cloud_vm_cluster(request) @@ -2653,6 +2668,7 @@ def test_delete_cloud_vm_cluster_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.delete_cloud_vm_cluster(**mock_args) @@ -2793,6 +2809,7 @@ def test_list_entitlements_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.list_entitlements(request) @@ -2846,6 +2863,7 @@ def test_list_entitlements_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_entitlements(**mock_args) @@ -3047,6 +3065,7 @@ def test_list_db_servers_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.list_db_servers(request) @@ -3102,6 +3121,7 @@ def test_list_db_servers_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_db_servers(**mock_args) @@ -3305,6 +3325,7 @@ def test_list_db_nodes_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.list_db_nodes(request) @@ -3360,6 +3381,7 @@ def test_list_db_nodes_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_db_nodes(**mock_args) @@ -3565,6 +3587,7 @@ def test_list_gi_versions_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.list_gi_versions(request) @@ -3618,6 +3641,7 @@ def test_list_gi_versions_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_gi_versions(**mock_args) @@ -3823,6 +3847,7 @@ def test_list_db_system_shapes_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.list_db_system_shapes(request) @@ -3876,6 +3901,7 @@ def test_list_db_system_shapes_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_db_system_shapes(**mock_args) @@ -4086,6 +4112,7 @@ def test_list_autonomous_databases_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.list_autonomous_databases(request) @@ -4141,6 +4168,7 @@ def test_list_autonomous_databases_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_autonomous_databases(**mock_args) @@ -4342,6 +4370,7 @@ def test_get_autonomous_database_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_autonomous_database(request) @@ -4389,6 +4418,7 @@ def test_get_autonomous_database_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_autonomous_database(**mock_args) @@ -4544,6 +4574,7 @@ def test_create_autonomous_database_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.create_autonomous_database(request) @@ -4611,6 +4642,7 @@ def test_create_autonomous_database_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_autonomous_database(**mock_args) @@ -4754,6 +4786,7 @@ def test_delete_autonomous_database_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.delete_autonomous_database(request) @@ -4799,6 +4832,7 @@ def test_delete_autonomous_database_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.delete_autonomous_database(**mock_args) @@ -4937,6 +4971,7 @@ def test_restore_autonomous_database_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.restore_autonomous_database(request) @@ -4991,6 +5026,7 @@ def test_restore_autonomous_database_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.restore_autonomous_database(**mock_args) @@ -5135,6 +5171,7 @@ def test_generate_autonomous_database_wallet_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.generate_autonomous_database_wallet(request) @@ -5197,6 +5234,7 @@ def test_generate_autonomous_database_wallet_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.generate_autonomous_database_wallet(**mock_args) @@ -5347,6 +5385,7 @@ def test_list_autonomous_db_versions_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.list_autonomous_db_versions(request) @@ -5400,6 +5439,7 @@ def test_list_autonomous_db_versions_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_autonomous_db_versions(**mock_args) @@ -5617,6 +5657,7 @@ def test_list_autonomous_database_character_sets_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.list_autonomous_database_character_sets(request) @@ -5675,6 +5716,7 @@ def test_list_autonomous_database_character_sets_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_autonomous_database_character_sets(**mock_args) @@ -5894,6 +5936,7 @@ def test_list_autonomous_database_backups_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.list_autonomous_database_backups(request) @@ -5952,6 +5995,7 @@ def test_list_autonomous_database_backups_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_autonomous_database_backups(**mock_args) @@ -6153,6 +6197,7 @@ def test_list_cloud_exadata_infrastructures_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.list_cloud_exadata_infrastructures(request) @@ -6190,6 +6235,7 @@ def test_list_cloud_exadata_infrastructures_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_cloud_exadata_infrastructures(request) # Establish that the response is the type that we expect. @@ -6232,6 +6278,7 @@ def test_list_cloud_exadata_infrastructures_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 = oracledatabase.ListCloudExadataInfrastructuresResponse.to_json( oracledatabase.ListCloudExadataInfrastructuresResponse() ) @@ -6280,6 +6327,7 @@ def test_get_cloud_exadata_infrastructure_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_cloud_exadata_infrastructure(request) @@ -6320,6 +6368,7 @@ def test_get_cloud_exadata_infrastructure_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_cloud_exadata_infrastructure(request) # Establish that the response is the type that we expect. @@ -6364,6 +6413,7 @@ def test_get_cloud_exadata_infrastructure_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 = exadata_infra.CloudExadataInfrastructure.to_json( exadata_infra.CloudExadataInfrastructure() ) @@ -6410,6 +6460,7 @@ def test_create_cloud_exadata_infrastructure_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.create_cloud_exadata_infrastructure(request) @@ -6560,6 +6611,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_cloud_exadata_infrastructure(request) # Establish that the response is the type that we expect. @@ -6603,6 +6655,7 @@ def test_create_cloud_exadata_infrastructure_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6649,6 +6702,7 @@ def test_delete_cloud_exadata_infrastructure_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.delete_cloud_exadata_infrastructure(request) @@ -6681,6 +6735,7 @@ def test_delete_cloud_exadata_infrastructure_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.delete_cloud_exadata_infrastructure(request) # Establish that the response is the type that we expect. @@ -6724,6 +6779,7 @@ def test_delete_cloud_exadata_infrastructure_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6768,6 +6824,7 @@ def test_list_cloud_vm_clusters_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.list_cloud_vm_clusters(request) @@ -6803,6 +6860,7 @@ def test_list_cloud_vm_clusters_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_cloud_vm_clusters(request) # Establish that the response is the type that we expect. @@ -6843,6 +6901,7 @@ def test_list_cloud_vm_clusters_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 = oracledatabase.ListCloudVmClustersResponse.to_json( oracledatabase.ListCloudVmClustersResponse() ) @@ -6891,6 +6950,7 @@ def test_get_cloud_vm_cluster_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_cloud_vm_cluster(request) @@ -6934,6 +6994,7 @@ def test_get_cloud_vm_cluster_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_cloud_vm_cluster(request) # Establish that the response is the type that we expect. @@ -6980,6 +7041,7 @@ def test_get_cloud_vm_cluster_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 = vm_cluster.CloudVmCluster.to_json(vm_cluster.CloudVmCluster()) req.return_value.content = return_value @@ -7024,6 +7086,7 @@ def test_create_cloud_vm_cluster_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.create_cloud_vm_cluster(request) @@ -7172,6 +7235,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_cloud_vm_cluster(request) # Establish that the response is the type that we expect. @@ -7213,6 +7277,7 @@ def test_create_cloud_vm_cluster_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7259,6 +7324,7 @@ def test_delete_cloud_vm_cluster_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.delete_cloud_vm_cluster(request) @@ -7291,6 +7357,7 @@ def test_delete_cloud_vm_cluster_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.delete_cloud_vm_cluster(request) # Establish that the response is the type that we expect. @@ -7332,6 +7399,7 @@ def test_delete_cloud_vm_cluster_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7376,6 +7444,7 @@ def test_list_entitlements_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.list_entitlements(request) @@ -7411,6 +7480,7 @@ def test_list_entitlements_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_entitlements(request) # Establish that the response is the type that we expect. @@ -7451,6 +7521,7 @@ def test_list_entitlements_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 = oracledatabase.ListEntitlementsResponse.to_json( oracledatabase.ListEntitlementsResponse() ) @@ -7499,6 +7570,7 @@ def test_list_db_servers_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.list_db_servers(request) @@ -7536,6 +7608,7 @@ def test_list_db_servers_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_db_servers(request) # Establish that the response is the type that we expect. @@ -7576,6 +7649,7 @@ def test_list_db_servers_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 = oracledatabase.ListDbServersResponse.to_json( oracledatabase.ListDbServersResponse() ) @@ -7622,6 +7696,7 @@ def test_list_db_nodes_rest_bad_request(request_type=oracledatabase.ListDbNodesR 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_db_nodes(request) @@ -7659,6 +7734,7 @@ def test_list_db_nodes_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_db_nodes(request) # Establish that the response is the type that we expect. @@ -7699,6 +7775,7 @@ def test_list_db_nodes_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 = oracledatabase.ListDbNodesResponse.to_json( oracledatabase.ListDbNodesResponse() ) @@ -7745,6 +7822,7 @@ def test_list_gi_versions_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.list_gi_versions(request) @@ -7780,6 +7858,7 @@ def test_list_gi_versions_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_gi_versions(request) # Establish that the response is the type that we expect. @@ -7820,6 +7899,7 @@ def test_list_gi_versions_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 = oracledatabase.ListGiVersionsResponse.to_json( oracledatabase.ListGiVersionsResponse() ) @@ -7866,6 +7946,7 @@ def test_list_db_system_shapes_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.list_db_system_shapes(request) @@ -7901,6 +7982,7 @@ def test_list_db_system_shapes_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_db_system_shapes(request) # Establish that the response is the type that we expect. @@ -7941,6 +8023,7 @@ def test_list_db_system_shapes_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 = oracledatabase.ListDbSystemShapesResponse.to_json( oracledatabase.ListDbSystemShapesResponse() ) @@ -7987,6 +8070,7 @@ def test_list_autonomous_databases_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.list_autonomous_databases(request) @@ -8022,6 +8106,7 @@ def test_list_autonomous_databases_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_autonomous_databases(request) # Establish that the response is the type that we expect. @@ -8062,6 +8147,7 @@ def test_list_autonomous_databases_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 = oracledatabase.ListAutonomousDatabasesResponse.to_json( oracledatabase.ListAutonomousDatabasesResponse() ) @@ -8110,6 +8196,7 @@ def test_get_autonomous_database_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_autonomous_database(request) @@ -8153,6 +8240,7 @@ def test_get_autonomous_database_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_autonomous_database(request) # Establish that the response is the type that we expect. @@ -8199,6 +8287,7 @@ def test_get_autonomous_database_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 = autonomous_database.AutonomousDatabase.to_json( autonomous_database.AutonomousDatabase() ) @@ -8245,6 +8334,7 @@ def test_create_autonomous_database_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.create_autonomous_database(request) @@ -8472,6 +8562,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_autonomous_database(request) # Establish that the response is the type that we expect. @@ -8513,6 +8604,7 @@ def test_create_autonomous_database_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8559,6 +8651,7 @@ def test_delete_autonomous_database_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.delete_autonomous_database(request) @@ -8591,6 +8684,7 @@ def test_delete_autonomous_database_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.delete_autonomous_database(request) # Establish that the response is the type that we expect. @@ -8632,6 +8726,7 @@ def test_delete_autonomous_database_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8678,6 +8773,7 @@ def test_restore_autonomous_database_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.restore_autonomous_database(request) @@ -8710,6 +8806,7 @@ def test_restore_autonomous_database_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.restore_autonomous_database(request) # Establish that the response is the type that we expect. @@ -8751,6 +8848,7 @@ def test_restore_autonomous_database_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8797,6 +8895,7 @@ def test_generate_autonomous_database_wallet_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.generate_autonomous_database_wallet(request) @@ -8836,6 +8935,7 @@ def test_generate_autonomous_database_wallet_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.generate_autonomous_database_wallet(request) # Establish that the response is the type that we expect. @@ -8878,6 +8978,7 @@ def test_generate_autonomous_database_wallet_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 = oracledatabase.GenerateAutonomousDatabaseWalletResponse.to_json( oracledatabase.GenerateAutonomousDatabaseWalletResponse() ) @@ -8924,6 +9025,7 @@ def test_list_autonomous_db_versions_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.list_autonomous_db_versions(request) @@ -8959,6 +9061,7 @@ def test_list_autonomous_db_versions_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_autonomous_db_versions(request) # Establish that the response is the type that we expect. @@ -8999,6 +9102,7 @@ def test_list_autonomous_db_versions_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 = oracledatabase.ListAutonomousDbVersionsResponse.to_json( oracledatabase.ListAutonomousDbVersionsResponse() ) @@ -9045,6 +9149,7 @@ def test_list_autonomous_database_character_sets_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.list_autonomous_database_character_sets(request) @@ -9082,6 +9187,7 @@ def test_list_autonomous_database_character_sets_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_autonomous_database_character_sets(request) # Establish that the response is the type that we expect. @@ -9124,6 +9230,7 @@ def test_list_autonomous_database_character_sets_rest_interceptors(null_intercep 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 = ( oracledatabase.ListAutonomousDatabaseCharacterSetsResponse.to_json( oracledatabase.ListAutonomousDatabaseCharacterSetsResponse() @@ -9172,6 +9279,7 @@ def test_list_autonomous_database_backups_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.list_autonomous_database_backups(request) @@ -9209,6 +9317,7 @@ def test_list_autonomous_database_backups_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_autonomous_database_backups(request) # Establish that the response is the type that we expect. @@ -9250,6 +9359,7 @@ def test_list_autonomous_database_backups_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 = oracledatabase.ListAutonomousDatabaseBackupsResponse.to_json( oracledatabase.ListAutonomousDatabaseBackupsResponse() ) @@ -9296,6 +9406,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) @@ -9326,6 +9437,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) @@ -9354,6 +9466,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) @@ -9384,6 +9497,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) @@ -9414,6 +9528,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -9444,6 +9559,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -9474,6 +9590,7 @@ def test_delete_operation_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.delete_operation(request) @@ -9504,6 +9621,7 @@ def test_delete_operation_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.delete_operation(request) @@ -9534,6 +9652,7 @@ def test_get_operation_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.get_operation(request) @@ -9564,6 +9683,7 @@ def test_get_operation_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_operation(request) @@ -9594,6 +9714,7 @@ def test_list_operations_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_operations(request) @@ -9624,6 +9745,7 @@ def test_list_operations_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_operations(request) From dfe5518bf0c5ef8a26681625d36c6e325b59feda 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 18:33:29 +0500 Subject: [PATCH 11/16] feat: [google-cloud-compute] Add support for opt-in debug logging (#13336) 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 feat: [google-cloud-compute] Update Compute Engine API to revision 20241201 (https://github.com/googleapis/google-cloud-python/issues/966) 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== BEGIN_NESTED_COMMIT feat: [google-cloud-compute] Update Compute Engine API to revision 20241201 (#966) Source-Link: https://github.com/googleapis/googleapis/commit/5d5b1bf126485b0e2c972bac41b376438601e266 Source-Link: https://github.com/googleapis/googleapis-gen/commit/c735b6193daebaa9c45c2e23153af16aee732fe6 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImM3MzViNjE5M2RhZWJhYTljNDVjMmUyMzE1M2FmMTZhZWU3MzJmZTYifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../docs/compute_v1/network_profiles.rst | 10 + .../docs/compute_v1/services_.rst | 1 + .../google/cloud/compute/__init__.py | 52 + .../google/cloud/compute/gapic_version.py | 2 +- .../google/cloud/compute_v1/__init__.py | 50 + .../cloud/compute_v1/gapic_metadata.json | 64 + .../google/cloud/compute_v1/gapic_version.py | 2 +- .../services/accelerator_types/client.py | 61 +- .../services/accelerator_types/pagers.py | 16 +- .../accelerator_types/transports/rest.py | 203 +- .../compute_v1/services/addresses/client.py | 125 +- .../compute_v1/services/addresses/pagers.py | 16 +- .../services/addresses/transports/rest.py | 458 +- .../compute_v1/services/autoscalers/client.py | 125 +- .../compute_v1/services/autoscalers/pagers.py | 16 +- .../services/autoscalers/transports/rest.py | 457 +- .../services/backend_buckets/client.py | 189 +- .../services/backend_buckets/pagers.py | 8 +- .../backend_buckets/transports/rest.py | 778 +- .../services/backend_services/client.py | 229 +- .../services/backend_services/pagers.py | 24 +- .../backend_services/transports/rest.py | 1041 ++- .../compute_v1/services/disk_types/client.py | 61 +- .../compute_v1/services/disk_types/pagers.py | 16 +- .../services/disk_types/transports/rest.py | 202 +- .../cloud/compute_v1/services/disks/client.py | 277 +- .../cloud/compute_v1/services/disks/pagers.py | 16 +- .../services/disks/transports/rest.py | 1163 ++- .../services/external_vpn_gateways/client.py | 109 +- .../services/external_vpn_gateways/pagers.py | 8 +- .../external_vpn_gateways/transports/rest.py | 394 +- .../services/firewall_policies/client.py | 261 +- .../services/firewall_policies/pagers.py | 8 +- .../firewall_policies/transports/rest.py | 1169 ++- .../compute_v1/services/firewalls/client.py | 117 +- .../compute_v1/services/firewalls/pagers.py | 8 +- .../services/firewalls/transports/rest.py | 388 +- .../services/forwarding_rules/client.py | 141 +- .../services/forwarding_rules/pagers.py | 16 +- .../forwarding_rules/transports/rest.py | 525 +- .../services/global_addresses/client.py | 117 +- .../services/global_addresses/pagers.py | 8 +- .../global_addresses/transports/rest.py | 394 +- .../global_forwarding_rules/client.py | 133 +- .../global_forwarding_rules/pagers.py | 8 +- .../transports/rest.py | 464 +- .../global_network_endpoint_groups/client.py | 125 +- .../global_network_endpoint_groups/pagers.py | 16 +- .../transports/rest.py | 456 +- .../services/global_operations/client.py | 77 +- .../services/global_operations/pagers.py | 16 +- .../global_operations/transports/rest.py | 331 +- .../global_organization_operations/client.py | 61 +- .../global_organization_operations/pagers.py | 8 +- .../transports/rest.py | 203 +- .../client.py | 101 +- .../pagers.py | 8 +- .../transports/rest.py | 327 +- .../services/health_checks/client.py | 125 +- .../services/health_checks/pagers.py | 16 +- .../services/health_checks/transports/rest.py | 459 +- .../services/image_family_views/client.py | 45 +- .../image_family_views/transports/rest.py | 74 +- .../compute_v1/services/images/client.py | 165 +- .../compute_v1/services/images/pagers.py | 8 +- .../services/images/transports/rest.py | 710 +- .../client.py | 101 +- .../pagers.py | 8 +- .../transports/rest.py | 328 +- .../instance_group_managers/client.py | 2009 ++++- .../instance_group_managers/pagers.py | 40 +- .../transports/base.py | 56 + .../transports/rest.py | 2184 +++++- .../transports/rest_base.py | 224 + .../services/instance_groups/client.py | 149 +- .../services/instance_groups/pagers.py | 24 +- .../instance_groups/transports/rest.py | 595 +- .../instance_settings_service/client.py | 61 +- .../transports/rest.py | 138 +- .../services/instance_templates/client.py | 117 +- .../services/instance_templates/pagers.py | 16 +- .../instance_templates/transports/rest.py | 524 +- .../compute_v1/services/instances/client.py | 701 +- .../compute_v1/services/instances/pagers.py | 24 +- .../services/instances/transports/rest.py | 3082 +++++++- .../services/instant_snapshots/client.py | 133 +- .../services/instant_snapshots/pagers.py | 16 +- .../instant_snapshots/transports/rest.py | 588 +- .../interconnect_attachments/client.py | 125 +- .../interconnect_attachments/pagers.py | 16 +- .../transports/rest.py | 465 +- .../services/interconnect_locations/client.py | 53 +- .../services/interconnect_locations/pagers.py | 8 +- .../interconnect_locations/transports/rest.py | 141 +- .../interconnect_remote_locations/client.py | 53 +- .../interconnect_remote_locations/pagers.py | 8 +- .../transports/rest.py | 142 +- .../services/interconnects/client.py | 133 +- .../services/interconnects/pagers.py | 8 +- .../services/interconnects/transports/rest.py | 526 +- .../services/license_codes/client.py | 53 +- .../services/license_codes/transports/rest.py | 137 +- .../compute_v1/services/licenses/client.py | 109 +- .../compute_v1/services/licenses/pagers.py | 8 +- .../services/licenses/transports/rest.py | 459 +- .../services/machine_images/client.py | 109 +- .../services/machine_images/pagers.py | 8 +- .../machine_images/transports/rest.py | 455 +- .../services/machine_types/client.py | 61 +- .../services/machine_types/pagers.py | 16 +- .../services/machine_types/transports/rest.py | 203 +- .../services/network_attachments/client.py | 133 +- .../services/network_attachments/pagers.py | 16 +- .../network_attachments/transports/rest.py | 588 +- .../network_edge_security_services/client.py | 101 +- .../network_edge_security_services/pagers.py | 8 +- .../transports/rest.py | 332 +- .../network_endpoint_groups/client.py | 141 +- .../network_endpoint_groups/pagers.py | 24 +- .../transports/rest.py | 589 +- .../network_firewall_policies/client.py | 237 +- .../network_firewall_policies/pagers.py | 8 +- .../transports/rest.py | 1032 ++- .../services/network_profiles/__init__.py | 18 + .../services/network_profiles/client.py | 921 +++ .../services/network_profiles/pagers.py | 117 + .../network_profiles/transports/README.rst | 9 + .../network_profiles/transports/__init__.py | 30 + .../network_profiles/transports/base.py | 182 + .../network_profiles/transports/rest.py | 550 ++ .../network_profiles/transports/rest_base.py | 183 + .../compute_v1/services/networks/client.py | 181 +- .../compute_v1/services/networks/pagers.py | 16 +- .../services/networks/transports/rest.py | 721 +- .../compute_v1/services/node_groups/client.py | 221 +- .../compute_v1/services/node_groups/pagers.py | 24 +- .../services/node_groups/transports/rest.py | 963 ++- .../services/node_templates/client.py | 117 +- .../services/node_templates/pagers.py | 16 +- .../node_templates/transports/rest.py | 522 +- .../compute_v1/services/node_types/client.py | 61 +- .../compute_v1/services/node_types/pagers.py | 16 +- .../services/node_types/transports/rest.py | 202 +- .../services/packet_mirrorings/client.py | 117 +- .../services/packet_mirrorings/pagers.py | 16 +- .../packet_mirrorings/transports/rest.py | 458 +- .../compute_v1/services/projects/client.py | 229 +- .../compute_v1/services/projects/pagers.py | 16 +- .../services/projects/transports/rest.py | 906 ++- .../public_advertised_prefixes/client.py | 133 +- .../public_advertised_prefixes/pagers.py | 8 +- .../transports/rest.py | 463 +- .../public_delegated_prefixes/client.py | 141 +- .../public_delegated_prefixes/pagers.py | 16 +- .../transports/rest.py | 528 +- .../services/region_autoscalers/client.py | 117 +- .../services/region_autoscalers/pagers.py | 8 +- .../region_autoscalers/transports/rest.py | 394 +- .../region_backend_services/client.py | 173 +- .../region_backend_services/pagers.py | 16 +- .../transports/rest.py | 783 +- .../services/region_commitments/client.py | 93 +- .../services/region_commitments/pagers.py | 16 +- .../region_commitments/transports/rest.py | 331 +- .../services/region_disk_types/client.py | 53 +- .../services/region_disk_types/pagers.py | 8 +- .../region_disk_types/transports/rest.py | 138 +- .../services/region_disks/client.py | 269 +- .../services/region_disks/pagers.py | 8 +- .../services/region_disks/transports/rest.py | 1094 ++- .../region_health_check_services/client.py | 101 +- .../region_health_check_services/pagers.py | 8 +- .../transports/rest.py | 331 +- .../services/region_health_checks/client.py | 117 +- .../services/region_health_checks/pagers.py | 8 +- .../region_health_checks/transports/rest.py | 394 +- .../region_instance_group_managers/client.py | 2017 ++++- .../region_instance_group_managers/pagers.py | 32 +- .../transports/base.py | 56 + .../transports/rest.py | 2119 +++++- .../transports/rest_base.py | 232 + .../services/region_instance_groups/client.py | 77 +- .../services/region_instance_groups/pagers.py | 16 +- .../region_instance_groups/transports/rest.py | 266 +- .../region_instance_templates/client.py | 85 +- .../region_instance_templates/pagers.py | 8 +- .../transports/rest.py | 270 +- .../services/region_instances/client.py | 53 +- .../region_instances/transports/rest.py | 74 +- .../region_instant_snapshots/client.py | 125 +- .../region_instant_snapshots/pagers.py | 8 +- .../transports/rest.py | 520 +- .../region_network_endpoint_groups/client.py | 125 +- .../region_network_endpoint_groups/pagers.py | 16 +- .../transports/rest.py | 456 +- .../client.py | 245 +- .../pagers.py | 8 +- .../transports/rest.py | 1078 ++- .../region_notification_endpoints/client.py | 85 +- .../region_notification_endpoints/pagers.py | 8 +- .../transports/rest.py | 266 +- .../services/region_operations/client.py | 69 +- .../services/region_operations/pagers.py | 8 +- .../region_operations/transports/rest.py | 268 +- .../region_security_policies/client.py | 476 +- .../region_security_policies/pagers.py | 8 +- .../transports/base.py | 14 + .../transports/rest.py | 798 +- .../transports/rest_base.py | 56 + .../region_ssl_certificates/client.py | 85 +- .../region_ssl_certificates/pagers.py | 8 +- .../transports/rest.py | 269 +- .../services/region_ssl_policies/client.py | 109 +- .../services/region_ssl_policies/pagers.py | 8 +- .../region_ssl_policies/transports/rest.py | 397 +- .../region_target_http_proxies/client.py | 101 +- .../region_target_http_proxies/pagers.py | 8 +- .../transports/rest.py | 332 +- .../region_target_https_proxies/client.py | 143 +- .../region_target_https_proxies/pagers.py | 8 +- .../transports/rest.py | 470 +- .../region_target_tcp_proxies/client.py | 85 +- .../region_target_tcp_proxies/pagers.py | 8 +- .../transports/rest.py | 269 +- .../services/region_url_maps/client.py | 125 +- .../services/region_url_maps/pagers.py | 8 +- .../region_url_maps/transports/rest.py | 456 +- .../services/region_zones/client.py | 45 +- .../services/region_zones/pagers.py | 8 +- .../services/region_zones/transports/rest.py | 72 +- .../compute_v1/services/regions/client.py | 53 +- .../compute_v1/services/regions/pagers.py | 8 +- .../services/regions/transports/rest.py | 138 +- .../services/reservations/client.py | 149 +- .../services/reservations/pagers.py | 16 +- .../services/reservations/transports/rest.py | 652 +- .../services/resource_policies/client.py | 133 +- .../services/resource_policies/pagers.py | 16 +- .../resource_policies/transports/rest.py | 588 +- .../compute_v1/services/routers/client.py | 157 +- .../compute_v1/services/routers/pagers.py | 24 +- .../services/routers/transports/rest.py | 716 +- .../compute_v1/services/routes/client.py | 85 +- .../compute_v1/services/routes/pagers.py | 8 +- .../services/routes/transports/rest.py | 266 +- .../services/security_policies/client.py | 189 +- .../services/security_policies/pagers.py | 16 +- .../security_policies/transports/rest.py | 779 +- .../services/service_attachments/client.py | 133 +- .../services/service_attachments/pagers.py | 16 +- .../service_attachments/transports/rest.py | 588 +- .../snapshot_settings_service/client.py | 61 +- .../transports/rest.py | 138 +- .../compute_v1/services/snapshots/client.py | 125 +- .../compute_v1/services/snapshots/pagers.py | 8 +- .../services/snapshots/transports/rest.py | 519 +- .../services/ssl_certificates/client.py | 93 +- .../services/ssl_certificates/pagers.py | 16 +- .../ssl_certificates/transports/rest.py | 333 +- .../services/ssl_policies/client.py | 117 +- .../services/ssl_policies/pagers.py | 16 +- .../services/ssl_policies/transports/rest.py | 456 +- .../services/storage_pool_types/client.py | 61 +- .../services/storage_pool_types/pagers.py | 16 +- .../storage_pool_types/transports/rest.py | 203 +- .../services/storage_pools/client.py | 141 +- .../services/storage_pools/pagers.py | 24 +- .../services/storage_pools/transports/rest.py | 652 +- .../compute_v1/services/subnetworks/client.py | 173 +- .../compute_v1/services/subnetworks/pagers.py | 24 +- .../services/subnetworks/transports/rest.py | 780 +- .../services/target_grpc_proxies/client.py | 101 +- .../services/target_grpc_proxies/pagers.py | 8 +- .../target_grpc_proxies/transports/rest.py | 330 +- .../services/target_http_proxies/client.py | 125 +- .../services/target_http_proxies/pagers.py | 16 +- .../target_http_proxies/transports/rest.py | 459 +- .../services/target_https_proxies/client.py | 199 +- .../services/target_https_proxies/pagers.py | 16 +- .../target_https_proxies/transports/rest.py | 724 +- .../services/target_instances/client.py | 109 +- .../services/target_instances/pagers.py | 16 +- .../target_instances/transports/rest.py | 396 +- .../services/target_pools/client.py | 197 +- .../services/target_pools/pagers.py | 16 +- .../services/target_pools/transports/rest.py | 783 +- .../services/target_ssl_proxies/client.py | 165 +- .../services/target_ssl_proxies/pagers.py | 8 +- .../target_ssl_proxies/transports/rest.py | 585 +- .../services/target_tcp_proxies/client.py | 125 +- .../services/target_tcp_proxies/pagers.py | 16 +- .../target_tcp_proxies/transports/rest.py | 459 +- .../services/target_vpn_gateways/client.py | 109 +- .../services/target_vpn_gateways/pagers.py | 16 +- .../target_vpn_gateways/transports/rest.py | 396 +- .../compute_v1/services/url_maps/client.py | 149 +- .../compute_v1/services/url_maps/pagers.py | 16 +- .../services/url_maps/transports/rest.py | 584 +- .../services/vpn_gateways/client.py | 125 +- .../services/vpn_gateways/pagers.py | 16 +- .../services/vpn_gateways/transports/rest.py | 526 +- .../compute_v1/services/vpn_tunnels/client.py | 109 +- .../compute_v1/services/vpn_tunnels/pagers.py | 16 +- .../services/vpn_tunnels/transports/rest.py | 388 +- .../services/zone_operations/client.py | 69 +- .../services/zone_operations/pagers.py | 8 +- .../zone_operations/transports/rest.py | 268 +- .../cloud/compute_v1/services/zones/client.py | 53 +- .../cloud/compute_v1/services/zones/pagers.py | 8 +- .../services/zones/transports/rest.py | 138 +- .../google/cloud/compute_v1/types/__init__.py | 48 + .../google/cloud/compute_v1/types/compute.py | 2662 ++++++- ...ce_group_managers_resume_instances_sync.py | 54 + ...nce_group_managers_start_instances_sync.py | 54 + ...ance_group_managers_stop_instances_sync.py | 54 + ...e_group_managers_suspend_instances_sync.py | 54 + ..._v1_generated_network_profiles_get_sync.py | 53 + ...v1_generated_network_profiles_list_sync.py | 53 + ...ce_group_managers_resume_instances_sync.py | 54 + ...nce_group_managers_start_instances_sync.py | 54 + ...ance_group_managers_stop_instances_sync.py | 54 + ...e_group_managers_suspend_instances_sync.py | 54 + ...egion_security_policies_set_labels_sync.py | 54 + ...ppet_metadata_google.cloud.compute.v1.json | 6546 ++++++++++------- .../scripts/fixup_compute_v1_keywords.py | 4 + .../compute_v1/test_accelerator_types.py | 15 + .../unit/gapic/compute_v1/test_addresses.py | 43 + .../unit/gapic/compute_v1/test_autoscalers.py | 43 + .../gapic/compute_v1/test_backend_buckets.py | 74 + .../gapic/compute_v1/test_backend_services.py | 96 + .../unit/gapic/compute_v1/test_disk_types.py | 15 + .../tests/unit/gapic/compute_v1/test_disks.py | 114 + .../compute_v1/test_external_vpn_gateways.py | 36 + .../compute_v1/test_firewall_policies.py | 106 + .../unit/gapic/compute_v1/test_firewalls.py | 38 + .../gapic/compute_v1/test_forwarding_rules.py | 50 + .../gapic/compute_v1/test_global_addresses.py | 38 + .../test_global_forwarding_rules.py | 45 + .../test_global_network_endpoint_groups.py | 43 + .../compute_v1/test_global_operations.py | 25 + .../test_global_organization_operations.py | 13 + .../test_global_public_delegated_prefixes.py | 31 + .../gapic/compute_v1/test_health_checks.py | 43 + .../compute_v1/test_image_family_views.py | 5 + .../unit/gapic/compute_v1/test_images.py | 65 + ..._instance_group_manager_resize_requests.py | 31 + .../test_instance_group_managers.py | 5612 ++++++++++---- .../gapic/compute_v1/test_instance_groups.py | 55 + .../test_instance_settings_service.py | 12 + .../compute_v1/test_instance_templates.py | 44 + .../unit/gapic/compute_v1/test_instances.py | 310 + .../compute_v1/test_instant_snapshots.py | 51 + .../test_interconnect_attachments.py | 43 + .../compute_v1/test_interconnect_locations.py | 10 + .../test_interconnect_remote_locations.py | 10 + .../gapic/compute_v1/test_interconnects.py | 48 + .../gapic/compute_v1/test_license_codes.py | 10 + .../unit/gapic/compute_v1/test_licenses.py | 39 + .../gapic/compute_v1/test_machine_images.py | 39 + .../gapic/compute_v1/test_machine_types.py | 15 + .../compute_v1/test_network_attachments.py | 51 + .../test_network_edge_security_services.py | 31 + .../test_network_endpoint_groups.py | 53 + .../test_network_firewall_policies.py | 98 + .../gapic/compute_v1/test_network_profiles.py | 2111 ++++++ .../unit/gapic/compute_v1/test_networks.py | 87 +- .../unit/gapic/compute_v1/test_node_groups.py | 91 + .../gapic/compute_v1/test_node_templates.py | 44 + .../unit/gapic/compute_v1/test_node_types.py | 15 + .../compute_v1/test_packet_mirrorings.py | 41 + .../unit/gapic/compute_v1/test_projects.py | 90 + .../test_public_advertised_prefixes.py | 45 + .../test_public_delegated_prefixes.py | 50 + .../compute_v1/test_region_autoscalers.py | 38 + .../test_region_backend_services.py | 70 + .../compute_v1/test_region_commitments.py | 29 + .../compute_v1/test_region_disk_types.py | 10 + .../gapic/compute_v1/test_region_disks.py | 109 + .../test_region_health_check_services.py | 31 + .../compute_v1/test_region_health_checks.py | 38 + .../test_region_instance_group_managers.py | 5416 +++++++++++--- .../compute_v1/test_region_instance_groups.py | 22 + .../test_region_instance_templates.py | 24 + .../gapic/compute_v1/test_region_instances.py | 7 + .../test_region_instant_snapshots.py | 46 + .../test_region_network_endpoint_groups.py | 43 + .../test_region_network_firewall_policies.py | 103 + .../test_region_notification_endpoints.py | 24 + .../compute_v1/test_region_operations.py | 20 + .../test_region_security_policies.py | 758 ++ .../test_region_ssl_certificates.py | 24 + .../compute_v1/test_region_ssl_policies.py | 36 + .../test_region_target_http_proxies.py | 31 + .../test_region_target_https_proxies.py | 45 + .../test_region_target_tcp_proxies.py | 24 + .../gapic/compute_v1/test_region_url_maps.py | 43 + .../gapic/compute_v1/test_region_zones.py | 5 + .../unit/gapic/compute_v1/test_regions.py | 10 + .../gapic/compute_v1/test_reservations.py | 58 + .../compute_v1/test_resource_policies.py | 51 + .../unit/gapic/compute_v1/test_routers.py | 63 + .../unit/gapic/compute_v1/test_routes.py | 33 + .../compute_v1/test_security_policies.py | 74 + .../compute_v1/test_service_attachments.py | 51 + .../test_snapshot_settings_service.py | 12 + .../unit/gapic/compute_v1/test_snapshots.py | 46 + .../gapic/compute_v1/test_ssl_certificates.py | 29 + .../gapic/compute_v1/test_ssl_policies.py | 41 + .../compute_v1/test_storage_pool_types.py | 15 + .../gapic/compute_v1/test_storage_pools.py | 56 + .../unit/gapic/compute_v1/test_subnetworks.py | 70 + .../compute_v1/test_target_grpc_proxies.py | 31 + .../compute_v1/test_target_http_proxies.py | 43 + .../compute_v1/test_target_https_proxies.py | 71 + .../gapic/compute_v1/test_target_instances.py | 36 + .../gapic/compute_v1/test_target_pools.py | 76 + .../compute_v1/test_target_ssl_proxies.py | 59 + .../compute_v1/test_target_tcp_proxies.py | 43 + .../compute_v1/test_target_vpn_gateways.py | 36 + .../unit/gapic/compute_v1/test_url_maps.py | 55 + .../gapic/compute_v1/test_vpn_gateways.py | 46 + .../unit/gapic/compute_v1/test_vpn_tunnels.py | 36 + .../gapic/compute_v1/test_zone_operations.py | 20 + .../tests/unit/gapic/compute_v1/test_zones.py | 10 + 424 files changed, 87259 insertions(+), 13768 deletions(-) create mode 100644 packages/google-cloud-compute/docs/compute_v1/network_profiles.rst create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/__init__.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/client.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/pagers.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/README.rst create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/__init__.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/base.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest.py create mode 100644 packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest_base.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_resume_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_start_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_stop_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_suspend_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_get_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_list_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_resume_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_start_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_stop_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py create mode 100644 packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_security_policies_set_labels_sync.py create mode 100644 packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_profiles.py diff --git a/packages/google-cloud-compute/docs/compute_v1/network_profiles.rst b/packages/google-cloud-compute/docs/compute_v1/network_profiles.rst new file mode 100644 index 000000000000..3a5efd73772b --- /dev/null +++ b/packages/google-cloud-compute/docs/compute_v1/network_profiles.rst @@ -0,0 +1,10 @@ +NetworkProfiles +--------------------------------- + +.. automodule:: google.cloud.compute_v1.services.network_profiles + :members: + :inherited-members: + +.. automodule:: google.cloud.compute_v1.services.network_profiles.pagers + :members: + :inherited-members: diff --git a/packages/google-cloud-compute/docs/compute_v1/services_.rst b/packages/google-cloud-compute/docs/compute_v1/services_.rst index 1b6d820b7b4e..7af4b46084d9 100644 --- a/packages/google-cloud-compute/docs/compute_v1/services_.rst +++ b/packages/google-cloud-compute/docs/compute_v1/services_.rst @@ -42,6 +42,7 @@ Services for Google Cloud Compute v1 API network_edge_security_services network_endpoint_groups network_firewall_policies + network_profiles networks node_groups node_templates diff --git a/packages/google-cloud-compute/google/cloud/compute/__init__.py b/packages/google-cloud-compute/google/cloud/compute/__init__.py index d73b4a051359..406a6ba53398 100644 --- a/packages/google-cloud-compute/google/cloud/compute/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute/__init__.py @@ -105,6 +105,9 @@ from google.cloud.compute_v1.services.network_firewall_policies.client import ( NetworkFirewallPoliciesClient, ) +from google.cloud.compute_v1.services.network_profiles.client import ( + NetworkProfilesClient, +) from google.cloud.compute_v1.services.networks.client import NetworksClient from google.cloud.compute_v1.services.node_groups.client import NodeGroupsClient from google.cloud.compute_v1.services.node_templates.client import NodeTemplatesClient @@ -649,6 +652,7 @@ GetNetworkEdgeSecurityServiceRequest, GetNetworkEndpointGroupRequest, GetNetworkFirewallPolicyRequest, + GetNetworkProfileRequest, GetNetworkRequest, GetNodeGroupRequest, GetNodeTemplateRequest, @@ -868,9 +872,14 @@ InstanceGroupManagersListPerInstanceConfigsResp, InstanceGroupManagersPatchPerInstanceConfigsReq, InstanceGroupManagersRecreateInstancesRequest, + InstanceGroupManagersResumeInstancesRequest, InstanceGroupManagersScopedList, InstanceGroupManagersSetInstanceTemplateRequest, InstanceGroupManagersSetTargetPoolsRequest, + InstanceGroupManagersStartInstancesRequest, + InstanceGroupManagersStopInstancesRequest, + InstanceGroupManagersSuspendInstancesRequest, + InstanceGroupManagerStandbyPolicy, InstanceGroupManagerStatus, InstanceGroupManagerStatusAllInstancesConfig, InstanceGroupManagerStatusStateful, @@ -1010,6 +1019,7 @@ ListNetworkEndpointsNetworkEndpointGroupsRequest, ListNetworkEndpointsRegionNetworkEndpointGroupsRequest, ListNetworkFirewallPoliciesRequest, + ListNetworkProfilesRequest, ListNetworksRequest, ListNodeGroupsRequest, ListNodesNodeGroupsRequest, @@ -1131,6 +1141,10 @@ NetworkList, NetworkPeering, NetworkPerformanceConfig, + NetworkProfile, + NetworkProfileLocation, + NetworkProfileNetworkFeatures, + NetworkProfilesListResponse, NetworkRoutingConfig, NetworksAddPeeringRequest, NetworksGetEffectiveFirewallsResponse, @@ -1282,8 +1296,12 @@ RegionInstanceGroupManagersListInstanceConfigsResp, RegionInstanceGroupManagersListInstancesResponse, RegionInstanceGroupManagersRecreateRequest, + RegionInstanceGroupManagersResumeInstancesRequest, RegionInstanceGroupManagersSetTargetPoolsRequest, RegionInstanceGroupManagersSetTemplateRequest, + RegionInstanceGroupManagersStartInstancesRequest, + RegionInstanceGroupManagersStopInstancesRequest, + RegionInstanceGroupManagersSuspendInstancesRequest, RegionInstanceGroupManagerUpdateInstanceConfigReq, RegionInstanceGroupsListInstances, RegionInstanceGroupsListInstancesRequest, @@ -1348,6 +1366,8 @@ ResourceStatus, ResourceStatusScheduling, ResumeInstanceRequest, + ResumeInstancesInstanceGroupManagerRequest, + ResumeInstancesRegionInstanceGroupManagerRequest, Route, RouteAsPath, RouteList, @@ -1478,6 +1498,7 @@ SetLabelsInterconnectRequest, SetLabelsRegionDiskRequest, SetLabelsRegionInstantSnapshotRequest, + SetLabelsRegionSecurityPolicyRequest, SetLabelsSecurityPolicyRequest, SetLabelsSnapshotRequest, SetLabelsTargetVpnGatewayRequest, @@ -1551,6 +1572,8 @@ StartAsyncReplicationDiskRequest, StartAsyncReplicationRegionDiskRequest, StartInstanceRequest, + StartInstancesInstanceGroupManagerRequest, + StartInstancesRegionInstanceGroupManagerRequest, StartWithEncryptionKeyInstanceRequest, StatefulPolicy, StatefulPolicyPreservedState, @@ -1562,6 +1585,8 @@ StopGroupAsyncReplicationDiskRequest, StopGroupAsyncReplicationRegionDiskRequest, StopInstanceRequest, + StopInstancesInstanceGroupManagerRequest, + StopInstancesRegionInstanceGroupManagerRequest, StoragePool, StoragePoolAggregatedList, StoragePoolDisk, @@ -1583,6 +1608,8 @@ SubnetworksSetPrivateIpGoogleAccessRequest, Subsetting, SuspendInstanceRequest, + SuspendInstancesInstanceGroupManagerRequest, + SuspendInstancesRegionInstanceGroupManagerRequest, SwitchToCustomModeNetworkRequest, Tags, TargetGrpcProxy, @@ -1780,6 +1807,7 @@ "NetworkEdgeSecurityServicesClient", "NetworkEndpointGroupsClient", "NetworkFirewallPoliciesClient", + "NetworkProfilesClient", "NetworksClient", "NodeGroupsClient", "NodeTemplatesClient", @@ -2249,6 +2277,7 @@ "GetNetworkEdgeSecurityServiceRequest", "GetNetworkEndpointGroupRequest", "GetNetworkFirewallPolicyRequest", + "GetNetworkProfileRequest", "GetNetworkRequest", "GetNodeGroupRequest", "GetNodeTemplateRequest", @@ -2468,9 +2497,14 @@ "InstanceGroupManagersListPerInstanceConfigsResp", "InstanceGroupManagersPatchPerInstanceConfigsReq", "InstanceGroupManagersRecreateInstancesRequest", + "InstanceGroupManagersResumeInstancesRequest", "InstanceGroupManagersScopedList", "InstanceGroupManagersSetInstanceTemplateRequest", "InstanceGroupManagersSetTargetPoolsRequest", + "InstanceGroupManagersStartInstancesRequest", + "InstanceGroupManagersStopInstancesRequest", + "InstanceGroupManagersSuspendInstancesRequest", + "InstanceGroupManagerStandbyPolicy", "InstanceGroupManagerStatus", "InstanceGroupManagerStatusAllInstancesConfig", "InstanceGroupManagerStatusStateful", @@ -2610,6 +2644,7 @@ "ListNetworkEndpointsNetworkEndpointGroupsRequest", "ListNetworkEndpointsRegionNetworkEndpointGroupsRequest", "ListNetworkFirewallPoliciesRequest", + "ListNetworkProfilesRequest", "ListNetworksRequest", "ListNodeGroupsRequest", "ListNodesNodeGroupsRequest", @@ -2731,6 +2766,10 @@ "NetworkList", "NetworkPeering", "NetworkPerformanceConfig", + "NetworkProfile", + "NetworkProfileLocation", + "NetworkProfileNetworkFeatures", + "NetworkProfilesListResponse", "NetworkRoutingConfig", "NetworksAddPeeringRequest", "NetworksGetEffectiveFirewallsResponse", @@ -2882,8 +2921,12 @@ "RegionInstanceGroupManagersListInstanceConfigsResp", "RegionInstanceGroupManagersListInstancesResponse", "RegionInstanceGroupManagersRecreateRequest", + "RegionInstanceGroupManagersResumeInstancesRequest", "RegionInstanceGroupManagersSetTargetPoolsRequest", "RegionInstanceGroupManagersSetTemplateRequest", + "RegionInstanceGroupManagersStartInstancesRequest", + "RegionInstanceGroupManagersStopInstancesRequest", + "RegionInstanceGroupManagersSuspendInstancesRequest", "RegionInstanceGroupManagerUpdateInstanceConfigReq", "RegionInstanceGroupsListInstances", "RegionInstanceGroupsListInstancesRequest", @@ -2948,6 +2991,8 @@ "ResourceStatus", "ResourceStatusScheduling", "ResumeInstanceRequest", + "ResumeInstancesInstanceGroupManagerRequest", + "ResumeInstancesRegionInstanceGroupManagerRequest", "Route", "RouteAsPath", "RouteList", @@ -3078,6 +3123,7 @@ "SetLabelsInterconnectRequest", "SetLabelsRegionDiskRequest", "SetLabelsRegionInstantSnapshotRequest", + "SetLabelsRegionSecurityPolicyRequest", "SetLabelsSecurityPolicyRequest", "SetLabelsSnapshotRequest", "SetLabelsTargetVpnGatewayRequest", @@ -3151,6 +3197,8 @@ "StartAsyncReplicationDiskRequest", "StartAsyncReplicationRegionDiskRequest", "StartInstanceRequest", + "StartInstancesInstanceGroupManagerRequest", + "StartInstancesRegionInstanceGroupManagerRequest", "StartWithEncryptionKeyInstanceRequest", "StatefulPolicy", "StatefulPolicyPreservedState", @@ -3162,6 +3210,8 @@ "StopGroupAsyncReplicationDiskRequest", "StopGroupAsyncReplicationRegionDiskRequest", "StopInstanceRequest", + "StopInstancesInstanceGroupManagerRequest", + "StopInstancesRegionInstanceGroupManagerRequest", "StoragePool", "StoragePoolAggregatedList", "StoragePoolDisk", @@ -3183,6 +3233,8 @@ "SubnetworksSetPrivateIpGoogleAccessRequest", "Subsetting", "SuspendInstanceRequest", + "SuspendInstancesInstanceGroupManagerRequest", + "SuspendInstancesRegionInstanceGroupManagerRequest", "SwitchToCustomModeNetworkRequest", "Tags", "TargetGrpcProxy", diff --git a/packages/google-cloud-compute/google/cloud/compute/gapic_version.py b/packages/google-cloud-compute/google/cloud/compute/gapic_version.py index 8b80cf328714..558c8aab67c5 100644 --- a/packages/google-cloud-compute/google/cloud/compute/gapic_version.py +++ b/packages/google-cloud-compute/google/cloud/compute/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.22.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py index 9f611f7657f2..de8581c432cf 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py @@ -61,6 +61,7 @@ from .services.network_edge_security_services import NetworkEdgeSecurityServicesClient from .services.network_endpoint_groups import NetworkEndpointGroupsClient from .services.network_firewall_policies import NetworkFirewallPoliciesClient +from .services.network_profiles import NetworkProfilesClient from .services.networks import NetworksClient from .services.node_groups import NodeGroupsClient from .services.node_templates import NodeTemplatesClient @@ -533,6 +534,7 @@ GetNetworkEdgeSecurityServiceRequest, GetNetworkEndpointGroupRequest, GetNetworkFirewallPolicyRequest, + GetNetworkProfileRequest, GetNetworkRequest, GetNodeGroupRequest, GetNodeTemplateRequest, @@ -752,9 +754,14 @@ InstanceGroupManagersListPerInstanceConfigsResp, InstanceGroupManagersPatchPerInstanceConfigsReq, InstanceGroupManagersRecreateInstancesRequest, + InstanceGroupManagersResumeInstancesRequest, InstanceGroupManagersScopedList, InstanceGroupManagersSetInstanceTemplateRequest, InstanceGroupManagersSetTargetPoolsRequest, + InstanceGroupManagersStartInstancesRequest, + InstanceGroupManagersStopInstancesRequest, + InstanceGroupManagersSuspendInstancesRequest, + InstanceGroupManagerStandbyPolicy, InstanceGroupManagerStatus, InstanceGroupManagerStatusAllInstancesConfig, InstanceGroupManagerStatusStateful, @@ -894,6 +901,7 @@ ListNetworkEndpointsNetworkEndpointGroupsRequest, ListNetworkEndpointsRegionNetworkEndpointGroupsRequest, ListNetworkFirewallPoliciesRequest, + ListNetworkProfilesRequest, ListNetworksRequest, ListNodeGroupsRequest, ListNodesNodeGroupsRequest, @@ -1015,6 +1023,10 @@ NetworkList, NetworkPeering, NetworkPerformanceConfig, + NetworkProfile, + NetworkProfileLocation, + NetworkProfileNetworkFeatures, + NetworkProfilesListResponse, NetworkRoutingConfig, NetworksAddPeeringRequest, NetworksGetEffectiveFirewallsResponse, @@ -1166,8 +1178,12 @@ RegionInstanceGroupManagersListInstanceConfigsResp, RegionInstanceGroupManagersListInstancesResponse, RegionInstanceGroupManagersRecreateRequest, + RegionInstanceGroupManagersResumeInstancesRequest, RegionInstanceGroupManagersSetTargetPoolsRequest, RegionInstanceGroupManagersSetTemplateRequest, + RegionInstanceGroupManagersStartInstancesRequest, + RegionInstanceGroupManagersStopInstancesRequest, + RegionInstanceGroupManagersSuspendInstancesRequest, RegionInstanceGroupManagerUpdateInstanceConfigReq, RegionInstanceGroupsListInstances, RegionInstanceGroupsListInstancesRequest, @@ -1232,6 +1248,8 @@ ResourceStatus, ResourceStatusScheduling, ResumeInstanceRequest, + ResumeInstancesInstanceGroupManagerRequest, + ResumeInstancesRegionInstanceGroupManagerRequest, Route, RouteAsPath, RouteList, @@ -1362,6 +1380,7 @@ SetLabelsInterconnectRequest, SetLabelsRegionDiskRequest, SetLabelsRegionInstantSnapshotRequest, + SetLabelsRegionSecurityPolicyRequest, SetLabelsSecurityPolicyRequest, SetLabelsSnapshotRequest, SetLabelsTargetVpnGatewayRequest, @@ -1435,6 +1454,8 @@ StartAsyncReplicationDiskRequest, StartAsyncReplicationRegionDiskRequest, StartInstanceRequest, + StartInstancesInstanceGroupManagerRequest, + StartInstancesRegionInstanceGroupManagerRequest, StartWithEncryptionKeyInstanceRequest, StatefulPolicy, StatefulPolicyPreservedState, @@ -1446,6 +1467,8 @@ StopGroupAsyncReplicationDiskRequest, StopGroupAsyncReplicationRegionDiskRequest, StopInstanceRequest, + StopInstancesInstanceGroupManagerRequest, + StopInstancesRegionInstanceGroupManagerRequest, StoragePool, StoragePoolAggregatedList, StoragePoolDisk, @@ -1467,6 +1490,8 @@ SubnetworksSetPrivateIpGoogleAccessRequest, Subsetting, SuspendInstanceRequest, + SuspendInstancesInstanceGroupManagerRequest, + SuspendInstancesRegionInstanceGroupManagerRequest, SwitchToCustomModeNetworkRequest, Tags, TargetGrpcProxy, @@ -2047,6 +2072,7 @@ "GetNetworkEdgeSecurityServiceRequest", "GetNetworkEndpointGroupRequest", "GetNetworkFirewallPolicyRequest", + "GetNetworkProfileRequest", "GetNetworkRequest", "GetNodeGroupRequest", "GetNodeTemplateRequest", @@ -2265,6 +2291,7 @@ "InstanceGroupManagerResizeRequestStatusLastAttempt", "InstanceGroupManagerResizeRequestsClient", "InstanceGroupManagerResizeRequestsListResponse", + "InstanceGroupManagerStandbyPolicy", "InstanceGroupManagerStatus", "InstanceGroupManagerStatusAllInstancesConfig", "InstanceGroupManagerStatusStateful", @@ -2283,9 +2310,13 @@ "InstanceGroupManagersListPerInstanceConfigsResp", "InstanceGroupManagersPatchPerInstanceConfigsReq", "InstanceGroupManagersRecreateInstancesRequest", + "InstanceGroupManagersResumeInstancesRequest", "InstanceGroupManagersScopedList", "InstanceGroupManagersSetInstanceTemplateRequest", "InstanceGroupManagersSetTargetPoolsRequest", + "InstanceGroupManagersStartInstancesRequest", + "InstanceGroupManagersStopInstancesRequest", + "InstanceGroupManagersSuspendInstancesRequest", "InstanceGroupManagersUpdatePerInstanceConfigsReq", "InstanceGroupsAddInstancesRequest", "InstanceGroupsClient", @@ -2429,6 +2460,7 @@ "ListNetworkEndpointsNetworkEndpointGroupsRequest", "ListNetworkEndpointsRegionNetworkEndpointGroupsRequest", "ListNetworkFirewallPoliciesRequest", + "ListNetworkProfilesRequest", "ListNetworksRequest", "ListNodeGroupsRequest", "ListNodeTemplatesRequest", @@ -2556,6 +2588,11 @@ "NetworkList", "NetworkPeering", "NetworkPerformanceConfig", + "NetworkProfile", + "NetworkProfileLocation", + "NetworkProfileNetworkFeatures", + "NetworkProfilesClient", + "NetworkProfilesListResponse", "NetworkRoutingConfig", "NetworksAddPeeringRequest", "NetworksClient", @@ -2724,8 +2761,12 @@ "RegionInstanceGroupManagersListInstanceConfigsResp", "RegionInstanceGroupManagersListInstancesResponse", "RegionInstanceGroupManagersRecreateRequest", + "RegionInstanceGroupManagersResumeInstancesRequest", "RegionInstanceGroupManagersSetTargetPoolsRequest", "RegionInstanceGroupManagersSetTemplateRequest", + "RegionInstanceGroupManagersStartInstancesRequest", + "RegionInstanceGroupManagersStopInstancesRequest", + "RegionInstanceGroupManagersSuspendInstancesRequest", "RegionInstanceGroupsClient", "RegionInstanceGroupsListInstances", "RegionInstanceGroupsListInstancesRequest", @@ -2808,6 +2849,8 @@ "ResourceStatus", "ResourceStatusScheduling", "ResumeInstanceRequest", + "ResumeInstancesInstanceGroupManagerRequest", + "ResumeInstancesRegionInstanceGroupManagerRequest", "Route", "RouteAsPath", "RouteList", @@ -2943,6 +2986,7 @@ "SetLabelsInterconnectRequest", "SetLabelsRegionDiskRequest", "SetLabelsRegionInstantSnapshotRequest", + "SetLabelsRegionSecurityPolicyRequest", "SetLabelsSecurityPolicyRequest", "SetLabelsSnapshotRequest", "SetLabelsTargetVpnGatewayRequest", @@ -3019,6 +3063,8 @@ "StartAsyncReplicationDiskRequest", "StartAsyncReplicationRegionDiskRequest", "StartInstanceRequest", + "StartInstancesInstanceGroupManagerRequest", + "StartInstancesRegionInstanceGroupManagerRequest", "StartWithEncryptionKeyInstanceRequest", "StatefulPolicy", "StatefulPolicyPreservedState", @@ -3030,6 +3076,8 @@ "StopGroupAsyncReplicationDiskRequest", "StopGroupAsyncReplicationRegionDiskRequest", "StopInstanceRequest", + "StopInstancesInstanceGroupManagerRequest", + "StopInstancesRegionInstanceGroupManagerRequest", "StoragePool", "StoragePoolAggregatedList", "StoragePoolDisk", @@ -3054,6 +3102,8 @@ "SubnetworksSetPrivateIpGoogleAccessRequest", "Subsetting", "SuspendInstanceRequest", + "SuspendInstancesInstanceGroupManagerRequest", + "SuspendInstancesRegionInstanceGroupManagerRequest", "SwitchToCustomModeNetworkRequest", "TCPHealthCheck", "Tags", diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json index 32af819c89f7..4cc069ff2947 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json +++ b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json @@ -1089,6 +1089,11 @@ "resize" ] }, + "ResumeInstances": { + "methods": [ + "resume_instances" + ] + }, "SetInstanceTemplate": { "methods": [ "set_instance_template" @@ -1099,6 +1104,21 @@ "set_target_pools" ] }, + "StartInstances": { + "methods": [ + "start_instances" + ] + }, + "StopInstances": { + "methods": [ + "stop_instances" + ] + }, + "SuspendInstances": { + "methods": [ + "suspend_instances" + ] + }, "UpdatePerInstanceConfigs": { "methods": [ "update_per_instance_configs" @@ -2026,6 +2046,25 @@ } } }, + "NetworkProfiles": { + "clients": { + "rest": { + "libraryClient": "NetworkProfilesClient", + "rpcs": { + "Get": { + "methods": [ + "get" + ] + }, + "List": { + "methods": [ + "list" + ] + } + } + } + } + }, "Networks": { "clients": { "rest": { @@ -2876,6 +2915,11 @@ "resize" ] }, + "ResumeInstances": { + "methods": [ + "resume_instances" + ] + }, "SetInstanceTemplate": { "methods": [ "set_instance_template" @@ -2886,6 +2930,21 @@ "set_target_pools" ] }, + "StartInstances": { + "methods": [ + "start_instances" + ] + }, + "StopInstances": { + "methods": [ + "stop_instances" + ] + }, + "SuspendInstances": { + "methods": [ + "suspend_instances" + ] + }, "UpdatePerInstanceConfigs": { "methods": [ "update_per_instance_configs" @@ -3261,6 +3320,11 @@ "methods": [ "remove_rule" ] + }, + "SetLabels": { + "methods": [ + "set_labels" + ] } } } diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py index 8b80cf328714..558c8aab67c5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.22.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/client.py index edb5e25be0a4..ac106837c853 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/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.compute_v1.services.accelerator_types import pagers from google.cloud.compute_v1.types import compute @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.AcceleratorTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "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.compute.v1.AcceleratorTypes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -635,7 +672,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of accelerator types. To prevent failure, Google recommends that you set the @@ -681,8 +718,10 @@ def sample_aggregated_list(): 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.compute_v1.services.accelerator_types.pagers.AggregatedListPager: @@ -754,7 +793,7 @@ def get( accelerator_type: 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]]] = (), ) -> compute.AcceleratorType: r"""Returns the specified accelerator type. @@ -813,8 +852,10 @@ def sample_get(): 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.compute_v1.types.AcceleratorType: @@ -889,7 +930,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of accelerator types that are available to the specified project. @@ -942,8 +983,10 @@ def sample_list(): 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.compute_v1.services.accelerator_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/pagers.py index 1a568ecb509a..f4de37465c69 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/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 = compute.AggregatedListAcceleratorTypesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListAcceleratorTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/transports/rest.py index 4ee578f83d39..f693a068f350 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/accelerator_types/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 @@ -37,6 +37,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, @@ -93,9 +101,10 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListAcceleratorTypesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListAcceleratorTypesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListAcceleratorTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -118,8 +127,10 @@ def post_aggregated_list( def pre_get( self, request: compute.GetAcceleratorTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetAcceleratorTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetAcceleratorTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -139,8 +150,10 @@ def post_get(self, response: compute.AcceleratorType) -> compute.AcceleratorType def pre_list( self, request: compute.ListAcceleratorTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListAcceleratorTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListAcceleratorTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -286,7 +299,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]]] = (), ) -> compute.AcceleratorTypeAggregatedList: r"""Call the aggregated list method over HTTP. @@ -298,8 +311,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: ~.compute.AcceleratorTypeAggregatedList: @@ -309,6 +324,7 @@ def __call__( http_options = ( _BaseAcceleratorTypesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseAcceleratorTypesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -319,6 +335,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 = 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.compute_v1.AcceleratorTypesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AcceleratorTypesRestTransport._AggregatedList._get_response( self._host, @@ -339,7 +382,31 @@ def __call__( pb_resp = compute.AcceleratorTypeAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AcceleratorTypeAggregatedList.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.compute_v1.AcceleratorTypesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseAcceleratorTypesRestTransport._BaseGet, AcceleratorTypesRestStub): @@ -374,7 +441,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]]] = (), ) -> compute.AcceleratorType: r"""Call the get method over HTTP. @@ -386,8 +453,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: ~.compute.AcceleratorType: @@ -405,6 +474,7 @@ def __call__( http_options = ( _BaseAcceleratorTypesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseAcceleratorTypesRestTransport._BaseGet._get_transcoded_request( @@ -419,6 +489,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.compute_v1.AcceleratorTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AcceleratorTypesRestTransport._Get._get_response( self._host, @@ -439,7 +536,29 @@ def __call__( pb_resp = compute.AcceleratorType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AcceleratorType.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.compute_v1.AcceleratorTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseAcceleratorTypesRestTransport._BaseList, AcceleratorTypesRestStub): @@ -474,7 +593,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]]] = (), ) -> compute.AcceleratorTypeList: r"""Call the list method over HTTP. @@ -486,8 +605,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: ~.compute.AcceleratorTypeList: @@ -497,6 +618,7 @@ def __call__( http_options = ( _BaseAcceleratorTypesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseAcceleratorTypesRestTransport._BaseList._get_transcoded_request( @@ -511,6 +633,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.compute_v1.AcceleratorTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AcceleratorTypesRestTransport._List._get_response( self._host, @@ -531,7 +680,29 @@ def __call__( pb_resp = compute.AcceleratorTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AcceleratorTypeList.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.compute_v1.AcceleratorTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.AcceleratorTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/client.py index ecdf130ba5ba..d3d71b3a0315 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.addresses import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.AddressesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "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.compute.v1.Addresses", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListAddressesRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of addresses. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.addresses.pagers.AggregatedListPager: @@ -744,7 +783,7 @@ def delete_unary( address: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified address resource. @@ -801,8 +840,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -872,7 +913,7 @@ def delete( address: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified address resource. @@ -929,8 +970,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1025,7 +1068,7 @@ def get( address: 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]]] = (), ) -> compute.Address: r"""Returns the specified address resource. @@ -1081,8 +1124,10 @@ def sample_get(): 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.compute_v1.types.Address: @@ -1157,7 +1202,7 @@ def insert_unary( address_resource: Optional[compute.Address] = 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]]] = (), ) -> compute.Operation: r"""Creates an address resource in the specified project by using the data included in the request. @@ -1212,8 +1257,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1282,7 +1329,7 @@ def insert( address_resource: Optional[compute.Address] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an address resource in the specified project by using the data included in the request. @@ -1337,8 +1384,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1431,7 +1480,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of addresses contained within the specified region. @@ -1481,8 +1530,10 @@ def sample_list(): 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.compute_v1.services.addresses.pagers.ListPager: @@ -1566,7 +1617,7 @@ def move_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Moves the specified address resource. @@ -1627,8 +1678,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -1707,7 +1760,7 @@ def move( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Moves the specified address resource. @@ -1768,8 +1821,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -1873,7 +1928,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. @@ -1936,8 +1991,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2016,7 +2073,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. @@ -2079,8 +2136,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/pagers.py index 4d54706e7faf..f047fd864f03 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/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 = compute.AggregatedListAddressesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListAddressesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/transports/rest.py index b7d59f7f5344..88cc27b706b7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/addresses/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 @@ -37,6 +37,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, @@ -125,8 +133,10 @@ def post_set_labels(self, response): def pre_aggregated_list( self, request: compute.AggregatedListAddressesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListAddressesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListAddressesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -146,8 +156,10 @@ def post_aggregated_list( return response def pre_delete( - self, request: compute.DeleteAddressRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteAddressRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteAddressRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteAddressRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -165,8 +177,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetAddressRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetAddressRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetAddressRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetAddressRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -184,8 +198,10 @@ def post_get(self, response: compute.Address) -> compute.Address: return response def pre_insert( - self, request: compute.InsertAddressRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertAddressRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertAddressRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertAddressRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -203,8 +219,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListAddressesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListAddressesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListAddressesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListAddressesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -222,8 +240,10 @@ def post_list(self, response: compute.AddressList) -> compute.AddressList: return response def pre_move( - self, request: compute.MoveAddressRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.MoveAddressRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.MoveAddressRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.MoveAddressRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for move Override in a subclass to manipulate the request or metadata @@ -243,8 +263,10 @@ def post_move(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -386,7 +408,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]]] = (), ) -> compute.AddressAggregatedList: r"""Call the aggregated list method over HTTP. @@ -398,8 +420,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: ~.compute.AddressAggregatedList: @@ -409,6 +433,7 @@ def __call__( http_options = ( _BaseAddressesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseAggregatedList._get_transcoded_request( @@ -423,6 +448,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.compute_v1.AddressesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._AggregatedList._get_response( self._host, @@ -443,7 +495,29 @@ def __call__( pb_resp = compute.AddressAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AddressAggregatedList.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.compute_v1.AddressesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseAddressesRestTransport._BaseDelete, AddressesRestStub): @@ -478,7 +552,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -490,8 +564,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: ~.compute.Operation: @@ -516,6 +592,7 @@ def __call__( """ http_options = _BaseAddressesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseDelete._get_transcoded_request( @@ -530,6 +607,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.compute_v1.AddressesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._Delete._get_response( self._host, @@ -550,7 +654,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AddressesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseAddressesRestTransport._BaseGet, AddressesRestStub): @@ -585,7 +711,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]]] = (), ) -> compute.Address: r"""Call the get method over HTTP. @@ -596,8 +722,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: ~.compute.Address: @@ -612,6 +740,7 @@ def __call__( """ http_options = _BaseAddressesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseGet._get_transcoded_request( @@ -624,6 +753,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 = 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.compute_v1.AddressesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._Get._get_response( self._host, @@ -644,7 +800,29 @@ def __call__( pb_resp = compute.Address.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Address.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.compute_v1.AddressesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseAddressesRestTransport._BaseInsert, AddressesRestStub): @@ -680,7 +858,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -692,8 +870,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: ~.compute.Operation: @@ -718,6 +898,7 @@ def __call__( """ http_options = _BaseAddressesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseInsert._get_transcoded_request( @@ -736,6 +917,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.compute_v1.AddressesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._Insert._get_response( self._host, @@ -757,7 +965,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AddressesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseAddressesRestTransport._BaseList, AddressesRestStub): @@ -792,7 +1022,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]]] = (), ) -> compute.AddressList: r"""Call the list method over HTTP. @@ -803,8 +1033,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: ~.compute.AddressList: @@ -812,6 +1044,7 @@ def __call__( """ http_options = _BaseAddressesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseList._get_transcoded_request( @@ -824,6 +1057,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 = 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.compute_v1.AddressesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._List._get_response( self._host, @@ -844,7 +1104,29 @@ def __call__( pb_resp = compute.AddressList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AddressList.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.compute_v1.AddressesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Move(_BaseAddressesRestTransport._BaseMove, AddressesRestStub): @@ -880,7 +1162,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]]] = (), ) -> compute.Operation: r"""Call the move method over HTTP. @@ -891,8 +1173,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: ~.compute.Operation: @@ -917,6 +1201,7 @@ def __call__( """ http_options = _BaseAddressesRestTransport._BaseMove._get_http_options() + request, metadata = self._interceptor.pre_move(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseMove._get_transcoded_request( @@ -933,6 +1218,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 = 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.compute_v1.AddressesClient.Move", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Move", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._Move._get_response( self._host, @@ -954,7 +1266,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AddressesClient.move", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "Move", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseAddressesRestTransport._BaseSetLabels, AddressesRestStub): @@ -990,7 +1324,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1002,8 +1336,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: ~.compute.Operation: @@ -1030,6 +1366,7 @@ def __call__( http_options = ( _BaseAddressesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseAddressesRestTransport._BaseSetLabels._get_transcoded_request( @@ -1048,6 +1385,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.compute_v1.AddressesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AddressesRestTransport._SetLabels._get_response( self._host, @@ -1069,7 +1433,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AddressesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Addresses", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/client.py index d0584d2f6f64..c25341b16d1c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.autoscalers import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.AutoscalersClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "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.compute.v1.Autoscalers", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListAutoscalersRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of autoscalers. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.autoscalers.pagers.AggregatedListPager: @@ -744,7 +783,7 @@ def delete_unary( autoscaler: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified autoscaler. @@ -799,8 +838,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -870,7 +911,7 @@ def delete( autoscaler: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified autoscaler. @@ -925,8 +966,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1021,7 +1064,7 @@ def get( autoscaler: 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]]] = (), ) -> compute.Autoscaler: r"""Returns the specified autoscaler resource. @@ -1076,8 +1119,10 @@ def sample_get(): 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.compute_v1.types.Autoscaler: @@ -1156,7 +1201,7 @@ def insert_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Creates an autoscaler in the specified project using the data included in the request. @@ -1211,8 +1256,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1281,7 +1328,7 @@ def insert( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an autoscaler in the specified project using the data included in the request. @@ -1336,8 +1383,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1430,7 +1479,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of autoscalers contained within the specified zone. @@ -1481,8 +1530,10 @@ def sample_list(): 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.compute_v1.services.autoscalers.pagers.ListPager: @@ -1563,7 +1614,7 @@ def patch_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Updates an autoscaler in the specified project using the data included in the request. This method supports @@ -1620,8 +1671,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1690,7 +1743,7 @@ def patch( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an autoscaler in the specified project using the data included in the request. This method supports @@ -1747,8 +1800,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1842,7 +1897,7 @@ def update_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Updates an autoscaler in the specified project using the data included in the request. @@ -1897,8 +1952,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1967,7 +2024,7 @@ def update( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an autoscaler in the specified project using the data included in the request. @@ -2022,8 +2079,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/pagers.py index 2cf717d38943..1ae68be4a3f8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/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 = compute.AggregatedListAutoscalersRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListAutoscalersRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/transports/rest.py index 951fb87a6cba..932152c9df4b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/autoscalers/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 @@ -37,6 +37,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, @@ -125,8 +133,11 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListAutoscalersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListAutoscalersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListAutoscalersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -148,8 +159,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -167,8 +180,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetAutoscalerRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetAutoscalerRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetAutoscalerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -188,8 +203,10 @@ def post_get(self, response: compute.Autoscaler) -> compute.Autoscaler: def pre_insert( self, request: compute.InsertAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -209,8 +226,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListAutoscalersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListAutoscalersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListAutoscalersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -230,8 +247,8 @@ def post_list(self, response: compute.AutoscalerList) -> compute.AutoscalerList: def pre_patch( self, request: compute.PatchAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -251,8 +268,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -394,7 +413,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]]] = (), ) -> compute.AutoscalerAggregatedList: r"""Call the aggregated list method over HTTP. @@ -406,8 +425,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: ~.compute.AutoscalerAggregatedList: @@ -417,6 +438,7 @@ def __call__( http_options = ( _BaseAutoscalersRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseAutoscalersRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -427,6 +449,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 = 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.compute_v1.AutoscalersClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._AggregatedList._get_response( self._host, @@ -447,7 +496,31 @@ def __call__( pb_resp = compute.AutoscalerAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AutoscalerAggregatedList.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.compute_v1.AutoscalersClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseAutoscalersRestTransport._BaseDelete, AutoscalersRestStub): @@ -482,7 +555,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -494,8 +567,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: ~.compute.Operation: @@ -520,6 +595,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BaseDelete._get_transcoded_request( @@ -534,6 +610,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.compute_v1.AutoscalersClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._Delete._get_response( self._host, @@ -554,7 +657,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AutoscalersClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseAutoscalersRestTransport._BaseGet, AutoscalersRestStub): @@ -589,7 +714,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]]] = (), ) -> compute.Autoscaler: r"""Call the get method over HTTP. @@ -601,8 +726,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: ~.compute.Autoscaler: @@ -622,6 +749,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BaseGet._get_transcoded_request( @@ -636,6 +764,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.compute_v1.AutoscalersClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._Get._get_response( self._host, @@ -656,7 +811,29 @@ def __call__( pb_resp = compute.Autoscaler.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Autoscaler.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.compute_v1.AutoscalersClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseAutoscalersRestTransport._BaseInsert, AutoscalersRestStub): @@ -692,7 +869,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -704,8 +881,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: ~.compute.Operation: @@ -730,6 +909,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BaseInsert._get_transcoded_request( @@ -748,6 +928,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.compute_v1.AutoscalersClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._Insert._get_response( self._host, @@ -769,7 +976,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AutoscalersClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseAutoscalersRestTransport._BaseList, AutoscalersRestStub): @@ -804,7 +1033,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]]] = (), ) -> compute.AutoscalerList: r"""Call the list method over HTTP. @@ -816,8 +1045,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: ~.compute.AutoscalerList: @@ -827,6 +1058,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BaseList._get_transcoded_request( @@ -841,6 +1073,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.compute_v1.AutoscalersClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._List._get_response( self._host, @@ -861,7 +1120,29 @@ def __call__( pb_resp = compute.AutoscalerList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AutoscalerList.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.compute_v1.AutoscalersClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseAutoscalersRestTransport._BasePatch, AutoscalersRestStub): @@ -897,7 +1178,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -909,8 +1190,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: ~.compute.Operation: @@ -935,6 +1218,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BasePatch._get_transcoded_request( @@ -953,6 +1237,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.compute_v1.AutoscalersClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._Patch._get_response( self._host, @@ -974,7 +1285,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AutoscalersClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseAutoscalersRestTransport._BaseUpdate, AutoscalersRestStub): @@ -1010,7 +1343,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1022,8 +1355,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: ~.compute.Operation: @@ -1048,6 +1383,7 @@ def __call__( """ http_options = _BaseAutoscalersRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseAutoscalersRestTransport._BaseUpdate._get_transcoded_request( @@ -1066,6 +1402,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.compute_v1.AutoscalersClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoscalersRestTransport._Update._get_response( self._host, @@ -1087,7 +1450,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.AutoscalersClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Autoscalers", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/client.py index af49015555ad..9a8da0fe724f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.backend_buckets import pagers @@ -558,6 +568,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( @@ -623,6 +637,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.compute_v1.BackendBucketsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "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.compute.v1.BackendBuckets", + "credentialsType": None, + }, + ) + def add_signed_url_key_unary( self, request: Optional[ @@ -634,7 +671,7 @@ def add_signed_url_key_unary( signed_url_key_resource: Optional[compute.SignedUrlKey] = 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]]] = (), ) -> compute.Operation: r"""Adds a key for validating requests with signed URLs for this backend bucket. @@ -693,8 +730,10 @@ def sample_add_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -765,7 +804,7 @@ def add_signed_url_key( signed_url_key_resource: Optional[compute.SignedUrlKey] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds a key for validating requests with signed URLs for this backend bucket. @@ -824,8 +863,10 @@ def sample_add_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -917,7 +958,7 @@ def delete_unary( backend_bucket: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified BackendBucket resource. @@ -968,8 +1009,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1035,7 +1078,7 @@ def delete( backend_bucket: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified BackendBucket resource. @@ -1086,8 +1129,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1180,7 +1225,7 @@ def delete_signed_url_key_unary( key_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]]] = (), ) -> compute.Operation: r"""Deletes a key for validating requests with signed URLs for this backend bucket. @@ -1242,8 +1287,10 @@ def sample_delete_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -1314,7 +1361,7 @@ def delete_signed_url_key( key_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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a key for validating requests with signed URLs for this backend bucket. @@ -1376,8 +1423,10 @@ def sample_delete_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -1469,7 +1518,7 @@ def get( backend_bucket: 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]]] = (), ) -> compute.BackendBucket: r"""Returns the specified BackendBucket resource. @@ -1520,8 +1569,10 @@ def sample_get(): 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.compute_v1.types.BackendBucket: @@ -1590,7 +1641,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1642,8 +1693,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.cloud.compute_v1.types.Policy: @@ -1729,7 +1782,7 @@ def insert_unary( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> compute.Operation: r"""Creates a BackendBucket resource in the specified project using the data included in the request. @@ -1778,8 +1831,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1840,7 +1895,7 @@ def insert( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a BackendBucket resource in the specified project using the data included in the request. @@ -1889,8 +1944,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1974,7 +2031,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of BackendBucket resources available to the specified project. @@ -2019,8 +2076,10 @@ def sample_list(): 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.compute_v1.services.backend_buckets.pagers.ListPager: @@ -2094,7 +2153,7 @@ def patch_unary( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH @@ -2153,8 +2212,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2223,7 +2284,7 @@ def patch( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH @@ -2282,8 +2343,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2380,7 +2443,7 @@ def set_edge_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the edge security policy for the specified backend bucket. @@ -2438,8 +2501,10 @@ def sample_set_edge_security_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.api_core.extended_operation.ExtendedOperation: @@ -2516,7 +2581,7 @@ def set_edge_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the edge security policy for the specified backend bucket. @@ -2574,8 +2639,10 @@ def sample_set_edge_security_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.api_core.extended_operation.ExtendedOperation: @@ -2674,7 +2741,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2731,8 +2798,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.cloud.compute_v1.types.Policy: @@ -2829,7 +2898,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2886,8 +2955,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -2958,7 +3029,7 @@ def update_unary( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified BackendBucket resource with the data included in the request. @@ -3015,8 +3086,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -3085,7 +3158,7 @@ def update( backend_bucket_resource: Optional[compute.BackendBucket] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified BackendBucket resource with the data included in the request. @@ -3142,8 +3215,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/pagers.py index 68a4fec7f36f..b41636e5dbd6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/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 = compute.ListBackendBucketsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/transports/rest.py index 9767011f1ef3..99593985513e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_buckets/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 @@ -37,6 +37,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, @@ -165,8 +173,11 @@ def post_update(self, response): def pre_add_signed_url_key( self, request: compute.AddSignedUrlKeyBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddSignedUrlKeyBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddSignedUrlKeyBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_signed_url_key Override in a subclass to manipulate the request or metadata @@ -186,8 +197,10 @@ def post_add_signed_url_key(self, response: compute.Operation) -> compute.Operat def pre_delete( self, request: compute.DeleteBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteBackendBucketRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -207,9 +220,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_signed_url_key( self, request: compute.DeleteSignedUrlKeyBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteSignedUrlKeyBackendBucketRequest, Sequence[Tuple[str, str]] + compute.DeleteSignedUrlKeyBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_signed_url_key @@ -232,8 +246,10 @@ def post_delete_signed_url_key( def pre_get( self, request: compute.GetBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetBackendBucketRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -253,8 +269,11 @@ def post_get(self, response: compute.BackendBucket) -> compute.BackendBucket: def pre_get_iam_policy( self, request: compute.GetIamPolicyBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -274,8 +293,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertBackendBucketRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -295,8 +316,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListBackendBucketsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListBackendBucketsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListBackendBucketsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -318,8 +341,10 @@ def post_list( def pre_patch( self, request: compute.PatchBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchBackendBucketRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -339,9 +364,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_edge_security_policy( self, request: compute.SetEdgeSecurityPolicyBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetEdgeSecurityPolicyBackendBucketRequest, Sequence[Tuple[str, str]] + compute.SetEdgeSecurityPolicyBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_edge_security_policy @@ -364,8 +390,11 @@ def post_set_edge_security_policy( def pre_set_iam_policy( self, request: compute.SetIamPolicyBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -385,9 +414,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsBackendBucketRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsBackendBucketRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -410,8 +440,10 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateBackendBucketRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateBackendBucketRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateBackendBucketRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -554,7 +586,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]]] = (), ) -> compute.Operation: r"""Call the add signed url key method over HTTP. @@ -566,8 +598,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: ~.compute.Operation: @@ -594,6 +628,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseAddSignedUrlKey._get_http_options() ) + request, metadata = self._interceptor.pre_add_signed_url_key( request, metadata ) @@ -610,6 +645,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 = 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.compute_v1.BackendBucketsClient.AddSignedUrlKey", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "AddSignedUrlKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._AddSignedUrlKey._get_response( self._host, @@ -631,7 +693,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_signed_url_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.add_signed_url_key", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "AddSignedUrlKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseBackendBucketsRestTransport._BaseDelete, BackendBucketsRestStub): @@ -666,7 +750,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -678,8 +762,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: ~.compute.Operation: @@ -706,6 +792,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BaseDelete._get_transcoded_request( @@ -720,6 +807,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.compute_v1.BackendBucketsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._Delete._get_response( self._host, @@ -740,7 +854,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSignedUrlKey( @@ -777,7 +913,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]]] = (), ) -> compute.Operation: r"""Call the delete signed url key method over HTTP. @@ -789,8 +925,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: ~.compute.Operation: @@ -817,6 +955,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseDeleteSignedUrlKey._get_http_options() ) + request, metadata = self._interceptor.pre_delete_signed_url_key( request, metadata ) @@ -829,6 +968,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 = 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.compute_v1.BackendBucketsClient.DeleteSignedUrlKey", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "DeleteSignedUrlKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._DeleteSignedUrlKey._get_response( self._host, @@ -849,7 +1015,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_signed_url_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.delete_signed_url_key", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "DeleteSignedUrlKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseBackendBucketsRestTransport._BaseGet, BackendBucketsRestStub): @@ -884,7 +1072,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]]] = (), ) -> compute.BackendBucket: r"""Call the get method over HTTP. @@ -896,8 +1084,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: ~.compute.BackendBucket: @@ -910,6 +1100,7 @@ def __call__( """ http_options = _BaseBackendBucketsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BaseGet._get_transcoded_request( @@ -924,6 +1115,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.compute_v1.BackendBucketsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._Get._get_response( self._host, @@ -944,7 +1162,29 @@ def __call__( pb_resp = compute.BackendBucket.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendBucket.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.compute_v1.BackendBucketsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -981,7 +1221,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -993,8 +1233,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: ~.compute.Policy: @@ -1027,6 +1269,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseBackendBucketsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1037,6 +1280,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 = 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.compute_v1.BackendBucketsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._GetIamPolicy._get_response( self._host, @@ -1057,7 +1327,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.BackendBucketsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseBackendBucketsRestTransport._BaseInsert, BackendBucketsRestStub): @@ -1093,7 +1385,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1105,8 +1397,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: ~.compute.Operation: @@ -1133,6 +1427,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BaseInsert._get_transcoded_request( @@ -1151,6 +1446,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.compute_v1.BackendBucketsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._Insert._get_response( self._host, @@ -1172,7 +1494,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseBackendBucketsRestTransport._BaseList, BackendBucketsRestStub): @@ -1207,7 +1551,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]]] = (), ) -> compute.BackendBucketList: r"""Call the list method over HTTP. @@ -1219,8 +1563,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: ~.compute.BackendBucketList: @@ -1232,6 +1578,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BaseList._get_transcoded_request( @@ -1246,6 +1593,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.compute_v1.BackendBucketsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._List._get_response( self._host, @@ -1266,7 +1640,29 @@ def __call__( pb_resp = compute.BackendBucketList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendBucketList.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.compute_v1.BackendBucketsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseBackendBucketsRestTransport._BasePatch, BackendBucketsRestStub): @@ -1302,7 +1698,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1314,8 +1710,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: ~.compute.Operation: @@ -1342,6 +1740,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BasePatch._get_transcoded_request( @@ -1360,6 +1759,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.compute_v1.BackendBucketsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._Patch._get_response( self._host, @@ -1381,7 +1807,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetEdgeSecurityPolicy( @@ -1420,7 +1868,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]]] = (), ) -> compute.Operation: r"""Call the set edge security policy method over HTTP. @@ -1432,8 +1880,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: ~.compute.Operation: @@ -1460,6 +1910,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseSetEdgeSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_edge_security_policy( request, metadata ) @@ -1476,6 +1927,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 = 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.compute_v1.BackendBucketsClient.SetEdgeSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "SetEdgeSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._SetEdgeSecurityPolicy._get_response( self._host, @@ -1497,7 +1975,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_edge_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.set_edge_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "SetEdgeSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1535,7 +2035,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1547,8 +2047,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: ~.compute.Policy: @@ -1581,6 +2083,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseBackendBucketsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1595,6 +2098,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 = 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.compute_v1.BackendBucketsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._SetIamPolicy._get_response( self._host, @@ -1616,7 +2146,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.BackendBucketsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1654,7 +2206,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1666,8 +2218,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: ~.compute.TestPermissionsResponse: @@ -1677,6 +2231,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1693,6 +2248,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 = 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.compute_v1.BackendBucketsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._TestIamPermissions._get_response( self._host, @@ -1714,7 +2296,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.BackendBucketsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseBackendBucketsRestTransport._BaseUpdate, BackendBucketsRestStub): @@ -1750,7 +2354,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1762,8 +2366,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: ~.compute.Operation: @@ -1790,6 +2396,7 @@ def __call__( http_options = ( _BaseBackendBucketsRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseBackendBucketsRestTransport._BaseUpdate._get_transcoded_request( @@ -1808,6 +2415,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.compute_v1.BackendBucketsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendBucketsRestTransport._Update._get_response( self._host, @@ -1829,7 +2463,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendBucketsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.BackendBuckets", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/client.py index 3768d6154768..893247fe95e3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.backend_services import pagers @@ -560,6 +570,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( @@ -625,6 +639,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.compute_v1.BackendServicesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "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.compute.v1.BackendServices", + "credentialsType": None, + }, + ) + def add_signed_url_key_unary( self, request: Optional[ @@ -636,7 +673,7 @@ def add_signed_url_key_unary( signed_url_key_resource: Optional[compute.SignedUrlKey] = 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]]] = (), ) -> compute.Operation: r"""Adds a key for validating requests with signed URLs for this backend service. @@ -695,8 +732,10 @@ def sample_add_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -767,7 +806,7 @@ def add_signed_url_key( signed_url_key_resource: Optional[compute.SignedUrlKey] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds a key for validating requests with signed URLs for this backend service. @@ -826,8 +865,10 @@ def sample_add_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -920,7 +961,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all BackendService resources, regional and global, available to the specified project. To prevent failure, @@ -969,8 +1010,10 @@ def sample_aggregated_list(): 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.compute_v1.services.backend_services.pagers.AggregatedListPager: @@ -1043,7 +1086,7 @@ def delete_unary( backend_service: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified BackendService resource. @@ -1094,8 +1137,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1161,7 +1206,7 @@ def delete( backend_service: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified BackendService resource. @@ -1212,8 +1257,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1306,7 +1353,7 @@ def delete_signed_url_key_unary( key_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]]] = (), ) -> compute.Operation: r"""Deletes a key for validating requests with signed URLs for this backend service. @@ -1368,8 +1415,10 @@ def sample_delete_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -1440,7 +1489,7 @@ def delete_signed_url_key( key_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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a key for validating requests with signed URLs for this backend service. @@ -1502,8 +1551,10 @@ def sample_delete_signed_url_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -1595,7 +1646,7 @@ def get( backend_service: 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]]] = (), ) -> compute.BackendService: r"""Returns the specified BackendService resource. @@ -1646,8 +1697,10 @@ def sample_get(): 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.compute_v1.types.BackendService: @@ -1729,7 +1782,7 @@ def get_health( ] = 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]]] = (), ) -> compute.BackendServiceGroupHealth: r"""Gets the most recent health check results for this BackendService. Example request body: { "group": @@ -1787,8 +1840,10 @@ def sample_get_health(): 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.compute_v1.types.BackendServiceGroupHealth: @@ -1860,7 +1915,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1912,8 +1967,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.cloud.compute_v1.types.Policy: @@ -1999,7 +2056,7 @@ def insert_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Creates a BackendService resource in the specified project using the data included in the request. For more @@ -2049,8 +2106,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2111,7 +2170,7 @@ def insert( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a BackendService resource in the specified project using the data included in the request. For more @@ -2161,8 +2220,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2246,7 +2307,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of BackendService resources available to the specified project. @@ -2291,8 +2352,10 @@ def sample_list(): 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.compute_v1.services.backend_services.pagers.ListPager: @@ -2364,7 +2427,7 @@ def list_usable( project: 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.ListUsablePager: r"""Retrieves a list of all usable backend services in the specified project. @@ -2409,8 +2472,10 @@ def sample_list_usable(): 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.compute_v1.services.backend_services.pagers.ListUsablePager: @@ -2484,7 +2549,7 @@ def patch_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified BackendService resource with the data included in the request. For more information, @@ -2544,8 +2609,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2614,7 +2681,7 @@ def patch( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified BackendService resource with the data included in the request. For more information, @@ -2674,8 +2741,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2772,7 +2841,7 @@ def set_edge_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the edge security policy for the specified backend service. @@ -2831,8 +2900,10 @@ def sample_set_edge_security_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.api_core.extended_operation.ExtendedOperation: @@ -2909,7 +2980,7 @@ def set_edge_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the edge security policy for the specified backend service. @@ -2968,8 +3039,10 @@ def sample_set_edge_security_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.api_core.extended_operation.ExtendedOperation: @@ -3070,7 +3143,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3127,8 +3200,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.cloud.compute_v1.types.Policy: @@ -3225,7 +3300,7 @@ def set_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Google Cloud Armor security policy for the specified backend service. For more information, see @@ -3284,8 +3359,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -3362,7 +3439,7 @@ def set_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Google Cloud Armor security policy for the specified backend service. For more information, see @@ -3421,8 +3498,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -3523,7 +3602,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -3580,8 +3659,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -3652,7 +3733,7 @@ def update_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified BackendService resource with the data included in the request. For more information, @@ -3710,8 +3791,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -3780,7 +3863,7 @@ def update( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified BackendService resource with the data included in the request. For more information, @@ -3838,8 +3921,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/pagers.py index 8e8e637f18f3..deea2abee36f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/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 = compute.AggregatedListBackendServicesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListBackendServicesRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListUsableBackendServicesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/transports/rest.py index 2d415a8ce157..6ea2df45b005 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/backend_services/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 @@ -37,6 +37,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,11 @@ def post_update(self, response): def pre_add_signed_url_key( self, request: compute.AddSignedUrlKeyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddSignedUrlKeyBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddSignedUrlKeyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_signed_url_key Override in a subclass to manipulate the request or metadata @@ -218,8 +229,11 @@ def post_add_signed_url_key(self, response: compute.Operation) -> compute.Operat def pre_aggregated_list( self, request: compute.AggregatedListBackendServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListBackendServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListBackendServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -241,8 +255,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -262,9 +278,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_signed_url_key( self, request: compute.DeleteSignedUrlKeyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteSignedUrlKeyBackendServiceRequest, Sequence[Tuple[str, str]] + compute.DeleteSignedUrlKeyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_signed_url_key @@ -287,8 +304,10 @@ def post_delete_signed_url_key( def pre_get( self, request: compute.GetBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -308,8 +327,10 @@ def post_get(self, response: compute.BackendService) -> compute.BackendService: def pre_get_health( self, request: compute.GetHealthBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetHealthBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetHealthBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_health Override in a subclass to manipulate the request or metadata @@ -331,8 +352,11 @@ def post_get_health( def pre_get_iam_policy( self, request: compute.GetIamPolicyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -352,8 +376,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -373,8 +399,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListBackendServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListBackendServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListBackendServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -396,8 +424,11 @@ def post_list( def pre_list_usable( self, request: compute.ListUsableBackendServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListUsableBackendServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListUsableBackendServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_usable Override in a subclass to manipulate the request or metadata @@ -419,8 +450,10 @@ def post_list_usable( def pre_patch( self, request: compute.PatchBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -440,9 +473,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_edge_security_policy( self, request: compute.SetEdgeSecurityPolicyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetEdgeSecurityPolicyBackendServiceRequest, Sequence[Tuple[str, str]] + compute.SetEdgeSecurityPolicyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_edge_security_policy @@ -465,8 +499,11 @@ def post_set_edge_security_policy( def pre_set_iam_policy( self, request: compute.SetIamPolicyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -486,9 +523,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_security_policy( self, request: compute.SetSecurityPolicyBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetSecurityPolicyBackendServiceRequest, Sequence[Tuple[str, str]] + compute.SetSecurityPolicyBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_security_policy @@ -511,9 +549,10 @@ def post_set_security_policy( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsBackendServiceRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -536,8 +575,10 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -680,7 +721,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]]] = (), ) -> compute.Operation: r"""Call the add signed url key method over HTTP. @@ -692,8 +733,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: ~.compute.Operation: @@ -720,6 +763,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseAddSignedUrlKey._get_http_options() ) + request, metadata = self._interceptor.pre_add_signed_url_key( request, metadata ) @@ -736,6 +780,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 = 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.compute_v1.BackendServicesClient.AddSignedUrlKey", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "AddSignedUrlKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._AddSignedUrlKey._get_response( self._host, @@ -757,7 +828,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_signed_url_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.add_signed_url_key", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "AddSignedUrlKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -794,7 +887,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]]] = (), ) -> compute.BackendServiceAggregatedList: r"""Call the aggregated list method over HTTP. @@ -806,8 +899,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: ~.compute.BackendServiceAggregatedList: @@ -819,6 +914,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseBackendServicesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -829,6 +925,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 = 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.compute_v1.BackendServicesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._AggregatedList._get_response( self._host, @@ -849,7 +972,31 @@ def __call__( pb_resp = compute.BackendServiceAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceAggregatedList.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.compute_v1.BackendServicesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -886,7 +1033,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -898,8 +1045,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: ~.compute.Operation: @@ -926,6 +1075,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BaseDelete._get_transcoded_request( @@ -940,6 +1090,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.compute_v1.BackendServicesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._Delete._get_response( self._host, @@ -960,7 +1137,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSignedUrlKey( @@ -998,7 +1197,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]]] = (), ) -> compute.Operation: r"""Call the delete signed url key method over HTTP. @@ -1010,8 +1209,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: ~.compute.Operation: @@ -1038,6 +1239,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseDeleteSignedUrlKey._get_http_options() ) + request, metadata = self._interceptor.pre_delete_signed_url_key( request, metadata ) @@ -1050,6 +1252,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 = 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.compute_v1.BackendServicesClient.DeleteSignedUrlKey", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "DeleteSignedUrlKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._DeleteSignedUrlKey._get_response( self._host, @@ -1070,7 +1299,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_signed_url_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.delete_signed_url_key", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "DeleteSignedUrlKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseBackendServicesRestTransport._BaseGet, BackendServicesRestStub): @@ -1105,7 +1356,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]]] = (), ) -> compute.BackendService: r"""Call the get method over HTTP. @@ -1117,8 +1368,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: ~.compute.BackendService: @@ -1143,6 +1396,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BaseGet._get_transcoded_request( @@ -1157,6 +1411,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.compute_v1.BackendServicesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._Get._get_response( self._host, @@ -1177,7 +1458,29 @@ def __call__( pb_resp = compute.BackendService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendService.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.compute_v1.BackendServicesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHealth( @@ -1215,7 +1518,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]]] = (), ) -> compute.BackendServiceGroupHealth: r"""Call the get health method over HTTP. @@ -1227,8 +1530,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: ~.compute.BackendServiceGroupHealth: @@ -1238,6 +1543,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseGetHealth._get_http_options() ) + request, metadata = self._interceptor.pre_get_health(request, metadata) transcoded_request = _BaseBackendServicesRestTransport._BaseGetHealth._get_transcoded_request( http_options, request @@ -1256,6 +1562,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.compute_v1.BackendServicesClient.GetHealth", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "GetHealth", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._GetHealth._get_response( self._host, @@ -1277,7 +1610,31 @@ def __call__( pb_resp = compute.BackendServiceGroupHealth.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_health(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceGroupHealth.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.compute_v1.BackendServicesClient.get_health", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "GetHealth", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1314,7 +1671,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1326,8 +1683,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: ~.compute.Policy: @@ -1360,6 +1719,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseBackendServicesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1370,6 +1730,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 = 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.compute_v1.BackendServicesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._GetIamPolicy._get_response( self._host, @@ -1390,7 +1777,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.BackendServicesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1428,7 +1837,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1440,8 +1849,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: ~.compute.Operation: @@ -1468,6 +1879,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BaseInsert._get_transcoded_request( @@ -1486,6 +1898,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.compute_v1.BackendServicesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._Insert._get_response( self._host, @@ -1507,7 +1946,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseBackendServicesRestTransport._BaseList, BackendServicesRestStub): @@ -1542,7 +2003,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]]] = (), ) -> compute.BackendServiceList: r"""Call the list method over HTTP. @@ -1554,8 +2015,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: ~.compute.BackendServiceList: @@ -1567,6 +2030,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BaseList._get_transcoded_request( @@ -1581,6 +2045,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.compute_v1.BackendServicesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._List._get_response( self._host, @@ -1601,7 +2092,29 @@ def __call__( pb_resp = compute.BackendServiceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceList.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.compute_v1.BackendServicesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsable( @@ -1638,7 +2151,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]]] = (), ) -> compute.BackendServiceListUsable: r"""Call the list usable method over HTTP. @@ -1650,8 +2163,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: ~.compute.BackendServiceListUsable: @@ -1663,6 +2178,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseListUsable._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable(request, metadata) transcoded_request = _BaseBackendServicesRestTransport._BaseListUsable._get_transcoded_request( http_options, request @@ -1673,6 +2189,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 = 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.compute_v1.BackendServicesClient.ListUsable", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "ListUsable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._ListUsable._get_response( self._host, @@ -1693,7 +2236,31 @@ def __call__( pb_resp = compute.BackendServiceListUsable.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceListUsable.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.compute_v1.BackendServicesClient.list_usable", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "ListUsable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseBackendServicesRestTransport._BasePatch, BackendServicesRestStub): @@ -1729,7 +2296,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1741,8 +2308,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: ~.compute.Operation: @@ -1769,6 +2338,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BasePatch._get_transcoded_request( @@ -1787,6 +2357,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.compute_v1.BackendServicesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._Patch._get_response( self._host, @@ -1808,7 +2405,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetEdgeSecurityPolicy( @@ -1847,7 +2466,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]]] = (), ) -> compute.Operation: r"""Call the set edge security policy method over HTTP. @@ -1859,8 +2478,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: ~.compute.Operation: @@ -1887,6 +2508,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseSetEdgeSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_edge_security_policy( request, metadata ) @@ -1903,6 +2525,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 = 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.compute_v1.BackendServicesClient.SetEdgeSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetEdgeSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BackendServicesRestTransport._SetEdgeSecurityPolicy._get_response( @@ -1926,7 +2575,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_edge_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.set_edge_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetEdgeSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1964,7 +2635,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1976,8 +2647,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: ~.compute.Policy: @@ -2010,6 +2683,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseBackendServicesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2024,6 +2698,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 = 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.compute_v1.BackendServicesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._SetIamPolicy._get_response( self._host, @@ -2045,7 +2746,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.BackendServicesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSecurityPolicy( @@ -2084,7 +2807,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]]] = (), ) -> compute.Operation: r"""Call the set security policy method over HTTP. @@ -2096,8 +2819,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: ~.compute.Operation: @@ -2124,6 +2849,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseSetSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_security_policy( request, metadata ) @@ -2140,6 +2866,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 = 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.compute_v1.BackendServicesClient.SetSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._SetSecurityPolicy._get_response( self._host, @@ -2161,7 +2914,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.set_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "SetSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2200,7 +2975,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2212,8 +2987,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: ~.compute.TestPermissionsResponse: @@ -2223,6 +3000,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2239,6 +3017,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 = 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.compute_v1.BackendServicesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._TestIamPermissions._get_response( self._host, @@ -2260,7 +3065,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.BackendServicesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update( @@ -2298,7 +3125,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -2310,8 +3137,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: ~.compute.Operation: @@ -2338,6 +3167,7 @@ def __call__( http_options = ( _BaseBackendServicesRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseBackendServicesRestTransport._BaseUpdate._get_transcoded_request( @@ -2356,6 +3186,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.compute_v1.BackendServicesClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackendServicesRestTransport._Update._get_response( self._host, @@ -2377,7 +3234,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.BackendServicesClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.BackendServices", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/client.py index 2982081397d9..2fe1619a9f90 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/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.compute_v1.services.disk_types import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.DiskTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "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.compute.v1.DiskTypes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListDiskTypesRequest, dict]] = None, @@ -622,7 +659,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of disk types. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -668,8 +705,10 @@ def sample_aggregated_list(): 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.compute_v1.services.disk_types.pagers.AggregatedListPager: @@ -741,7 +780,7 @@ def get( disk_type: 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]]] = (), ) -> compute.DiskType: r"""Returns the specified disk type. @@ -797,8 +836,10 @@ def sample_get(): 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.compute_v1.types.DiskType: @@ -876,7 +917,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of disk types available to the specified project. @@ -928,8 +969,10 @@ def sample_list(): 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.compute_v1.services.disk_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/pagers.py index 12ebee0e4f03..9ffd0d09544c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/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 = compute.AggregatedListDiskTypesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListDiskTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/transports/rest.py index 63ebc782608e..53e57e51b7dd 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disk_types/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 @@ -37,6 +37,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, @@ -93,8 +101,10 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListDiskTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListDiskTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListDiskTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -114,8 +124,10 @@ def post_aggregated_list( return response def pre_get( - self, request: compute.GetDiskTypeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetDiskTypeRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetDiskTypeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetDiskTypeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -133,8 +145,10 @@ def post_get(self, response: compute.DiskType) -> compute.DiskType: return response def pre_list( - self, request: compute.ListDiskTypesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListDiskTypesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListDiskTypesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListDiskTypesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -276,7 +290,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]]] = (), ) -> compute.DiskTypeAggregatedList: r"""Call the aggregated list method over HTTP. @@ -288,8 +302,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: ~.compute.DiskTypeAggregatedList: @@ -299,6 +315,7 @@ def __call__( http_options = ( _BaseDiskTypesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseDiskTypesRestTransport._BaseAggregatedList._get_transcoded_request( @@ -313,6 +330,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.compute_v1.DiskTypesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiskTypesRestTransport._AggregatedList._get_response( self._host, @@ -333,7 +377,29 @@ def __call__( pb_resp = compute.DiskTypeAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskTypeAggregatedList.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.compute_v1.DiskTypesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseDiskTypesRestTransport._BaseGet, DiskTypesRestStub): @@ -368,7 +434,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]]] = (), ) -> compute.DiskType: r"""Call the get method over HTTP. @@ -379,8 +445,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: ~.compute.DiskType: @@ -399,6 +467,7 @@ def __call__( """ http_options = _BaseDiskTypesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseDiskTypesRestTransport._BaseGet._get_transcoded_request( @@ -411,6 +480,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 = 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.compute_v1.DiskTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiskTypesRestTransport._Get._get_response( self._host, @@ -431,7 +527,29 @@ def __call__( pb_resp = compute.DiskType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskType.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.compute_v1.DiskTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseDiskTypesRestTransport._BaseList, DiskTypesRestStub): @@ -466,7 +584,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]]] = (), ) -> compute.DiskTypeList: r"""Call the list method over HTTP. @@ -477,8 +595,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: ~.compute.DiskTypeList: @@ -486,6 +606,7 @@ def __call__( """ http_options = _BaseDiskTypesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseDiskTypesRestTransport._BaseList._get_transcoded_request( @@ -498,6 +619,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 = 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.compute_v1.DiskTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiskTypesRestTransport._List._get_response( self._host, @@ -518,7 +666,29 @@ def __call__( pb_resp = compute.DiskTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskTypeList.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.compute_v1.DiskTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.DiskTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/client.py index e0637dd7e56e..229f23d3c36c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.disks import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.DisksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "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.compute.v1.Disks", + "credentialsType": None, + }, + ) + def add_resource_policies_unary( self, request: Optional[Union[compute.AddResourcePoliciesDiskRequest, dict]] = None, @@ -630,7 +667,7 @@ def add_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk @@ -694,8 +731,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -774,7 +813,7 @@ def add_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk @@ -838,8 +877,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -938,7 +979,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of persistent disks. To prevent failure, Google recommends that you set the @@ -984,8 +1025,10 @@ def sample_aggregated_list(): 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.compute_v1.services.disks.pagers.AggregatedListPager: @@ -1059,7 +1102,7 @@ def bulk_insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Bulk create a set of disks. @@ -1115,8 +1158,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1189,7 +1234,7 @@ def bulk_insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Bulk create a set of disks. @@ -1245,8 +1290,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1343,7 +1390,7 @@ def create_snapshot_unary( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> compute.Operation: r"""Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using @@ -1411,8 +1458,10 @@ def sample_create_snapshot(): 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.api_core.extended_operation.ExtendedOperation: @@ -1485,7 +1534,7 @@ def create_snapshot( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using @@ -1553,8 +1602,10 @@ def sample_create_snapshot(): 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.api_core.extended_operation.ExtendedOperation: @@ -1651,7 +1702,7 @@ def delete_unary( disk: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. @@ -1713,8 +1764,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1784,7 +1837,7 @@ def delete( disk: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. @@ -1846,8 +1899,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1942,7 +1997,7 @@ def get( disk: 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]]] = (), ) -> compute.Disk: r"""Returns the specified persistent disk. @@ -2000,8 +2055,10 @@ def sample_get(): 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.compute_v1.types.Disk: @@ -2081,7 +2138,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -2141,8 +2198,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.cloud.compute_v1.types.Policy: @@ -2232,7 +2291,7 @@ def insert_unary( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> compute.Operation: r"""Creates a persistent disk in the specified project using the data in the request. You can create a disk @@ -2293,8 +2352,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2363,7 +2424,7 @@ def insert( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a persistent disk in the specified project using the data in the request. You can create a disk @@ -2424,8 +2485,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2518,7 +2581,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of persistent disks contained within the specified zone. @@ -2570,8 +2633,10 @@ def sample_list(): 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.compute_v1.services.disks.pagers.ListPager: @@ -2657,7 +2722,7 @@ def remove_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes resource policies from a disk. @@ -2719,8 +2784,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -2801,7 +2868,7 @@ def remove_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes resource policies from a disk. @@ -2863,8 +2930,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -2966,7 +3035,7 @@ def resize_unary( disks_resize_request_resource: Optional[compute.DisksResizeRequest] = 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]]] = (), ) -> compute.Operation: r"""Resizes the specified persistent disk. You can only increase the size of the disk. @@ -3028,8 +3097,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -3102,7 +3173,7 @@ def resize( disks_resize_request_resource: Optional[compute.DisksResizeRequest] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Resizes the specified persistent disk. You can only increase the size of the disk. @@ -3164,8 +3235,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -3263,7 +3336,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3328,8 +3401,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.cloud.compute_v1.types.Policy: @@ -3426,7 +3501,7 @@ def set_labels_unary( zone_set_labels_request_resource: Optional[compute.ZoneSetLabelsRequest] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. @@ -3491,8 +3566,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -3569,7 +3646,7 @@ def set_labels( zone_set_labels_request_resource: Optional[compute.ZoneSetLabelsRequest] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. @@ -3634,8 +3711,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -3739,7 +3818,7 @@ def start_async_replication_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Starts asynchronous replication. Must be invoked on the primary disk. @@ -3802,8 +3881,10 @@ def sample_start_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -3882,7 +3963,7 @@ def start_async_replication( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Starts asynchronous replication. Must be invoked on the primary disk. @@ -3945,8 +4026,10 @@ def sample_start_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4047,7 +4130,7 @@ def stop_async_replication_unary( disk: 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]]] = (), ) -> compute.Operation: r"""Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. @@ -4105,8 +4188,10 @@ def sample_stop_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4176,7 +4261,7 @@ def stop_async_replication( disk: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. @@ -4234,8 +4319,10 @@ def sample_stop_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4334,7 +4421,7 @@ def stop_group_async_replication_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or @@ -4394,8 +4481,10 @@ def sample_stop_group_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4474,7 +4563,7 @@ def stop_group_async_replication( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or @@ -4534,8 +4623,10 @@ def sample_stop_group_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4638,7 +4729,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -4703,8 +4794,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -4779,7 +4872,7 @@ def update_unary( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified disk with the data included in the request. The update is performed only on selected fields @@ -4843,8 +4936,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -4917,7 +5012,7 @@ def update( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified disk with the data included in the request. The update is performed only on selected fields @@ -4981,8 +5076,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/pagers.py index ca3c0d817a1b..917e973f5914 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/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 = compute.AggregatedListDisksRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListDisksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/transports/rest.py index bb76f22b222e..02d1acbc36a9 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/disks/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 @@ -37,6 +37,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, @@ -213,8 +221,10 @@ def post_update(self, response): def pre_add_resource_policies( self, request: compute.AddResourcePoliciesDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddResourcePoliciesDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddResourcePoliciesDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_resource_policies Override in a subclass to manipulate the request or metadata @@ -236,8 +246,10 @@ def post_add_resource_policies( def pre_aggregated_list( self, request: compute.AggregatedListDisksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListDisksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListDisksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -259,8 +271,8 @@ def post_aggregated_list( def pre_bulk_insert( self, request: compute.BulkInsertDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.BulkInsertDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.BulkInsertDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for bulk_insert Override in a subclass to manipulate the request or metadata @@ -280,8 +292,10 @@ def post_bulk_insert(self, response: compute.Operation) -> compute.Operation: def pre_create_snapshot( self, request: compute.CreateSnapshotDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.CreateSnapshotDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.CreateSnapshotDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_snapshot Override in a subclass to manipulate the request or metadata @@ -299,8 +313,10 @@ def post_create_snapshot(self, response: compute.Operation) -> compute.Operation return response def pre_delete( - self, request: compute.DeleteDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -318,8 +334,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -339,8 +357,10 @@ def post_get(self, response: compute.Disk) -> compute.Disk: def pre_get_iam_policy( self, request: compute.GetIamPolicyDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -358,8 +378,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: return response def pre_insert( - self, request: compute.InsertDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -377,8 +399,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListDisksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListDisksRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListDisksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListDisksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -398,8 +422,11 @@ def post_list(self, response: compute.DiskList) -> compute.DiskList: def pre_remove_resource_policies( self, request: compute.RemoveResourcePoliciesDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveResourcePoliciesDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveResourcePoliciesDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_resource_policies Override in a subclass to manipulate the request or metadata @@ -419,8 +446,10 @@ def post_remove_resource_policies( return response def pre_resize( - self, request: compute.ResizeDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ResizeDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ResizeDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ResizeDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resize Override in a subclass to manipulate the request or metadata @@ -440,8 +469,10 @@ def post_resize(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyDiskRequest, 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 +490,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: return response def pre_set_labels( - self, request: compute.SetLabelsDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.SetLabelsDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.SetLabelsDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.SetLabelsDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -480,8 +513,11 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_start_async_replication( self, request: compute.StartAsyncReplicationDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.StartAsyncReplicationDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StartAsyncReplicationDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_async_replication Override in a subclass to manipulate the request or metadata @@ -503,8 +539,10 @@ def post_start_async_replication( def pre_stop_async_replication( self, request: compute.StopAsyncReplicationDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.StopAsyncReplicationDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StopAsyncReplicationDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_async_replication Override in a subclass to manipulate the request or metadata @@ -526,8 +564,11 @@ def post_stop_async_replication( def pre_stop_group_async_replication( self, request: compute.StopGroupAsyncReplicationDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.StopGroupAsyncReplicationDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StopGroupAsyncReplicationDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for stop_group_async_replication Override in a subclass to manipulate the request or metadata @@ -549,8 +590,10 @@ def post_stop_group_async_replication( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -570,8 +613,10 @@ def post_test_iam_permissions( return response def pre_update( - self, request: compute.UpdateDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.UpdateDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.UpdateDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.UpdateDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -714,7 +759,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]]] = (), ) -> compute.Operation: r"""Call the add resource policies method over HTTP. @@ -726,8 +771,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: ~.compute.Operation: @@ -754,6 +801,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseAddResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_add_resource_policies( request, metadata ) @@ -774,6 +822,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.compute_v1.DisksClient.AddResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "AddResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._AddResourcePolicies._get_response( self._host, @@ -795,7 +870,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.add_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "AddResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList(_BaseDisksRestTransport._BaseAggregatedList, DisksRestStub): @@ -830,7 +927,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]]] = (), ) -> compute.DiskAggregatedList: r"""Call the aggregated list method over HTTP. @@ -842,8 +939,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: ~.compute.DiskAggregatedList: @@ -853,6 +952,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseAggregatedList._get_transcoded_request( @@ -867,6 +967,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.compute_v1.DisksClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._AggregatedList._get_response( self._host, @@ -887,7 +1014,29 @@ def __call__( pb_resp = compute.DiskAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskAggregatedList.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.compute_v1.DisksClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BulkInsert(_BaseDisksRestTransport._BaseBulkInsert, DisksRestStub): @@ -923,7 +1072,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]]] = (), ) -> compute.Operation: r"""Call the bulk insert method over HTTP. @@ -935,8 +1084,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: ~.compute.Operation: @@ -961,6 +1112,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseBulkInsert._get_http_options() + request, metadata = self._interceptor.pre_bulk_insert(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseBulkInsert._get_transcoded_request( @@ -979,6 +1131,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.compute_v1.DisksClient.BulkInsert", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "BulkInsert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._BulkInsert._get_response( self._host, @@ -1000,7 +1179,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.bulk_insert", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "BulkInsert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSnapshot(_BaseDisksRestTransport._BaseCreateSnapshot, DisksRestStub): @@ -1036,7 +1237,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]]] = (), ) -> compute.Operation: r"""Call the create snapshot method over HTTP. @@ -1048,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: ~.compute.Operation: @@ -1076,6 +1279,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseCreateSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_create_snapshot(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseCreateSnapshot._get_transcoded_request( @@ -1094,6 +1298,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.compute_v1.DisksClient.CreateSnapshot", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "CreateSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._CreateSnapshot._get_response( self._host, @@ -1115,7 +1346,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.create_snapshot", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "CreateSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseDisksRestTransport._BaseDelete, DisksRestStub): @@ -1150,7 +1403,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1161,8 +1414,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: ~.compute.Operation: @@ -1187,6 +1442,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseDelete._get_transcoded_request( @@ -1199,6 +1455,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 = 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.compute_v1.DisksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._Delete._get_response( self._host, @@ -1219,7 +1502,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseDisksRestTransport._BaseGet, DisksRestStub): @@ -1254,7 +1559,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]]] = (), ) -> compute.Disk: r"""Call the get method over HTTP. @@ -1265,8 +1570,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: ~.compute.Disk: @@ -1286,6 +1593,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseGet._get_transcoded_request( @@ -1298,6 +1606,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 = 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.compute_v1.DisksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._Get._get_response( self._host, @@ -1318,7 +1653,29 @@ def __call__( pb_resp = compute.Disk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Disk.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.compute_v1.DisksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseDisksRestTransport._BaseGetIamPolicy, DisksRestStub): @@ -1353,7 +1710,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1365,8 +1722,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: ~.compute.Policy: @@ -1397,6 +1756,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseGetIamPolicy._get_http_options() + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1411,6 +1771,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.compute_v1.DisksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._GetIamPolicy._get_response( self._host, @@ -1431,7 +1818,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.DisksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseDisksRestTransport._BaseInsert, DisksRestStub): @@ -1467,7 +1876,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1478,8 +1887,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: ~.compute.Operation: @@ -1504,6 +1915,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseInsert._get_transcoded_request( @@ -1520,6 +1932,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 = 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.compute_v1.DisksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._Insert._get_response( self._host, @@ -1541,7 +1980,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseDisksRestTransport._BaseList, DisksRestStub): @@ -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]]] = (), ) -> compute.DiskList: r"""Call the list 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: ~.compute.DiskList: @@ -1596,6 +2059,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseList._get_transcoded_request( @@ -1608,6 +2072,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 = 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.compute_v1.DisksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._List._get_response( self._host, @@ -1628,7 +2119,29 @@ def __call__( pb_resp = compute.DiskList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskList.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.compute_v1.DisksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveResourcePolicies( @@ -1666,7 +2179,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]]] = (), ) -> compute.Operation: r"""Call the remove resource policies method over HTTP. @@ -1678,8 +2191,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: ~.compute.Operation: @@ -1706,6 +2221,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseRemoveResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_remove_resource_policies( request, metadata ) @@ -1722,6 +2238,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 = 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.compute_v1.DisksClient.RemoveResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "RemoveResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._RemoveResourcePolicies._get_response( self._host, @@ -1743,7 +2286,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.remove_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "RemoveResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resize(_BaseDisksRestTransport._BaseResize, DisksRestStub): @@ -1779,7 +2344,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]]] = (), ) -> compute.Operation: r"""Call the resize method over HTTP. @@ -1790,8 +2355,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: ~.compute.Operation: @@ -1816,6 +2383,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseResize._get_http_options() + request, metadata = self._interceptor.pre_resize(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseResize._get_transcoded_request( @@ -1832,6 +2400,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 = 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.compute_v1.DisksClient.Resize", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Resize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._Resize._get_response( self._host, @@ -1853,7 +2448,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.resize", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Resize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseDisksRestTransport._BaseSetIamPolicy, DisksRestStub): @@ -1889,7 +2506,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1901,8 +2518,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: ~.compute.Policy: @@ -1933,6 +2552,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseSetIamPolicy._get_http_options() + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1951,6 +2571,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.compute_v1.DisksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._SetIamPolicy._get_response( self._host, @@ -1972,7 +2619,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.DisksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseDisksRestTransport._BaseSetLabels, DisksRestStub): @@ -2008,7 +2677,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -2020,8 +2689,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: ~.compute.Operation: @@ -2046,6 +2717,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseSetLabels._get_http_options() + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseSetLabels._get_transcoded_request( @@ -2064,6 +2736,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.compute_v1.DisksClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._SetLabels._get_response( self._host, @@ -2085,7 +2784,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartAsyncReplication( @@ -2123,7 +2844,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]]] = (), ) -> compute.Operation: r"""Call the start async replication method over HTTP. @@ -2135,8 +2856,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: ~.compute.Operation: @@ -2163,6 +2886,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseStartAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_start_async_replication( request, metadata ) @@ -2179,6 +2903,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 = 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.compute_v1.DisksClient.StartAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StartAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._StartAsyncReplication._get_response( self._host, @@ -2200,7 +2951,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.start_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StartAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopAsyncReplication( @@ -2237,7 +3010,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]]] = (), ) -> compute.Operation: r"""Call the stop async replication method over HTTP. @@ -2249,8 +3022,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: ~.compute.Operation: @@ -2277,6 +3052,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseStopAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_stop_async_replication( request, metadata ) @@ -2289,6 +3065,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 = 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.compute_v1.DisksClient.StopAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StopAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._StopAsyncReplication._get_response( self._host, @@ -2309,7 +3112,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.stop_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StopAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopGroupAsyncReplication( @@ -2347,7 +3172,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]]] = (), ) -> compute.Operation: r"""Call the stop group async replication method over HTTP. @@ -2360,8 +3185,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: ~.compute.Operation: @@ -2388,6 +3215,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseStopGroupAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_stop_group_async_replication( request, metadata ) @@ -2404,6 +3232,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 = 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.compute_v1.DisksClient.StopGroupAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StopGroupAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._StopGroupAsyncReplication._get_response( self._host, @@ -2425,7 +3280,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_group_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.stop_group_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "StopGroupAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2463,7 +3340,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2475,8 +3352,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: ~.compute.TestPermissionsResponse: @@ -2486,6 +3365,7 @@ def __call__( http_options = ( _BaseDisksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2508,6 +3388,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.compute_v1.DisksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._TestIamPermissions._get_response( self._host, @@ -2529,7 +3436,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.DisksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseDisksRestTransport._BaseUpdate, DisksRestStub): @@ -2565,7 +3494,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -2576,8 +3505,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: ~.compute.Operation: @@ -2602,6 +3533,7 @@ def __call__( """ http_options = _BaseDisksRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseDisksRestTransport._BaseUpdate._get_transcoded_request( @@ -2618,6 +3550,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 = 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.compute_v1.DisksClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DisksRestTransport._Update._get_response( self._host, @@ -2639,7 +3598,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.DisksClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Disks", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/client.py index 690c9b15c0ec..fca2b661f1f1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.external_vpn_gateways import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.ExternalVpnGatewaysClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "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.compute.v1.ExternalVpnGateways", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteExternalVpnGatewayRequest, dict]] = None, @@ -636,7 +673,7 @@ def delete_unary( external_vpn_gateway: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified externalVpnGateway. @@ -687,8 +724,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -754,7 +793,7 @@ def delete( external_vpn_gateway: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified externalVpnGateway. @@ -805,8 +844,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -896,7 +937,7 @@ def get( external_vpn_gateway: 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]]] = (), ) -> compute.ExternalVpnGateway: r"""Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() @@ -949,8 +990,10 @@ def sample_get(): 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.compute_v1.types.ExternalVpnGateway: @@ -1028,7 +1071,7 @@ def insert_unary( external_vpn_gateway_resource: Optional[compute.ExternalVpnGateway] = 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]]] = (), ) -> compute.Operation: r"""Creates a ExternalVpnGateway in the specified project using the data included in the request. @@ -1077,8 +1120,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1139,7 +1184,7 @@ def insert( external_vpn_gateway_resource: Optional[compute.ExternalVpnGateway] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a ExternalVpnGateway in the specified project using the data included in the request. @@ -1188,8 +1233,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1273,7 +1320,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of ExternalVpnGateway available to the specified project. @@ -1318,8 +1365,10 @@ def sample_list(): 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.compute_v1.services.external_vpn_gateways.pagers.ListPager: @@ -1397,7 +1446,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources @@ -1455,8 +1504,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1533,7 +1584,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources @@ -1591,8 +1642,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1693,7 +1746,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -1750,8 +1803,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/pagers.py index 62f5d2d2597b..d13d942a03d7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/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 = compute.ListExternalVpnGatewaysRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/transports/rest.py index 904c85ac0731..b3daa948e7ae 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/external_vpn_gateways/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_test_iam_permissions(self, response): def pre_delete( self, request: compute.DeleteExternalVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteExternalVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteExternalVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -138,8 +148,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetExternalVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetExternalVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetExternalVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -161,8 +173,10 @@ def post_get( def pre_insert( self, request: compute.InsertExternalVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertExternalVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertExternalVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -182,8 +196,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListExternalVpnGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListExternalVpnGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListExternalVpnGatewaysRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -205,8 +221,11 @@ def post_list( def pre_set_labels( self, request: compute.SetLabelsExternalVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsExternalVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsExternalVpnGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -226,9 +245,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsExternalVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsExternalVpnGatewayRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsExternalVpnGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -373,7 +393,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -385,8 +405,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: ~.compute.Operation: @@ -413,6 +435,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseExternalVpnGatewaysRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -423,6 +446,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 = 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.compute_v1.ExternalVpnGatewaysClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExternalVpnGatewaysRestTransport._Delete._get_response( self._host, @@ -443,7 +493,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ExternalVpnGatewaysClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -480,7 +552,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]]] = (), ) -> compute.ExternalVpnGateway: r"""Call the get method over HTTP. @@ -492,8 +564,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: ~.compute.ExternalVpnGateway: @@ -517,6 +591,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseExternalVpnGatewaysRestTransport._BaseGet._get_transcoded_request( @@ -531,6 +606,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.compute_v1.ExternalVpnGatewaysClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExternalVpnGatewaysRestTransport._Get._get_response( self._host, @@ -551,7 +653,29 @@ def __call__( pb_resp = compute.ExternalVpnGateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ExternalVpnGateway.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.compute_v1.ExternalVpnGatewaysClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -589,7 +713,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -601,8 +725,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: ~.compute.Operation: @@ -629,6 +755,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseExternalVpnGatewaysRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -643,6 +770,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 = 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.compute_v1.ExternalVpnGatewaysClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExternalVpnGatewaysRestTransport._Insert._get_response( self._host, @@ -664,7 +818,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ExternalVpnGatewaysClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -701,7 +877,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]]] = (), ) -> compute.ExternalVpnGatewayList: r"""Call the list method over HTTP. @@ -713,8 +889,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: ~.compute.ExternalVpnGatewayList: @@ -726,6 +904,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseExternalVpnGatewaysRestTransport._BaseList._get_transcoded_request( @@ -740,6 +919,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.compute_v1.ExternalVpnGatewaysClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExternalVpnGatewaysRestTransport._List._get_response( self._host, @@ -760,7 +966,29 @@ def __call__( pb_resp = compute.ExternalVpnGatewayList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ExternalVpnGatewayList.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.compute_v1.ExternalVpnGatewaysClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -799,7 +1027,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -811,8 +1039,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: ~.compute.Operation: @@ -839,6 +1069,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseExternalVpnGatewaysRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -853,6 +1084,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 = 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.compute_v1.ExternalVpnGatewaysClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ExternalVpnGatewaysRestTransport._SetLabels._get_response( self._host, @@ -874,7 +1132,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ExternalVpnGatewaysClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -913,7 +1193,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -925,8 +1205,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: ~.compute.TestPermissionsResponse: @@ -936,6 +1218,7 @@ def __call__( http_options = ( _BaseExternalVpnGatewaysRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -952,6 +1235,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 = 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.compute_v1.ExternalVpnGatewaysClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ExternalVpnGatewaysRestTransport._TestIamPermissions._get_response( @@ -975,7 +1285,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.ExternalVpnGatewaysClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.ExternalVpnGateways", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/client.py index 2d349546a644..8da708b9a75a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.firewall_policies import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.FirewallPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "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.compute.v1.FirewallPolicies", + "credentialsType": None, + }, + ) + def add_association_unary( self, request: Optional[ @@ -638,7 +675,7 @@ def add_association_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts an association for the specified firewall policy. @@ -689,8 +726,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -761,7 +800,7 @@ def add_association( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts an association for the specified firewall policy. @@ -812,8 +851,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -903,7 +944,7 @@ def add_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Inserts a rule into a firewall policy. @@ -953,8 +994,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1017,7 +1060,7 @@ def add_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts a rule into a firewall policy. @@ -1067,8 +1110,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1153,7 +1198,7 @@ def clone_rules_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Copies rules to the specified firewall policy. @@ -1198,8 +1243,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1259,7 +1306,7 @@ def clone_rules( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Copies rules to the specified firewall policy. @@ -1304,8 +1351,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1388,7 +1437,7 @@ def delete_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified policy. @@ -1433,8 +1482,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1494,7 +1545,7 @@ def delete( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified policy. @@ -1539,8 +1590,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1623,7 +1676,7 @@ def get( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicy: r"""Returns the specified firewall policy. @@ -1666,8 +1719,10 @@ def sample_get(): 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.compute_v1.types.FirewallPolicy: @@ -1729,7 +1784,7 @@ def get_association( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Gets an association with the specified name. @@ -1774,8 +1829,10 @@ def sample_get_association(): 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.compute_v1.types.FirewallPolicyAssociation: @@ -1835,7 +1892,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1881,8 +1938,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.cloud.compute_v1.types.Policy: @@ -1960,7 +2019,7 @@ def get_rule( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyRule: r"""Gets a rule of the specified priority. @@ -2005,8 +2064,10 @@ def sample_get_rule(): 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.compute_v1.types.FirewallPolicyRule: @@ -2069,7 +2130,7 @@ def insert_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new policy in the specified project using the data included in the request. @@ -2122,8 +2183,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2178,7 +2241,7 @@ def insert( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new policy in the specified project using the data included in the request. @@ -2231,8 +2294,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2309,7 +2374,7 @@ def list( *, 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.ListPager: r"""Lists all the policies that have been configured for the specified folder or organization. @@ -2348,8 +2413,10 @@ def sample_list(): 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.compute_v1.services.firewall_policies.pagers.ListPager: @@ -2401,7 +2468,7 @@ def list_associations( *, 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]]] = (), ) -> compute.FirewallPoliciesListAssociationsResponse: r"""Lists associations of a specified target, i.e., organization or folder. @@ -2439,8 +2506,10 @@ def sample_list_associations(): 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.compute_v1.types.FirewallPoliciesListAssociationsResponse: @@ -2478,7 +2547,7 @@ def move_unary( parent_id: 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]]] = (), ) -> compute.Operation: r"""Moves the specified firewall policy. @@ -2533,8 +2602,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -2597,7 +2668,7 @@ def move( parent_id: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Moves the specified firewall policy. @@ -2652,8 +2723,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -2740,7 +2813,7 @@ def patch_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified policy with the data included in the request. @@ -2791,8 +2864,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2855,7 +2930,7 @@ def patch( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified policy with the data included in the request. @@ -2906,8 +2981,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2993,7 +3070,7 @@ def patch_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Patches a rule of the specified priority. @@ -3043,8 +3120,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3107,7 +3186,7 @@ def patch_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches a rule of the specified priority. @@ -3157,8 +3236,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3245,7 +3326,7 @@ def remove_association_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Removes an association for the specified firewall policy. @@ -3291,8 +3372,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3354,7 +3437,7 @@ def remove_association( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes an association for the specified firewall policy. @@ -3400,8 +3483,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3484,7 +3569,7 @@ def remove_rule_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes a rule of the specified priority. @@ -3529,8 +3614,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3590,7 +3677,7 @@ def remove_rule( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a rule of the specified priority. @@ -3635,8 +3722,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3724,7 +3813,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3775,8 +3864,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.cloud.compute_v1.types.Policy: @@ -3865,7 +3956,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -3916,8 +4007,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/pagers.py index 85db80666514..3a8e6864f9c8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/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 = compute.ListFirewallPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/transports/rest.py index 4b11f4cb0887..2ae3c7e45643 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewall_policies/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 @@ -37,6 +37,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, @@ -213,8 +221,11 @@ def post_test_iam_permissions(self, response): def pre_add_association( self, request: compute.AddAssociationFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddAssociationFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddAssociationFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_association Override in a subclass to manipulate the request or metadata @@ -234,8 +245,10 @@ def post_add_association(self, response: compute.Operation) -> compute.Operation def pre_add_rule( self, request: compute.AddRuleFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddRuleFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddRuleFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_rule Override in a subclass to manipulate the request or metadata @@ -255,8 +268,10 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: def pre_clone_rules( self, request: compute.CloneRulesFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.CloneRulesFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.CloneRulesFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for clone_rules Override in a subclass to manipulate the request or metadata @@ -276,8 +291,10 @@ def post_clone_rules(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -297,8 +314,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -318,8 +337,11 @@ def post_get(self, response: compute.FirewallPolicy) -> compute.FirewallPolicy: def pre_get_association( self, request: compute.GetAssociationFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetAssociationFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetAssociationFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_association Override in a subclass to manipulate the request or metadata @@ -341,8 +363,11 @@ def post_get_association( def pre_get_iam_policy( self, request: compute.GetIamPolicyFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -362,8 +387,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_get_rule( self, request: compute.GetRuleFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRuleFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRuleFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_rule Override in a subclass to manipulate the request or metadata @@ -385,8 +412,10 @@ def post_get_rule( def pre_insert( self, request: compute.InsertFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -406,8 +435,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListFirewallPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListFirewallPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListFirewallPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -429,9 +460,10 @@ def post_list( def pre_list_associations( self, request: compute.ListAssociationsFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListAssociationsFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.ListAssociationsFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_associations @@ -454,8 +486,10 @@ def post_list_associations( def pre_move( self, request: compute.MoveFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.MoveFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.MoveFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for move Override in a subclass to manipulate the request or metadata @@ -475,8 +509,10 @@ def post_move(self, response: compute.Operation) -> compute.Operation: def pre_patch( self, request: compute.PatchFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -496,8 +532,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_rule( self, request: compute.PatchRuleFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRuleFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRuleFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch_rule Override in a subclass to manipulate the request or metadata @@ -517,9 +555,10 @@ def post_patch_rule(self, response: compute.Operation) -> compute.Operation: def pre_remove_association( self, request: compute.RemoveAssociationFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveAssociationFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.RemoveAssociationFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_association @@ -540,8 +579,10 @@ def post_remove_association(self, response: compute.Operation) -> compute.Operat def pre_remove_rule( self, request: compute.RemoveRuleFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveRuleFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveRuleFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_rule Override in a subclass to manipulate the request or metadata @@ -561,8 +602,11 @@ def post_remove_rule(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -582,9 +626,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -730,7 +775,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]]] = (), ) -> compute.Operation: r"""Call the add association method over HTTP. @@ -742,8 +787,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: ~.compute.Operation: @@ -770,6 +817,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseAddAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_add_association(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseAddAssociation._get_transcoded_request( http_options, request @@ -784,6 +832,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 = 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.compute_v1.FirewallPoliciesClient.AddAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "AddAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._AddAssociation._get_response( self._host, @@ -805,7 +880,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.add_association", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "AddAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddRule( @@ -843,7 +940,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]]] = (), ) -> compute.Operation: r"""Call the add rule method over HTTP. @@ -855,8 +952,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: ~.compute.Operation: @@ -883,6 +982,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseAddRule._get_http_options() ) + request, metadata = self._interceptor.pre_add_rule(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseAddRule._get_transcoded_request( @@ -903,6 +1003,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.compute_v1.FirewallPoliciesClient.AddRule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "AddRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._AddRule._get_response( self._host, @@ -924,7 +1051,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.add_rule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "AddRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CloneRules( @@ -961,7 +1110,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]]] = (), ) -> compute.Operation: r"""Call the clone rules method over HTTP. @@ -973,8 +1122,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: ~.compute.Operation: @@ -1001,6 +1152,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseCloneRules._get_http_options() ) + request, metadata = self._interceptor.pre_clone_rules(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseCloneRules._get_transcoded_request( http_options, request @@ -1011,6 +1163,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 = 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.compute_v1.FirewallPoliciesClient.CloneRules", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "CloneRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._CloneRules._get_response( self._host, @@ -1031,7 +1210,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clone_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.clone_rules", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "CloneRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -1068,7 +1269,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1080,8 +1281,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: ~.compute.Operation: @@ -1108,6 +1311,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseDelete._get_transcoded_request( @@ -1122,6 +1326,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.compute_v1.FirewallPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._Delete._get_response( self._host, @@ -1142,7 +1373,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseFirewallPoliciesRestTransport._BaseGet, FirewallPoliciesRestStub): @@ -1177,7 +1430,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]]] = (), ) -> compute.FirewallPolicy: r"""Call the get method over HTTP. @@ -1189,8 +1442,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: ~.compute.FirewallPolicy: @@ -1202,6 +1457,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseGet._get_transcoded_request( @@ -1216,6 +1472,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.compute_v1.FirewallPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._Get._get_response( self._host, @@ -1236,7 +1519,29 @@ def __call__( pb_resp = compute.FirewallPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicy.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.compute_v1.FirewallPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAssociation( @@ -1273,7 +1578,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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Call the get association method over HTTP. @@ -1285,8 +1590,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: ~.compute.FirewallPolicyAssociation: @@ -1296,6 +1603,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseGetAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_get_association(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseGetAssociation._get_transcoded_request( http_options, request @@ -1306,6 +1614,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 = 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.compute_v1.FirewallPoliciesClient.GetAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._GetAssociation._get_response( self._host, @@ -1326,7 +1661,31 @@ def __call__( pb_resp = compute.FirewallPolicyAssociation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyAssociation.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.compute_v1.FirewallPoliciesClient.get_association", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1363,7 +1722,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1375,8 +1734,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: ~.compute.Policy: @@ -1409,6 +1770,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1419,6 +1781,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 = 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.compute_v1.FirewallPoliciesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._GetIamPolicy._get_response( self._host, @@ -1439,7 +1828,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.FirewallPoliciesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -1476,7 +1887,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]]] = (), ) -> compute.FirewallPolicyRule: r"""Call the get rule method over HTTP. @@ -1488,8 +1899,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: ~.compute.FirewallPolicyRule: @@ -1503,6 +1916,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseGetRule._get_transcoded_request( @@ -1517,6 +1931,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.compute_v1.FirewallPoliciesClient.GetRule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._GetRule._get_response( self._host, @@ -1537,7 +1978,29 @@ def __call__( pb_resp = compute.FirewallPolicyRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyRule.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.compute_v1.FirewallPoliciesClient.get_rule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1575,7 +2038,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1587,8 +2050,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: ~.compute.Operation: @@ -1615,6 +2080,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseInsert._get_transcoded_request( @@ -1635,6 +2101,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.compute_v1.FirewallPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._Insert._get_response( self._host, @@ -1656,7 +2149,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseFirewallPoliciesRestTransport._BaseList, FirewallPoliciesRestStub): @@ -1691,7 +2206,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]]] = (), ) -> compute.FirewallPolicyList: r"""Call the list method over HTTP. @@ -1703,8 +2218,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: ~.compute.FirewallPolicyList: @@ -1714,6 +2231,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseList._get_transcoded_request( @@ -1728,6 +2246,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.compute_v1.FirewallPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._List._get_response( self._host, @@ -1748,7 +2293,29 @@ def __call__( pb_resp = compute.FirewallPolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyList.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.compute_v1.FirewallPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssociations( @@ -1786,7 +2353,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]]] = (), ) -> compute.FirewallPoliciesListAssociationsResponse: r"""Call the list associations method over HTTP. @@ -1798,8 +2365,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: ~.compute.FirewallPoliciesListAssociationsResponse: @@ -1809,6 +2378,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseListAssociations._get_http_options() ) + request, metadata = self._interceptor.pre_list_associations( request, metadata ) @@ -1821,6 +2391,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 = 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.compute_v1.FirewallPoliciesClient.ListAssociations", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "ListAssociations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._ListAssociations._get_response( self._host, @@ -1841,7 +2438,33 @@ def __call__( pb_resp = compute.FirewallPoliciesListAssociationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_associations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.FirewallPoliciesListAssociationsResponse.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.compute_v1.FirewallPoliciesClient.list_associations", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "ListAssociations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Move(_BaseFirewallPoliciesRestTransport._BaseMove, FirewallPoliciesRestStub): @@ -1876,7 +2499,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]]] = (), ) -> compute.Operation: r"""Call the move method over HTTP. @@ -1888,8 +2511,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: ~.compute.Operation: @@ -1916,6 +2541,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseMove._get_http_options() ) + request, metadata = self._interceptor.pre_move(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BaseMove._get_transcoded_request( @@ -1930,6 +2556,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.compute_v1.FirewallPoliciesClient.Move", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Move", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._Move._get_response( self._host, @@ -1950,7 +2603,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.move", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Move", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1988,7 +2663,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -2000,8 +2675,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: ~.compute.Operation: @@ -2028,6 +2705,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseFirewallPoliciesRestTransport._BasePatch._get_transcoded_request( @@ -2046,6 +2724,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.compute_v1.FirewallPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._Patch._get_response( self._host, @@ -2067,7 +2772,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchRule( @@ -2105,7 +2832,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]]] = (), ) -> compute.Operation: r"""Call the patch rule method over HTTP. @@ -2117,8 +2844,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: ~.compute.Operation: @@ -2145,6 +2874,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BasePatchRule._get_http_options() ) + request, metadata = self._interceptor.pre_patch_rule(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BasePatchRule._get_transcoded_request( http_options, request @@ -2159,6 +2889,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 = 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.compute_v1.FirewallPoliciesClient.PatchRule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "PatchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._PatchRule._get_response( self._host, @@ -2180,7 +2937,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.patch_rule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "PatchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveAssociation( @@ -2218,7 +2997,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]]] = (), ) -> compute.Operation: r"""Call the remove association method over HTTP. @@ -2230,8 +3009,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: ~.compute.Operation: @@ -2258,6 +3039,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseRemoveAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_remove_association( request, metadata ) @@ -2270,6 +3052,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 = 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.compute_v1.FirewallPoliciesClient.RemoveAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "RemoveAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._RemoveAssociation._get_response( self._host, @@ -2290,7 +3099,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.remove_association", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "RemoveAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveRule( @@ -2327,7 +3158,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]]] = (), ) -> compute.Operation: r"""Call the remove rule method over HTTP. @@ -2339,8 +3170,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: ~.compute.Operation: @@ -2367,6 +3200,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseRemoveRule._get_http_options() ) + request, metadata = self._interceptor.pre_remove_rule(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseRemoveRule._get_transcoded_request( http_options, request @@ -2377,6 +3211,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 = 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.compute_v1.FirewallPoliciesClient.RemoveRule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "RemoveRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._RemoveRule._get_response( self._host, @@ -2397,7 +3258,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallPoliciesClient.remove_rule", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "RemoveRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2435,7 +3318,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -2447,8 +3330,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: ~.compute.Policy: @@ -2481,6 +3366,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseFirewallPoliciesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2495,6 +3381,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 = 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.compute_v1.FirewallPoliciesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._SetIamPolicy._get_response( self._host, @@ -2516,7 +3429,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.FirewallPoliciesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2555,7 +3490,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2567,8 +3502,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: ~.compute.TestPermissionsResponse: @@ -2578,6 +3515,7 @@ def __call__( http_options = ( _BaseFirewallPoliciesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2594,6 +3532,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 = 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.compute_v1.FirewallPoliciesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallPoliciesRestTransport._TestIamPermissions._get_response( self._host, @@ -2615,7 +3580,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.FirewallPoliciesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.FirewallPolicies", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/client.py index 6f02daa4fc23..0de4cdc1a12d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.firewalls import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.FirewallsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "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.compute.v1.Firewalls", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteFirewallRequest, dict]] = None, @@ -626,7 +663,7 @@ def delete_unary( firewall: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified firewall. @@ -675,8 +712,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -742,7 +781,7 @@ def delete( firewall: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified firewall. @@ -791,8 +830,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -882,7 +923,7 @@ def get( firewall: 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]]] = (), ) -> compute.Firewall: r"""Returns the specified firewall. @@ -930,8 +971,10 @@ def sample_get(): 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.compute_v1.types.Firewall: @@ -1000,7 +1043,7 @@ def insert_unary( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> compute.Operation: r"""Creates a firewall rule in the specified project using the data included in the request. @@ -1049,8 +1092,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1111,7 +1156,7 @@ def insert( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a firewall rule in the specified project using the data included in the request. @@ -1160,8 +1205,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1245,7 +1292,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of firewall rules available to the specified project. @@ -1289,8 +1336,10 @@ def sample_list(): 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.compute_v1.services.firewalls.pagers.ListPager: @@ -1364,7 +1413,7 @@ def patch_unary( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified firewall rule with the data included in the request. This method supports PATCH @@ -1421,8 +1470,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1491,7 +1542,7 @@ def patch( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified firewall rule with the data included in the request. This method supports PATCH @@ -1548,8 +1599,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1642,7 +1695,7 @@ def update_unary( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified firewall rule with the data included in the request. Note that all fields will be @@ -1700,8 +1753,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1770,7 +1825,7 @@ def update( firewall_resource: Optional[compute.Firewall] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified firewall rule with the data included in the request. Note that all fields will be @@ -1828,8 +1883,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/pagers.py index 0dd23cd88cdc..b555ae4f8f9c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/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 = compute.ListFirewallsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/transports/rest.py index 644c29e7b4cf..896cd8868490 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/firewalls/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 @@ -37,6 +37,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, @@ -117,8 +125,8 @@ def post_update(self, response): def pre_delete( self, request: compute.DeleteFirewallRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteFirewallRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteFirewallRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -136,8 +144,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetFirewallRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetFirewallRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetFirewallRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetFirewallRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -157,8 +167,8 @@ def post_get(self, response: compute.Firewall) -> compute.Firewall: def pre_insert( self, request: compute.InsertFirewallRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertFirewallRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertFirewallRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -176,8 +186,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListFirewallsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListFirewallsRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListFirewallsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListFirewallsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -195,8 +207,10 @@ def post_list(self, response: compute.FirewallList) -> compute.FirewallList: return response def pre_patch( - self, request: compute.PatchFirewallRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PatchFirewallRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PatchFirewallRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchFirewallRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -216,8 +230,8 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateFirewallRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateFirewallRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.UpdateFirewallRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -357,7 +371,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -369,8 +383,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: ~.compute.Operation: @@ -395,6 +411,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BaseDelete._get_transcoded_request( @@ -409,6 +426,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.compute_v1.FirewallsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._Delete._get_response( self._host, @@ -429,7 +473,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseFirewallsRestTransport._BaseGet, FirewallsRestStub): @@ -464,7 +530,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]]] = (), ) -> compute.Firewall: r"""Call the get method over HTTP. @@ -475,8 +541,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: ~.compute.Firewall: @@ -489,6 +557,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BaseGet._get_transcoded_request( @@ -501,6 +570,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 = 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.compute_v1.FirewallsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._Get._get_response( self._host, @@ -521,7 +617,29 @@ def __call__( pb_resp = compute.Firewall.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Firewall.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.compute_v1.FirewallsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseFirewallsRestTransport._BaseInsert, FirewallsRestStub): @@ -557,7 +675,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -569,8 +687,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: ~.compute.Operation: @@ -595,6 +715,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BaseInsert._get_transcoded_request( @@ -613,6 +734,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.compute_v1.FirewallsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._Insert._get_response( self._host, @@ -634,7 +782,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseFirewallsRestTransport._BaseList, FirewallsRestStub): @@ -669,7 +839,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]]] = (), ) -> compute.FirewallList: r"""Call the list method over HTTP. @@ -680,8 +850,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: ~.compute.FirewallList: @@ -689,6 +861,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BaseList._get_transcoded_request( @@ -701,6 +874,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 = 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.compute_v1.FirewallsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._List._get_response( self._host, @@ -721,7 +921,29 @@ def __call__( pb_resp = compute.FirewallList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallList.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.compute_v1.FirewallsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseFirewallsRestTransport._BasePatch, FirewallsRestStub): @@ -757,7 +979,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -769,8 +991,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: ~.compute.Operation: @@ -795,6 +1019,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BasePatch._get_transcoded_request( @@ -813,6 +1038,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.compute_v1.FirewallsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._Patch._get_response( self._host, @@ -834,7 +1086,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseFirewallsRestTransport._BaseUpdate, FirewallsRestStub): @@ -870,7 +1144,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -882,8 +1156,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: ~.compute.Operation: @@ -908,6 +1184,7 @@ def __call__( """ http_options = _BaseFirewallsRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseFirewallsRestTransport._BaseUpdate._get_transcoded_request( @@ -926,6 +1203,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.compute_v1.FirewallsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallsRestTransport._Update._get_response( self._host, @@ -947,7 +1251,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.FirewallsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Firewalls", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/client.py index 53e9a20ae3e0..bce45cef30fc 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.forwarding_rules import pagers @@ -560,6 +570,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( @@ -625,6 +639,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.compute_v1.ForwardingRulesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "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.compute.v1.ForwardingRules", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -634,7 +671,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of forwarding rules. To prevent failure, Google recommends that you set the @@ -680,8 +717,10 @@ def sample_aggregated_list(): 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.compute_v1.services.forwarding_rules.pagers.AggregatedListPager: @@ -753,7 +792,7 @@ def delete_unary( forwarding_rule: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified ForwardingRule resource. @@ -812,8 +851,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -883,7 +924,7 @@ def delete( forwarding_rule: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified ForwardingRule resource. @@ -942,8 +983,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1038,7 +1081,7 @@ def get( forwarding_rule: 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]]] = (), ) -> compute.ForwardingRule: r"""Returns the specified ForwardingRule resource. @@ -1097,8 +1140,10 @@ def sample_get(): 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.compute_v1.types.ForwardingRule: @@ -1178,7 +1223,7 @@ def insert_unary( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> compute.Operation: r"""Creates a ForwardingRule resource in the specified project and region using the data included in the @@ -1236,8 +1281,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1306,7 +1353,7 @@ def insert( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a ForwardingRule resource in the specified project and region using the data included in the @@ -1364,8 +1411,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1458,7 +1507,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of ForwardingRule resources available to the specified project and region. @@ -1511,8 +1560,10 @@ def sample_list(): 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.compute_v1.services.forwarding_rules.pagers.ListPager: @@ -1594,7 +1645,7 @@ def patch_unary( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the @@ -1661,8 +1712,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1737,7 +1790,7 @@ def patch( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the @@ -1804,8 +1857,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1907,7 +1962,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources @@ -1971,8 +2026,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2051,7 +2108,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources @@ -2115,8 +2172,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2218,7 +2277,7 @@ def set_target_unary( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> compute.Operation: r"""Changes target URL for forwarding rule. The new target should be of the same type as the old target. @@ -2283,8 +2342,10 @@ def sample_set_target(): 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.api_core.extended_operation.ExtendedOperation: @@ -2359,7 +2420,7 @@ def set_target( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes target URL for forwarding rule. The new target should be of the same type as the old target. @@ -2424,8 +2485,10 @@ def sample_set_target(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/pagers.py index 8f86a1a7bfea..c3fe15533900 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/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 = compute.AggregatedListForwardingRulesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListForwardingRulesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/transports/rest.py index 444c55abe758..a7794aac8401 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/forwarding_rules/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 @@ -37,6 +37,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, @@ -133,8 +141,11 @@ def post_set_target(self, response): def pre_aggregated_list( self, request: compute.AggregatedListForwardingRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListForwardingRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListForwardingRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -156,8 +167,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -177,8 +190,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -198,8 +213,10 @@ def post_get(self, response: compute.ForwardingRule) -> compute.ForwardingRule: def pre_insert( self, request: compute.InsertForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -219,8 +236,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListForwardingRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListForwardingRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListForwardingRulesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -242,8 +261,10 @@ def post_list( def pre_patch( self, request: compute.PatchForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -263,8 +284,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -284,8 +307,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_set_target( self, request: compute.SetTargetForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetTargetForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetTargetForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_target Override in a subclass to manipulate the request or metadata @@ -427,7 +452,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]]] = (), ) -> compute.ForwardingRuleAggregatedList: r"""Call the aggregated list method over HTTP. @@ -439,8 +464,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: ~.compute.ForwardingRuleAggregatedList: @@ -450,6 +477,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseForwardingRulesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -460,6 +488,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 = 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.compute_v1.ForwardingRulesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._AggregatedList._get_response( self._host, @@ -480,7 +535,31 @@ def __call__( pb_resp = compute.ForwardingRuleAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ForwardingRuleAggregatedList.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.compute_v1.ForwardingRulesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -517,7 +596,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -529,8 +608,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: ~.compute.Operation: @@ -557,6 +638,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseForwardingRulesRestTransport._BaseDelete._get_transcoded_request( @@ -571,6 +653,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.compute_v1.ForwardingRulesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._Delete._get_response( self._host, @@ -591,7 +700,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ForwardingRulesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseForwardingRulesRestTransport._BaseGet, ForwardingRulesRestStub): @@ -626,7 +757,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]]] = (), ) -> compute.ForwardingRule: r"""Call the get method over HTTP. @@ -638,8 +769,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: ~.compute.ForwardingRule: @@ -661,6 +794,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseForwardingRulesRestTransport._BaseGet._get_transcoded_request( @@ -675,6 +809,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.compute_v1.ForwardingRulesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._Get._get_response( self._host, @@ -695,7 +856,29 @@ def __call__( pb_resp = compute.ForwardingRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ForwardingRule.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.compute_v1.ForwardingRulesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -733,7 +916,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -745,8 +928,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: ~.compute.Operation: @@ -773,6 +958,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseForwardingRulesRestTransport._BaseInsert._get_transcoded_request( @@ -791,6 +977,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.compute_v1.ForwardingRulesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._Insert._get_response( self._host, @@ -812,7 +1025,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ForwardingRulesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseForwardingRulesRestTransport._BaseList, ForwardingRulesRestStub): @@ -847,7 +1082,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]]] = (), ) -> compute.ForwardingRuleList: r"""Call the list method over HTTP. @@ -859,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: ~.compute.ForwardingRuleList: @@ -872,6 +1109,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseForwardingRulesRestTransport._BaseList._get_transcoded_request( @@ -886,6 +1124,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.compute_v1.ForwardingRulesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._List._get_response( self._host, @@ -906,7 +1171,29 @@ def __call__( pb_resp = compute.ForwardingRuleList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ForwardingRuleList.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.compute_v1.ForwardingRulesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseForwardingRulesRestTransport._BasePatch, ForwardingRulesRestStub): @@ -942,7 +1229,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -954,8 +1241,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: ~.compute.Operation: @@ -982,6 +1271,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseForwardingRulesRestTransport._BasePatch._get_transcoded_request( @@ -1000,6 +1290,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.compute_v1.ForwardingRulesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._Patch._get_response( self._host, @@ -1021,7 +1338,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ForwardingRulesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1059,7 +1398,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1071,8 +1410,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: ~.compute.Operation: @@ -1099,6 +1440,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseForwardingRulesRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -1117,6 +1459,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.compute_v1.ForwardingRulesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._SetLabels._get_response( self._host, @@ -1138,7 +1507,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ForwardingRulesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetTarget( @@ -1176,7 +1567,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]]] = (), ) -> compute.Operation: r"""Call the set target method over HTTP. @@ -1188,8 +1579,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: ~.compute.Operation: @@ -1216,6 +1609,7 @@ def __call__( http_options = ( _BaseForwardingRulesRestTransport._BaseSetTarget._get_http_options() ) + request, metadata = self._interceptor.pre_set_target(request, metadata) transcoded_request = _BaseForwardingRulesRestTransport._BaseSetTarget._get_transcoded_request( http_options, request @@ -1234,6 +1628,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.compute_v1.ForwardingRulesClient.SetTarget", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "SetTarget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ForwardingRulesRestTransport._SetTarget._get_response( self._host, @@ -1255,7 +1676,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_target(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ForwardingRulesClient.set_target", + extra={ + "serviceName": "google.cloud.compute.v1.ForwardingRules", + "rpcName": "SetTarget", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/client.py index 116ff97f44f1..2fcf027c8bec 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.global_addresses import pagers @@ -560,6 +570,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( @@ -625,6 +639,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.compute_v1.GlobalAddressesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "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.compute.v1.GlobalAddresses", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteGlobalAddressRequest, dict]] = None, @@ -633,7 +670,7 @@ def delete_unary( address: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified address resource. @@ -684,8 +721,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -751,7 +790,7 @@ def delete( address: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified address resource. @@ -802,8 +841,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -893,7 +934,7 @@ def get( address: 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]]] = (), ) -> compute.Address: r"""Returns the specified address resource. @@ -944,8 +985,10 @@ def sample_get(): 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.compute_v1.types.Address: @@ -1016,7 +1059,7 @@ def insert_unary( address_resource: Optional[compute.Address] = 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]]] = (), ) -> compute.Operation: r"""Creates an address resource in the specified project by using the data included in the request. @@ -1065,8 +1108,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1127,7 +1172,7 @@ def insert( address_resource: Optional[compute.Address] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an address resource in the specified project by using the data included in the request. @@ -1176,8 +1221,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1261,7 +1308,7 @@ def list( project: 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.ListPager: r"""Retrieves a list of global addresses. @@ -1305,8 +1352,10 @@ def sample_list(): 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.compute_v1.services.global_addresses.pagers.ListPager: @@ -1382,7 +1431,7 @@ def move_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Moves the specified address resource from one project to another project. @@ -1439,8 +1488,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -1515,7 +1566,7 @@ def move( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Moves the specified address resource from one project to another project. @@ -1572,8 +1623,10 @@ def sample_move(): 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.api_core.extended_operation.ExtendedOperation: @@ -1672,7 +1725,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. @@ -1729,8 +1782,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1805,7 +1860,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. @@ -1862,8 +1917,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/pagers.py index 4ca4e68698c8..4477cd93abea 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/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 = compute.ListGlobalAddressesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/transports/rest.py index 2ca145bf5a39..d2110ebc0102 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_addresses/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_set_labels(self, response): def pre_delete( self, request: compute.DeleteGlobalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteGlobalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteGlobalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -138,8 +148,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetGlobalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetGlobalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetGlobalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -159,8 +171,10 @@ def post_get(self, response: compute.Address) -> compute.Address: def pre_insert( self, request: compute.InsertGlobalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertGlobalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertGlobalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -180,8 +194,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalAddressesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListGlobalAddressesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListGlobalAddressesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -201,8 +217,10 @@ def post_list(self, response: compute.AddressList) -> compute.AddressList: def pre_move( self, request: compute.MoveGlobalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.MoveGlobalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.MoveGlobalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for move Override in a subclass to manipulate the request or metadata @@ -222,8 +240,10 @@ def post_move(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsGlobalAddressRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsGlobalAddressRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsGlobalAddressRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -365,7 +385,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -377,8 +397,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: ~.compute.Operation: @@ -405,6 +427,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseGlobalAddressesRestTransport._BaseDelete._get_transcoded_request( @@ -419,6 +442,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.compute_v1.GlobalAddressesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._Delete._get_response( self._host, @@ -439,7 +489,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalAddressesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseGlobalAddressesRestTransport._BaseGet, GlobalAddressesRestStub): @@ -474,7 +546,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]]] = (), ) -> compute.Address: r"""Call the get method over HTTP. @@ -486,8 +558,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: ~.compute.Address: @@ -504,6 +578,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseGlobalAddressesRestTransport._BaseGet._get_transcoded_request( @@ -518,6 +593,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.compute_v1.GlobalAddressesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._Get._get_response( self._host, @@ -538,7 +640,29 @@ def __call__( pb_resp = compute.Address.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Address.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.compute_v1.GlobalAddressesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -576,7 +700,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -588,8 +712,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: ~.compute.Operation: @@ -616,6 +742,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseGlobalAddressesRestTransport._BaseInsert._get_transcoded_request( @@ -634,6 +761,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.compute_v1.GlobalAddressesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._Insert._get_response( self._host, @@ -655,7 +809,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalAddressesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseGlobalAddressesRestTransport._BaseList, GlobalAddressesRestStub): @@ -690,7 +866,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]]] = (), ) -> compute.AddressList: r"""Call the list method over HTTP. @@ -702,8 +878,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: ~.compute.AddressList: @@ -713,6 +891,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseGlobalAddressesRestTransport._BaseList._get_transcoded_request( @@ -727,6 +906,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.compute_v1.GlobalAddressesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._List._get_response( self._host, @@ -747,7 +953,29 @@ def __call__( pb_resp = compute.AddressList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.AddressList.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.compute_v1.GlobalAddressesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Move(_BaseGlobalAddressesRestTransport._BaseMove, GlobalAddressesRestStub): @@ -783,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]]] = (), ) -> compute.Operation: r"""Call the move method over HTTP. @@ -795,8 +1023,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: ~.compute.Operation: @@ -823,6 +1053,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseMove._get_http_options() ) + request, metadata = self._interceptor.pre_move(request, metadata) transcoded_request = ( _BaseGlobalAddressesRestTransport._BaseMove._get_transcoded_request( @@ -841,6 +1072,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.compute_v1.GlobalAddressesClient.Move", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Move", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._Move._get_response( self._host, @@ -862,7 +1120,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalAddressesClient.move", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "Move", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -900,7 +1180,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -912,8 +1192,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: ~.compute.Operation: @@ -940,6 +1222,7 @@ def __call__( http_options = ( _BaseGlobalAddressesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseGlobalAddressesRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -958,6 +1241,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.compute_v1.GlobalAddressesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalAddressesRestTransport._SetLabels._get_response( self._host, @@ -979,7 +1289,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalAddressesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalAddresses", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/client.py index f90f59354a39..f950a5a25378 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.global_forwarding_rules import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.GlobalForwardingRulesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "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.compute.v1.GlobalForwardingRules", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -640,7 +677,7 @@ def delete_unary( forwarding_rule: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified GlobalForwardingRule resource. @@ -691,8 +728,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -760,7 +799,7 @@ def delete( forwarding_rule: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified GlobalForwardingRule resource. @@ -811,8 +850,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -902,7 +943,7 @@ def get( forwarding_rule: 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]]] = (), ) -> compute.ForwardingRule: r"""Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a @@ -955,8 +996,10 @@ def sample_get(): 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.compute_v1.types.ForwardingRule: @@ -1034,7 +1077,7 @@ def insert_unary( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> compute.Operation: r"""Creates a GlobalForwardingRule resource in the specified project using the data included in the @@ -1084,8 +1127,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1148,7 +1193,7 @@ def insert( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a GlobalForwardingRule resource in the specified project using the data included in the @@ -1198,8 +1243,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1283,7 +1330,7 @@ def list( project: 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.ListPager: r"""Retrieves a list of GlobalForwardingRule resources available to the specified project. @@ -1328,8 +1375,10 @@ def sample_list(): 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.compute_v1.services.global_forwarding_rules.pagers.ListPager: @@ -1403,7 +1452,7 @@ def patch_unary( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the @@ -1462,8 +1511,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1532,7 +1583,7 @@ def patch( forwarding_rule_resource: Optional[compute.ForwardingRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the @@ -1591,8 +1642,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1689,7 +1742,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on the specified resource. To learn more about labels, read the Labeling resources @@ -1747,8 +1800,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1825,7 +1880,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on the specified resource. To learn more about labels, read the Labeling resources @@ -1883,8 +1938,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1983,7 +2040,7 @@ def set_target_unary( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> compute.Operation: r"""Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as @@ -2041,8 +2098,10 @@ def sample_set_target(): 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.api_core.extended_operation.ExtendedOperation: @@ -2115,7 +2174,7 @@ def set_target( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as @@ -2173,8 +2232,10 @@ def sample_set_target(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/pagers.py index ba1f431c78dc..1e1001b52605 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/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 = compute.ListGlobalForwardingRulesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/transports/rest.py index 12b0bc64f3ee..ae74b87b2e59 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_forwarding_rules/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 @@ -37,6 +37,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, @@ -125,8 +133,11 @@ def post_set_target(self, response): def pre_delete( self, request: compute.DeleteGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteGlobalForwardingRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -146,8 +157,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetGlobalForwardingRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -167,8 +180,11 @@ def post_get(self, response: compute.ForwardingRule) -> compute.ForwardingRule: def pre_insert( self, request: compute.InsertGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertGlobalForwardingRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -188,8 +204,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalForwardingRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListGlobalForwardingRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListGlobalForwardingRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -211,8 +230,11 @@ def post_list( def pre_patch( self, request: compute.PatchGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchGlobalForwardingRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -232,8 +254,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsGlobalForwardingRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -253,8 +278,11 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_set_target( self, request: compute.SetTargetGlobalForwardingRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetTargetGlobalForwardingRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetTargetGlobalForwardingRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_target Override in a subclass to manipulate the request or metadata @@ -397,7 +425,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -409,8 +437,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: ~.compute.Operation: @@ -437,6 +467,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -447,6 +478,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 = 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.compute_v1.GlobalForwardingRulesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._Delete._get_response( self._host, @@ -467,7 +525,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalForwardingRulesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -504,7 +584,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]]] = (), ) -> compute.ForwardingRule: r"""Call the get method over HTTP. @@ -516,8 +596,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: ~.compute.ForwardingRule: @@ -539,6 +621,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -551,6 +634,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.compute_v1.GlobalForwardingRulesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._Get._get_response( self._host, @@ -571,7 +681,29 @@ def __call__( pb_resp = compute.ForwardingRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ForwardingRule.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.compute_v1.GlobalForwardingRulesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -610,7 +742,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -622,8 +754,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: ~.compute.Operation: @@ -650,6 +784,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -664,6 +799,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 = 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.compute_v1.GlobalForwardingRulesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._Insert._get_response( self._host, @@ -685,7 +847,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalForwardingRulesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -722,7 +906,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]]] = (), ) -> compute.ForwardingRuleList: r"""Call the list method over HTTP. @@ -734,8 +918,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: ~.compute.ForwardingRuleList: @@ -747,6 +933,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -757,6 +944,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 = 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.compute_v1.GlobalForwardingRulesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._List._get_response( self._host, @@ -777,7 +991,29 @@ def __call__( pb_resp = compute.ForwardingRuleList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ForwardingRuleList.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.compute_v1.GlobalForwardingRulesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -816,7 +1052,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -828,8 +1064,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: ~.compute.Operation: @@ -856,6 +1094,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -870,6 +1109,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 = 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.compute_v1.GlobalForwardingRulesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._Patch._get_response( self._host, @@ -891,7 +1157,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalForwardingRulesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -930,7 +1218,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -942,8 +1230,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: ~.compute.Operation: @@ -970,6 +1260,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -984,6 +1275,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 = 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.compute_v1.GlobalForwardingRulesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._SetLabels._get_response( self._host, @@ -1005,7 +1323,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalForwardingRulesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetTarget( @@ -1044,7 +1384,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]]] = (), ) -> compute.Operation: r"""Call the set target method over HTTP. @@ -1056,8 +1396,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: ~.compute.Operation: @@ -1084,6 +1426,7 @@ def __call__( http_options = ( _BaseGlobalForwardingRulesRestTransport._BaseSetTarget._get_http_options() ) + request, metadata = self._interceptor.pre_set_target(request, metadata) transcoded_request = _BaseGlobalForwardingRulesRestTransport._BaseSetTarget._get_transcoded_request( http_options, request @@ -1098,6 +1441,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 = 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.compute_v1.GlobalForwardingRulesClient.SetTarget", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "SetTarget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalForwardingRulesRestTransport._SetTarget._get_response( self._host, @@ -1119,7 +1489,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_target(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalForwardingRulesClient.set_target", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalForwardingRules", + "rpcName": "SetTarget", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/client.py index dbb29bfda564..097c349490a8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.global_network_endpoint_groups import pagers @@ -568,6 +578,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( @@ -636,6 +650,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.compute_v1.GlobalNetworkEndpointGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "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.compute.v1.GlobalNetworkEndpointGroups", + "credentialsType": None, + }, + ) + def attach_network_endpoints_unary( self, request: Optional[ @@ -649,7 +686,7 @@ def attach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Attach a network endpoint to the specified network endpoint group. @@ -708,8 +745,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -797,7 +836,7 @@ def attach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Attach a network endpoint to the specified network endpoint group. @@ -856,8 +895,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -966,7 +1007,7 @@ def delete_unary( network_endpoint_group: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend @@ -1020,8 +1061,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1089,7 +1132,7 @@ def delete( network_endpoint_group: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend @@ -1143,8 +1186,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1239,7 +1284,7 @@ def detach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Detach the network endpoint from the specified network endpoint group. @@ -1298,8 +1343,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1387,7 +1434,7 @@ def detach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Detach the network endpoint from the specified network endpoint group. @@ -1446,8 +1493,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1556,7 +1605,7 @@ def get( network_endpoint_group: 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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Returns the specified network endpoint group. @@ -1607,8 +1656,10 @@ def sample_get(): 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.compute_v1.types.NetworkEndpointGroup: @@ -1682,7 +1733,7 @@ def insert_unary( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> compute.Operation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -1732,8 +1783,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1798,7 +1851,7 @@ def insert( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -1848,8 +1901,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1937,7 +1992,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of network endpoint groups that are located in the specified project. @@ -1982,8 +2037,10 @@ def sample_list(): 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.compute_v1.services.global_network_endpoint_groups.pagers.ListPager: @@ -2056,7 +2113,7 @@ def list_network_endpoints( network_endpoint_group: 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.ListNetworkEndpointsPager: r"""Lists the network endpoints in the specified network endpoint group. @@ -2111,8 +2168,10 @@ def sample_list_network_endpoints(): 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.compute_v1.services.global_network_endpoint_groups.pagers.ListNetworkEndpointsPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/pagers.py index 34da8cb1b0c5..b3c7e2262cd1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/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 = compute.ListGlobalNetworkEndpointGroupsRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/transports/rest.py index a70b56b3e762..e9b4dfd2770f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_network_endpoint_groups/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 @@ -37,6 +37,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, @@ -125,10 +133,10 @@ def post_list_network_endpoints(self, response): def pre_attach_network_endpoints( self, request: compute.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for attach_network_endpoints @@ -151,9 +159,10 @@ def post_attach_network_endpoints( def pre_delete( self, request: compute.DeleteGlobalNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteGlobalNetworkEndpointGroupRequest, Sequence[Tuple[str, str]] + compute.DeleteGlobalNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -174,10 +183,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_detach_network_endpoints( self, request: compute.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for detach_network_endpoints @@ -200,8 +209,11 @@ def post_detach_network_endpoints( def pre_get( self, request: compute.GetGlobalNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetGlobalNetworkEndpointGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetGlobalNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -223,9 +235,10 @@ def post_get( def pre_insert( self, request: compute.InsertGlobalNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertGlobalNetworkEndpointGroupRequest, Sequence[Tuple[str, str]] + compute.InsertGlobalNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -246,9 +259,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListGlobalNetworkEndpointGroupsRequest, Sequence[Tuple[str, str]] + compute.ListGlobalNetworkEndpointGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -271,10 +285,10 @@ def post_list( def pre_list_network_endpoints( self, request: compute.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_network_endpoints @@ -425,7 +439,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]]] = (), ) -> compute.Operation: r"""Call the attach network endpoints method over HTTP. @@ -437,8 +451,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: ~.compute.Operation: @@ -465,6 +481,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseAttachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_attach_network_endpoints( request, metadata ) @@ -481,6 +498,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.AttachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._AttachNetworkEndpoints._get_response( self._host, @@ -502,7 +546,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_attach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalNetworkEndpointGroupsClient.attach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -540,7 +606,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -552,8 +618,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: ~.compute.Operation: @@ -580,6 +648,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseGlobalNetworkEndpointGroupsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -590,6 +659,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._Delete._get_response( self._host, @@ -610,7 +706,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalNetworkEndpointGroupsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetachNetworkEndpoints( @@ -651,7 +769,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]]] = (), ) -> compute.Operation: r"""Call the detach network endpoints method over HTTP. @@ -663,8 +781,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: ~.compute.Operation: @@ -691,6 +811,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseDetachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_detach_network_endpoints( request, metadata ) @@ -707,6 +828,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.DetachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._DetachNetworkEndpoints._get_response( self._host, @@ -728,7 +876,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalNetworkEndpointGroupsClient.detach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -766,7 +936,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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Call the get method over HTTP. @@ -778,8 +948,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: ~.compute.NetworkEndpointGroup: @@ -797,6 +969,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseGlobalNetworkEndpointGroupsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -807,6 +980,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._Get._get_response( self._host, @@ -827,7 +1027,29 @@ def __call__( pb_resp = compute.NetworkEndpointGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroup.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.compute_v1.GlobalNetworkEndpointGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -866,7 +1088,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -878,8 +1100,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: ~.compute.Operation: @@ -906,6 +1130,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseGlobalNetworkEndpointGroupsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -920,6 +1145,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._Insert._get_response( self._host, @@ -941,7 +1193,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalNetworkEndpointGroupsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -979,7 +1253,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]]] = (), ) -> compute.NetworkEndpointGroupList: r"""Call the list method over HTTP. @@ -991,8 +1265,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: ~.compute.NetworkEndpointGroupList: @@ -1002,6 +1278,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseGlobalNetworkEndpointGroupsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1012,6 +1289,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._List._get_response( self._host, @@ -1032,7 +1336,31 @@ def __call__( pb_resp = compute.NetworkEndpointGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroupList.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.compute_v1.GlobalNetworkEndpointGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkEndpoints( @@ -1070,7 +1398,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]]] = (), ) -> compute.NetworkEndpointGroupsListNetworkEndpoints: r"""Call the list network endpoints method over HTTP. @@ -1082,8 +1410,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: ~.compute.NetworkEndpointGroupsListNetworkEndpoints: @@ -1093,6 +1423,7 @@ def __call__( http_options = ( _BaseGlobalNetworkEndpointGroupsRestTransport._BaseListNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_endpoints( request, metadata ) @@ -1105,6 +1436,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 = 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.compute_v1.GlobalNetworkEndpointGroupsClient.ListNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalNetworkEndpointGroupsRestTransport._ListNetworkEndpoints._get_response( self._host, @@ -1125,7 +1483,33 @@ def __call__( pb_resp = compute.NetworkEndpointGroupsListNetworkEndpoints.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkEndpointGroupsListNetworkEndpoints.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.compute_v1.GlobalNetworkEndpointGroupsClient.list_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalNetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/client.py index 658858c6c7d8..a1223f9a9418 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/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.compute_v1.services.global_operations import pagers from google.cloud.compute_v1.types import compute @@ -557,6 +567,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( @@ -623,6 +637,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.compute_v1.GlobalOperationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "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.compute.v1.GlobalOperations", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -632,7 +669,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the @@ -678,8 +715,10 @@ def sample_aggregated_list(): 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.compute_v1.services.global_operations.pagers.AggregatedListPager: @@ -750,7 +789,7 @@ def delete( operation: 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]]] = (), ) -> compute.DeleteGlobalOperationResponse: r"""Deletes the specified Operations resource. @@ -802,8 +841,10 @@ def sample_delete(): 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.compute_v1.types.DeleteGlobalOperationResponse: @@ -870,7 +911,7 @@ def get( operation: 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]]] = (), ) -> compute.Operation: r"""Retrieves the specified Operations resource. @@ -922,8 +963,10 @@ def sample_get(): 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.compute_v1.types.Operation: @@ -1003,7 +1046,7 @@ def list( project: 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.ListPager: r"""Retrieves a list of Operation resources contained within the specified project. @@ -1048,8 +1091,10 @@ def sample_list(): 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.compute_v1.services.global_operations.pagers.ListPager: @@ -1122,7 +1167,7 @@ def wait( operation: 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]]] = (), ) -> compute.Operation: r"""Waits for the specified Operation resource to return as ``DONE`` or for the request to approach the 2 minute deadline, and @@ -1186,8 +1231,10 @@ def sample_wait(): 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.compute_v1.types.Operation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/pagers.py index dfb228a93aa9..8ace7233da0e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/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 = compute.AggregatedListGlobalOperationsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListGlobalOperationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/transports/rest.py index c67b297bcceb..f7ca4bae9469 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_operations/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 @@ -37,6 +37,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, @@ -109,9 +117,10 @@ def post_wait(self, response): def pre_aggregated_list( self, request: compute.AggregatedListGlobalOperationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListGlobalOperationsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListGlobalOperationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -134,8 +143,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteGlobalOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteGlobalOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteGlobalOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -157,8 +168,10 @@ def post_delete( def pre_get( self, request: compute.GetGlobalOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetGlobalOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetGlobalOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -178,8 +191,10 @@ def post_get(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListGlobalOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListGlobalOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -199,8 +214,10 @@ def post_list(self, response: compute.OperationList) -> compute.OperationList: def pre_wait( self, request: compute.WaitGlobalOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.WaitGlobalOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.WaitGlobalOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait Override in a subclass to manipulate the request or metadata @@ -342,7 +359,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]]] = (), ) -> compute.OperationAggregatedList: r"""Call the aggregated list method over HTTP. @@ -354,8 +371,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: ~.compute.OperationAggregatedList: @@ -365,6 +384,7 @@ def __call__( http_options = ( _BaseGlobalOperationsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseGlobalOperationsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -375,6 +395,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 = 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.compute_v1.GlobalOperationsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOperationsRestTransport._AggregatedList._get_response( self._host, @@ -395,7 +442,29 @@ def __call__( pb_resp = compute.OperationAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.OperationAggregatedList.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.compute_v1.GlobalOperationsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -432,7 +501,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]]] = (), ) -> compute.DeleteGlobalOperationResponse: r"""Call the delete method over HTTP. @@ -444,8 +513,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: ~.compute.DeleteGlobalOperationResponse: @@ -458,6 +529,7 @@ def __call__( http_options = ( _BaseGlobalOperationsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseGlobalOperationsRestTransport._BaseDelete._get_transcoded_request( @@ -472,6 +544,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.compute_v1.GlobalOperationsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOperationsRestTransport._Delete._get_response( self._host, @@ -492,7 +591,31 @@ def __call__( pb_resp = compute.DeleteGlobalOperationResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DeleteGlobalOperationResponse.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.compute_v1.GlobalOperationsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseGlobalOperationsRestTransport._BaseGet, GlobalOperationsRestStub): @@ -527,7 +650,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]]] = (), ) -> compute.Operation: r"""Call the get method over HTTP. @@ -539,8 +662,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: ~.compute.Operation: @@ -567,6 +692,7 @@ def __call__( http_options = ( _BaseGlobalOperationsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseGlobalOperationsRestTransport._BaseGet._get_transcoded_request( @@ -581,6 +707,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.compute_v1.GlobalOperationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOperationsRestTransport._Get._get_response( self._host, @@ -601,7 +754,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalOperationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseGlobalOperationsRestTransport._BaseList, GlobalOperationsRestStub): @@ -636,7 +811,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]]] = (), ) -> compute.OperationList: r"""Call the list method over HTTP. @@ -648,8 +823,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: ~.compute.OperationList: @@ -661,6 +838,7 @@ def __call__( http_options = ( _BaseGlobalOperationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseGlobalOperationsRestTransport._BaseList._get_transcoded_request( @@ -675,6 +853,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.compute_v1.GlobalOperationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOperationsRestTransport._List._get_response( self._host, @@ -695,7 +900,29 @@ def __call__( pb_resp = compute.OperationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.OperationList.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.compute_v1.GlobalOperationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Wait(_BaseGlobalOperationsRestTransport._BaseWait, GlobalOperationsRestStub): @@ -730,7 +957,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]]] = (), ) -> compute.Operation: r"""Call the wait method over HTTP. @@ -742,8 +969,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: ~.compute.Operation: @@ -770,6 +999,7 @@ def __call__( http_options = ( _BaseGlobalOperationsRestTransport._BaseWait._get_http_options() ) + request, metadata = self._interceptor.pre_wait(request, metadata) transcoded_request = ( _BaseGlobalOperationsRestTransport._BaseWait._get_transcoded_request( @@ -784,6 +1014,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.compute_v1.GlobalOperationsClient.Wait", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Wait", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOperationsRestTransport._Wait._get_response( self._host, @@ -804,7 +1061,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_wait(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalOperationsClient.wait", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOperations", + "rpcName": "Wait", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/client.py index cac7229cc72f..9713ec40bd5c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/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.compute_v1.services.global_organization_operations import pagers from google.cloud.compute_v1.types import compute @@ -565,6 +575,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( @@ -635,6 +649,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.compute_v1.GlobalOrganizationOperationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "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.compute.v1.GlobalOrganizationOperations", + "credentialsType": None, + }, + ) + def delete( self, request: Optional[ @@ -644,7 +681,7 @@ def delete( operation: 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]]] = (), ) -> compute.DeleteGlobalOrganizationOperationResponse: r"""Deletes the specified Operations resource. @@ -690,8 +727,10 @@ def sample_delete(): 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.compute_v1.types.DeleteGlobalOrganizationOperationResponse: @@ -754,7 +793,7 @@ def get( operation: 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]]] = (), ) -> compute.Operation: r"""Retrieves the specified Operations resource. Gets a list of operations by making a ``list()`` request. @@ -801,8 +840,10 @@ def sample_get(): 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.compute_v1.types.Operation: @@ -878,7 +919,7 @@ def list( *, 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.ListPager: r"""Retrieves a list of Operation resources contained within the specified organization. @@ -917,8 +958,10 @@ def sample_list(): 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.compute_v1.services.global_organization_operations.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/pagers.py index e4dfba501fb5..5bc1f3593ace 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/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 = compute.ListGlobalOrganizationOperationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/transports/rest.py index 790801b9ad94..f84931824737 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_organization_operations/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 @@ -37,6 +37,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, @@ -93,9 +101,10 @@ def post_list(self, response): def pre_delete( self, request: compute.DeleteGlobalOrganizationOperationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteGlobalOrganizationOperationRequest, Sequence[Tuple[str, str]] + compute.DeleteGlobalOrganizationOperationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -118,9 +127,10 @@ def post_delete( def pre_get( self, request: compute.GetGlobalOrganizationOperationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetGlobalOrganizationOperationRequest, Sequence[Tuple[str, str]] + compute.GetGlobalOrganizationOperationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get @@ -141,9 +151,10 @@ def post_get(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalOrganizationOperationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListGlobalOrganizationOperationsRequest, Sequence[Tuple[str, str]] + compute.ListGlobalOrganizationOperationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -289,7 +300,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]]] = (), ) -> compute.DeleteGlobalOrganizationOperationResponse: r"""Call the delete method over HTTP. @@ -301,8 +312,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: ~.compute.DeleteGlobalOrganizationOperationResponse: @@ -315,6 +328,7 @@ def __call__( http_options = ( _BaseGlobalOrganizationOperationsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseGlobalOrganizationOperationsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -325,6 +339,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 = 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.compute_v1.GlobalOrganizationOperationsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOrganizationOperationsRestTransport._Delete._get_response( self._host, @@ -345,7 +386,33 @@ def __call__( pb_resp = compute.DeleteGlobalOrganizationOperationResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.DeleteGlobalOrganizationOperationResponse.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.compute_v1.GlobalOrganizationOperationsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -383,7 +450,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]]] = (), ) -> compute.Operation: r"""Call the get method over HTTP. @@ -395,8 +462,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: ~.compute.Operation: @@ -423,6 +492,7 @@ def __call__( http_options = ( _BaseGlobalOrganizationOperationsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseGlobalOrganizationOperationsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -433,6 +503,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 = 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.compute_v1.GlobalOrganizationOperationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOrganizationOperationsRestTransport._Get._get_response( self._host, @@ -453,7 +550,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalOrganizationOperationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -491,7 +610,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]]] = (), ) -> compute.OperationList: r"""Call the list method over HTTP. @@ -503,8 +622,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: ~.compute.OperationList: @@ -516,6 +637,7 @@ def __call__( http_options = ( _BaseGlobalOrganizationOperationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseGlobalOrganizationOperationsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -526,6 +648,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 = 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.compute_v1.GlobalOrganizationOperationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalOrganizationOperationsRestTransport._List._get_response( self._host, @@ -546,7 +695,29 @@ def __call__( pb_resp = compute.OperationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.OperationList.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.compute_v1.GlobalOrganizationOperationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalOrganizationOperations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/client.py index f085b6f6112f..a03981a443fb 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.global_public_delegated_prefixes import pagers @@ -570,6 +580,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( @@ -640,6 +654,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.compute_v1.GlobalPublicDelegatedPrefixesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "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.compute.v1.GlobalPublicDelegatedPrefixes", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -650,7 +687,7 @@ def delete_unary( public_delegated_prefix: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified global PublicDelegatedPrefix. @@ -701,8 +738,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -770,7 +809,7 @@ def delete( public_delegated_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified global PublicDelegatedPrefix. @@ -821,8 +860,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -914,7 +955,7 @@ def get( public_delegated_prefix: 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]]] = (), ) -> compute.PublicDelegatedPrefix: r"""Returns the specified global PublicDelegatedPrefix resource. @@ -966,8 +1007,10 @@ def sample_get(): 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.compute_v1.types.PublicDelegatedPrefix: @@ -1044,7 +1087,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included @@ -1094,8 +1137,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1162,7 +1207,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included @@ -1212,8 +1257,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1301,7 +1348,7 @@ def list( project: 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.ListPager: r"""Lists the global PublicDelegatedPrefixes for a project. @@ -1346,8 +1393,10 @@ def sample_list(): 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.compute_v1.services.global_public_delegated_prefixes.pagers.ListPager: @@ -1423,7 +1472,7 @@ def patch_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This @@ -1482,8 +1531,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1560,7 +1611,7 @@ def patch( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This @@ -1619,8 +1670,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/pagers.py index 141df484d756..07aa1ef8afc8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/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 = compute.ListGlobalPublicDelegatedPrefixesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/transports/rest.py index ab7c67e15d17..12aa802cb36c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/global_public_delegated_prefixes/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 @@ -37,6 +37,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, @@ -109,9 +117,10 @@ def post_patch(self, response): def pre_delete( self, request: compute.DeleteGlobalPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteGlobalPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.DeleteGlobalPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -132,9 +141,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetGlobalPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetGlobalPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.GetGlobalPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get @@ -157,9 +167,10 @@ def post_get( def pre_insert( self, request: compute.InsertGlobalPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertGlobalPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.InsertGlobalPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -180,9 +191,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListGlobalPublicDelegatedPrefixesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListGlobalPublicDelegatedPrefixesRequest, Sequence[Tuple[str, str]] + compute.ListGlobalPublicDelegatedPrefixesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -205,9 +217,10 @@ def post_list( def pre_patch( self, request: compute.PatchGlobalPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchGlobalPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.PatchGlobalPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch @@ -355,7 +368,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -367,8 +380,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: ~.compute.Operation: @@ -395,6 +410,7 @@ def __call__( http_options = ( _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -405,6 +421,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 = 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.compute_v1.GlobalPublicDelegatedPrefixesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalPublicDelegatedPrefixesRestTransport._Delete._get_response( self._host, @@ -425,7 +468,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalPublicDelegatedPrefixesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -463,7 +528,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]]] = (), ) -> compute.PublicDelegatedPrefix: r"""Call the get method over HTTP. @@ -475,8 +540,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: ~.compute.PublicDelegatedPrefix: @@ -495,6 +562,7 @@ def __call__( http_options = ( _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -505,6 +573,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 = 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.compute_v1.GlobalPublicDelegatedPrefixesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalPublicDelegatedPrefixesRestTransport._Get._get_response( self._host, @@ -525,7 +620,29 @@ def __call__( pb_resp = compute.PublicDelegatedPrefix.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicDelegatedPrefix.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.compute_v1.GlobalPublicDelegatedPrefixesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -564,7 +681,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -576,8 +693,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: ~.compute.Operation: @@ -604,6 +723,7 @@ def __call__( http_options = ( _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -618,6 +738,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 = 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.compute_v1.GlobalPublicDelegatedPrefixesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalPublicDelegatedPrefixesRestTransport._Insert._get_response( self._host, @@ -639,7 +786,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalPublicDelegatedPrefixesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -677,7 +846,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]]] = (), ) -> compute.PublicDelegatedPrefixList: r"""Call the list method over HTTP. @@ -689,8 +858,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: ~.compute.PublicDelegatedPrefixList: @@ -700,6 +871,7 @@ def __call__( http_options = ( _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseGlobalPublicDelegatedPrefixesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -710,6 +882,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 = 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.compute_v1.GlobalPublicDelegatedPrefixesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalPublicDelegatedPrefixesRestTransport._List._get_response( self._host, @@ -730,7 +929,31 @@ def __call__( pb_resp = compute.PublicDelegatedPrefixList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicDelegatedPrefixList.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.compute_v1.GlobalPublicDelegatedPrefixesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -769,7 +992,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -781,8 +1004,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: ~.compute.Operation: @@ -809,6 +1034,7 @@ def __call__( http_options = ( _BaseGlobalPublicDelegatedPrefixesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseGlobalPublicDelegatedPrefixesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -823,6 +1049,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 = 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.compute_v1.GlobalPublicDelegatedPrefixesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GlobalPublicDelegatedPrefixesRestTransport._Patch._get_response( self._host, @@ -844,7 +1097,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.GlobalPublicDelegatedPrefixesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.GlobalPublicDelegatedPrefixes", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/client.py index 35a872335d1f..6e2b31ffafba 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.health_checks import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.HealthChecksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "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.compute.v1.HealthChecks", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -627,7 +664,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all HealthCheck resources, regional and global, available to the specified project. To prevent failure, @@ -676,8 +713,10 @@ def sample_aggregated_list(): 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.compute_v1.services.health_checks.pagers.AggregatedListPager: @@ -748,7 +787,7 @@ def delete_unary( health_check: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified HealthCheck resource. @@ -799,8 +838,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -866,7 +907,7 @@ def delete( health_check: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified HealthCheck resource. @@ -917,8 +958,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1008,7 +1051,7 @@ def get( health_check: 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]]] = (), ) -> compute.HealthCheck: r"""Returns the specified HealthCheck resource. @@ -1059,8 +1102,10 @@ def sample_get(): 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.compute_v1.types.HealthCheck: @@ -1141,7 +1186,7 @@ def insert_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Creates a HealthCheck resource in the specified project using the data included in the request. @@ -1190,8 +1235,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1252,7 +1299,7 @@ def insert( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a HealthCheck resource in the specified project using the data included in the request. @@ -1301,8 +1348,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1386,7 +1435,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of HealthCheck resources available to the specified project. @@ -1431,8 +1480,10 @@ def sample_list(): 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.compute_v1.services.health_checks.pagers.ListPager: @@ -1506,7 +1557,7 @@ def patch_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. This @@ -1565,8 +1616,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1635,7 +1688,7 @@ def patch( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. This @@ -1694,8 +1747,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1788,7 +1843,7 @@ def update_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. @@ -1845,8 +1900,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1915,7 +1972,7 @@ def update( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. @@ -1972,8 +2029,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/pagers.py index 269919a8a85b..832bb5181cd6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/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 = compute.AggregatedListHealthChecksRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListHealthChecksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/transports/rest.py index 73f9a916b367..c5f43ca900b5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/health_checks/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 @@ -37,6 +37,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, @@ -125,8 +133,11 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListHealthChecksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListHealthChecksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListHealthChecksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -148,8 +159,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -169,8 +182,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -190,8 +203,10 @@ def post_get(self, response: compute.HealthCheck) -> compute.HealthCheck: def pre_insert( self, request: compute.InsertHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -211,8 +226,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListHealthChecksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListHealthChecksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListHealthChecksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -232,8 +249,10 @@ def post_list(self, response: compute.HealthCheckList) -> compute.HealthCheckLis def pre_patch( self, request: compute.PatchHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -253,8 +272,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -396,7 +417,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]]] = (), ) -> compute.HealthChecksAggregatedList: r"""Call the aggregated list method over HTTP. @@ -408,8 +429,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: ~.compute.HealthChecksAggregatedList: @@ -419,6 +442,7 @@ def __call__( http_options = ( _BaseHealthChecksRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseHealthChecksRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -429,6 +453,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 = 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.compute_v1.HealthChecksClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._AggregatedList._get_response( self._host, @@ -449,7 +500,31 @@ def __call__( pb_resp = compute.HealthChecksAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthChecksAggregatedList.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.compute_v1.HealthChecksClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseHealthChecksRestTransport._BaseDelete, HealthChecksRestStub): @@ -484,7 +559,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -496,8 +571,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: ~.compute.Operation: @@ -524,6 +601,7 @@ def __call__( http_options = ( _BaseHealthChecksRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BaseDelete._get_transcoded_request( @@ -538,6 +616,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.compute_v1.HealthChecksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._Delete._get_response( self._host, @@ -558,7 +663,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.HealthChecksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseHealthChecksRestTransport._BaseGet, HealthChecksRestStub): @@ -593,7 +720,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]]] = (), ) -> compute.HealthCheck: r"""Call the get method over HTTP. @@ -605,8 +732,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: ~.compute.HealthCheck: @@ -631,6 +760,7 @@ def __call__( """ http_options = _BaseHealthChecksRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BaseGet._get_transcoded_request( @@ -645,6 +775,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.compute_v1.HealthChecksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._Get._get_response( self._host, @@ -665,7 +822,29 @@ def __call__( pb_resp = compute.HealthCheck.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheck.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.compute_v1.HealthChecksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseHealthChecksRestTransport._BaseInsert, HealthChecksRestStub): @@ -701,7 +880,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -713,8 +892,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: ~.compute.Operation: @@ -741,6 +922,7 @@ def __call__( http_options = ( _BaseHealthChecksRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BaseInsert._get_transcoded_request( @@ -759,6 +941,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.compute_v1.HealthChecksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._Insert._get_response( self._host, @@ -780,7 +989,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.HealthChecksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseHealthChecksRestTransport._BaseList, HealthChecksRestStub): @@ -815,7 +1046,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]]] = (), ) -> compute.HealthCheckList: r"""Call the list method over HTTP. @@ -827,8 +1058,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: ~.compute.HealthCheckList: @@ -838,6 +1071,7 @@ def __call__( """ http_options = _BaseHealthChecksRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BaseList._get_transcoded_request( @@ -852,6 +1086,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.compute_v1.HealthChecksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._List._get_response( self._host, @@ -872,7 +1133,29 @@ def __call__( pb_resp = compute.HealthCheckList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheckList.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.compute_v1.HealthChecksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseHealthChecksRestTransport._BasePatch, HealthChecksRestStub): @@ -908,7 +1191,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -920,8 +1203,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: ~.compute.Operation: @@ -946,6 +1231,7 @@ def __call__( """ http_options = _BaseHealthChecksRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BasePatch._get_transcoded_request( @@ -964,6 +1250,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.compute_v1.HealthChecksClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._Patch._get_response( self._host, @@ -985,7 +1298,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.HealthChecksClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseHealthChecksRestTransport._BaseUpdate, HealthChecksRestStub): @@ -1021,7 +1356,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1033,8 +1368,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: ~.compute.Operation: @@ -1061,6 +1398,7 @@ def __call__( http_options = ( _BaseHealthChecksRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseHealthChecksRestTransport._BaseUpdate._get_transcoded_request( @@ -1079,6 +1417,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.compute_v1.HealthChecksClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HealthChecksRestTransport._Update._get_response( self._host, @@ -1100,7 +1465,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.HealthChecksClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.HealthChecks", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/client.py index 86b18ac725db..9d3f03c0d5ed 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/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.compute_v1.types import compute from .transports.base import DEFAULT_CLIENT_INFO, ImageFamilyViewsTransport @@ -556,6 +566,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( @@ -622,6 +636,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.compute_v1.ImageFamilyViewsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ImageFamilyViews", + "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.compute.v1.ImageFamilyViews", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetImageFamilyViewRequest, dict]] = None, @@ -631,7 +668,7 @@ def get( family: 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]]] = (), ) -> compute.ImageFamilyView: r"""Returns the latest image that is part of an image family, is not deprecated and is rolled out in the @@ -692,8 +729,10 @@ def sample_get(): 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.compute_v1.types.ImageFamilyView: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/transports/rest.py index a2e7cb8cbe70..f7ea98547660 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/image_family_views/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 @@ -37,6 +37,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, @@ -77,8 +85,10 @@ def post_get(self, response): def pre_get( self, request: compute.GetImageFamilyViewRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetImageFamilyViewRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetImageFamilyViewRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -218,7 +228,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]]] = (), ) -> compute.ImageFamilyView: r"""Call the get method over HTTP. @@ -230,8 +240,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: ~.compute.ImageFamilyView: @@ -241,6 +253,7 @@ def __call__( http_options = ( _BaseImageFamilyViewsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseImageFamilyViewsRestTransport._BaseGet._get_transcoded_request( @@ -255,6 +268,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.compute_v1.ImageFamilyViewsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ImageFamilyViews", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageFamilyViewsRestTransport._Get._get_response( self._host, @@ -275,7 +315,29 @@ def __call__( pb_resp = compute.ImageFamilyView.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ImageFamilyView.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.compute_v1.ImageFamilyViewsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ImageFamilyViews", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/client.py index aae696350b3b..9bc48fc557f0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.images import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.ImagesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "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.compute.v1.Images", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteImageRequest, dict]] = None, @@ -626,7 +663,7 @@ def delete_unary( image: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified image. @@ -674,8 +711,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -741,7 +780,7 @@ def delete( image: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified image. @@ -789,8 +828,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -881,7 +922,7 @@ def deprecate_unary( deprecation_status_resource: Optional[compute.DeprecationStatus] = 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]]] = (), ) -> compute.Operation: r"""Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status @@ -937,8 +978,10 @@ def sample_deprecate(): 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.api_core.extended_operation.ExtendedOperation: @@ -1007,7 +1050,7 @@ def deprecate( deprecation_status_resource: Optional[compute.DeprecationStatus] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status @@ -1063,8 +1106,10 @@ def sample_deprecate(): 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.api_core.extended_operation.ExtendedOperation: @@ -1156,7 +1201,7 @@ def get( image: 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]]] = (), ) -> compute.Image: r"""Returns the specified image. @@ -1204,8 +1249,10 @@ def sample_get(): 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.compute_v1.types.Image: @@ -1273,7 +1320,7 @@ def get_from_family( family: 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]]] = (), ) -> compute.Image: r"""Returns the latest image that is part of an image family and is not deprecated. For more information on @@ -1330,8 +1377,10 @@ def sample_get_from_family(): 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.compute_v1.types.Image: @@ -1399,7 +1448,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1451,8 +1500,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.cloud.compute_v1.types.Policy: @@ -1538,7 +1589,7 @@ def insert_unary( image_resource: Optional[compute.Image] = 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]]] = (), ) -> compute.Operation: r"""Creates an image in the specified project using the data included in the request. @@ -1586,8 +1637,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1648,7 +1701,7 @@ def insert( image_resource: Optional[compute.Image] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an image in the specified project using the data included in the request. @@ -1696,8 +1749,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1781,7 +1836,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of custom images available to the specified project. Custom images are images you create @@ -1831,8 +1886,10 @@ def sample_list(): 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.compute_v1.services.images.pagers.ListPager: @@ -1906,7 +1963,7 @@ def patch_unary( image_resource: Optional[compute.Image] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified image with the data included in the request. Only the following fields can be modified: @@ -1961,8 +2018,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2031,7 +2090,7 @@ def patch( image_resource: Optional[compute.Image] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified image with the data included in the request. Only the following fields can be modified: @@ -2086,8 +2145,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2182,7 +2243,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2239,8 +2300,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.cloud.compute_v1.types.Policy: @@ -2335,7 +2398,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. @@ -2392,8 +2455,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2468,7 +2533,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. @@ -2525,8 +2590,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2625,7 +2692,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2682,8 +2749,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/pagers.py index 9acfdf4227e7..e030bd1a7610 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/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 = compute.ListImagesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/transports/rest.py index 9e77d1f6a983..98f84f48aa20 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/images/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/images/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 @@ -37,6 +37,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, @@ -155,8 +163,10 @@ def post_test_iam_permissions(self, response): """ def pre_delete( - self, request: compute.DeleteImageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteImageRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteImageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -176,8 +186,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_deprecate( self, request: compute.DeprecateImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeprecateImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeprecateImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for deprecate Override in a subclass to manipulate the request or metadata @@ -195,8 +205,10 @@ def post_deprecate(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetImageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetImageRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetImageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -216,8 +228,10 @@ def post_get(self, response: compute.Image) -> compute.Image: def pre_get_from_family( self, request: compute.GetFromFamilyImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetFromFamilyImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetFromFamilyImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_from_family Override in a subclass to manipulate the request or metadata @@ -237,8 +251,10 @@ def post_get_from_family(self, response: compute.Image) -> compute.Image: def pre_get_iam_policy( self, request: compute.GetIamPolicyImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -256,8 +272,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: return response def pre_insert( - self, request: compute.InsertImageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertImageRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertImageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -275,8 +293,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListImagesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListImagesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListImagesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListImagesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -294,8 +314,10 @@ def post_list(self, response: compute.ImageList) -> compute.ImageList: return response def pre_patch( - self, request: compute.PatchImageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PatchImageRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PatchImageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -315,8 +337,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -336,8 +360,8 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.SetLabelsImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -357,8 +381,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -500,7 +526,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -511,8 +537,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: ~.compute.Operation: @@ -537,6 +565,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseDelete._get_transcoded_request( @@ -549,6 +578,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 = 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.compute_v1.ImagesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._Delete._get_response( self._host, @@ -569,7 +625,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ImagesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Deprecate(_BaseImagesRestTransport._BaseDeprecate, ImagesRestStub): @@ -605,7 +683,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]]] = (), ) -> compute.Operation: r"""Call the deprecate method over HTTP. @@ -617,8 +695,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: ~.compute.Operation: @@ -643,6 +723,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseDeprecate._get_http_options() + request, metadata = self._interceptor.pre_deprecate(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseDeprecate._get_transcoded_request( @@ -661,6 +742,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.compute_v1.ImagesClient.Deprecate", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Deprecate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._Deprecate._get_response( self._host, @@ -682,7 +790,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deprecate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ImagesClient.deprecate", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Deprecate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseImagesRestTransport._BaseGet, ImagesRestStub): @@ -717,7 +847,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]]] = (), ) -> compute.Image: r"""Call the get method over HTTP. @@ -728,8 +858,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: ~.compute.Image: @@ -741,6 +873,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseGet._get_transcoded_request( @@ -753,6 +886,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 = 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.compute_v1.ImagesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._Get._get_response( self._host, @@ -773,7 +933,29 @@ def __call__( pb_resp = compute.Image.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Image.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.compute_v1.ImagesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetFromFamily(_BaseImagesRestTransport._BaseGetFromFamily, ImagesRestStub): @@ -808,7 +990,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]]] = (), ) -> compute.Image: r"""Call the get from family method over HTTP. @@ -820,8 +1002,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: ~.compute.Image: @@ -835,6 +1019,7 @@ def __call__( http_options = ( _BaseImagesRestTransport._BaseGetFromFamily._get_http_options() ) + request, metadata = self._interceptor.pre_get_from_family(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseGetFromFamily._get_transcoded_request( @@ -849,6 +1034,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.compute_v1.ImagesClient.GetFromFamily", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "GetFromFamily", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._GetFromFamily._get_response( self._host, @@ -869,7 +1081,29 @@ def __call__( pb_resp = compute.Image.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_from_family(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Image.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.compute_v1.ImagesClient.get_from_family", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "GetFromFamily", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseImagesRestTransport._BaseGetIamPolicy, ImagesRestStub): @@ -904,7 +1138,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -916,8 +1150,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: ~.compute.Policy: @@ -950,6 +1186,7 @@ def __call__( http_options = ( _BaseImagesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -964,6 +1201,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.compute_v1.ImagesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._GetIamPolicy._get_response( self._host, @@ -984,7 +1248,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ImagesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseImagesRestTransport._BaseInsert, ImagesRestStub): @@ -1020,7 +1306,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1031,8 +1317,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: ~.compute.Operation: @@ -1057,6 +1345,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseInsert._get_transcoded_request( @@ -1073,6 +1362,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 = 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.compute_v1.ImagesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._Insert._get_response( self._host, @@ -1094,7 +1410,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ImagesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseImagesRestTransport._BaseList, ImagesRestStub): @@ -1129,7 +1467,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]]] = (), ) -> compute.ImageList: r"""Call the list method over HTTP. @@ -1140,8 +1478,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: ~.compute.ImageList: @@ -1149,6 +1489,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseList._get_transcoded_request( @@ -1161,6 +1502,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 = 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.compute_v1.ImagesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._List._get_response( self._host, @@ -1181,7 +1549,29 @@ def __call__( pb_resp = compute.ImageList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ImageList.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.compute_v1.ImagesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseImagesRestTransport._BasePatch, ImagesRestStub): @@ -1217,7 +1607,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1228,8 +1618,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: ~.compute.Operation: @@ -1254,6 +1646,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BasePatch._get_transcoded_request( @@ -1270,6 +1663,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 = 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.compute_v1.ImagesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._Patch._get_response( self._host, @@ -1291,7 +1711,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ImagesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseImagesRestTransport._BaseSetIamPolicy, ImagesRestStub): @@ -1327,7 +1769,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1339,8 +1781,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: ~.compute.Policy: @@ -1373,6 +1817,7 @@ def __call__( http_options = ( _BaseImagesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1391,6 +1836,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.compute_v1.ImagesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._SetIamPolicy._get_response( self._host, @@ -1412,7 +1884,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ImagesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseImagesRestTransport._BaseSetLabels, ImagesRestStub): @@ -1448,7 +1942,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1460,8 +1954,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: ~.compute.Operation: @@ -1486,6 +1982,7 @@ def __call__( """ http_options = _BaseImagesRestTransport._BaseSetLabels._get_http_options() + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseImagesRestTransport._BaseSetLabels._get_transcoded_request( @@ -1504,6 +2001,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.compute_v1.ImagesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._SetLabels._get_response( self._host, @@ -1525,7 +2049,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ImagesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1563,7 +2109,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1575,8 +2121,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: ~.compute.TestPermissionsResponse: @@ -1586,6 +2134,7 @@ def __call__( http_options = ( _BaseImagesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1606,6 +2155,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.compute_v1.ImagesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImagesRestTransport._TestIamPermissions._get_response( self._host, @@ -1627,7 +2203,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.ImagesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Images", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/client.py index 24ab6efa975d..c4ae0c53dcdd 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instance_group_manager_resize_requests import ( @@ -577,6 +587,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( @@ -650,6 +664,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.compute_v1.InstanceGroupManagerResizeRequestsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "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.compute.v1.InstanceGroupManagerResizeRequests", + "credentialsType": None, + }, + ) + def cancel_unary( self, request: Optional[ @@ -662,7 +699,7 @@ def cancel_unary( resize_request: 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]]] = (), ) -> compute.Operation: r"""Cancels the specified resize request and removes it from the queue. Cancelled resize request does no longer @@ -735,8 +772,10 @@ def sample_cancel(): 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.api_core.extended_operation.ExtendedOperation: @@ -816,7 +855,7 @@ def cancel( resize_request: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Cancels the specified resize request and removes it from the queue. Cancelled resize request does no longer @@ -889,8 +928,10 @@ def sample_cancel(): 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.api_core.extended_operation.ExtendedOperation: @@ -995,7 +1036,7 @@ def delete_unary( resize_request: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified, inactive resize request. Requests that are still active cannot be deleted. @@ -1068,8 +1109,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1149,7 +1192,7 @@ def delete( resize_request: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified, inactive resize request. Requests that are still active cannot be deleted. @@ -1222,8 +1265,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1328,7 +1373,7 @@ def get( resize_request: 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]]] = (), ) -> compute.InstanceGroupManagerResizeRequest: r"""Returns all of the details about the specified resize request. @@ -1400,8 +1445,10 @@ def sample_get(): 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.compute_v1.types.InstanceGroupManagerResizeRequest: @@ -1487,7 +1534,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates a new resize request that starts provisioning VMs immediately or queues VM creation. @@ -1556,8 +1603,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1645,7 +1694,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new resize request that starts provisioning VMs immediately or queues VM creation. @@ -1714,8 +1763,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1825,7 +1876,7 @@ def list( instance_group_manager: 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.ListPager: r"""Retrieves a list of resize requests that are contained in the managed instance group. @@ -1888,8 +1939,10 @@ def sample_list(): 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.compute_v1.services.instance_group_manager_resize_requests.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/pagers.py index 416045b694d4..d5ab16954c39 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/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 = compute.ListInstanceGroupManagerResizeRequestsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/transports/rest.py index ad0c9cc59a45..e1d4ea5d3afc 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_manager_resize_requests/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 @@ -37,6 +37,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, @@ -109,10 +117,10 @@ def post_list(self, response): def pre_cancel( self, request: compute.CancelInstanceGroupManagerResizeRequestRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.CancelInstanceGroupManagerResizeRequestRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for cancel @@ -133,10 +141,10 @@ def post_cancel(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteInstanceGroupManagerResizeRequestRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DeleteInstanceGroupManagerResizeRequestRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -157,9 +165,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInstanceGroupManagerResizeRequestRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetInstanceGroupManagerResizeRequestRequest, Sequence[Tuple[str, str]] + compute.GetInstanceGroupManagerResizeRequestRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get @@ -182,10 +191,10 @@ def post_get( def pre_insert( self, request: compute.InsertInstanceGroupManagerResizeRequestRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.InsertInstanceGroupManagerResizeRequestRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -206,9 +215,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInstanceGroupManagerResizeRequestsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListInstanceGroupManagerResizeRequestsRequest, Sequence[Tuple[str, str]] + compute.ListInstanceGroupManagerResizeRequestsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -358,7 +368,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]]] = (), ) -> compute.Operation: r"""Call the cancel method over HTTP. @@ -370,8 +380,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: ~.compute.Operation: @@ -398,6 +410,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseCancel._get_http_options() ) + request, metadata = self._interceptor.pre_cancel(request, metadata) transcoded_request = _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseCancel._get_transcoded_request( http_options, request @@ -408,6 +421,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 = 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.compute_v1.InstanceGroupManagerResizeRequestsClient.Cancel", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Cancel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagerResizeRequestsRestTransport._Cancel._get_response( @@ -430,7 +470,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagerResizeRequestsClient.cancel", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Cancel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -468,7 +530,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -480,8 +542,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: ~.compute.Operation: @@ -508,6 +572,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -518,6 +583,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 = 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.compute_v1.InstanceGroupManagerResizeRequestsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagerResizeRequestsRestTransport._Delete._get_response( @@ -540,7 +632,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagerResizeRequestsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -578,7 +692,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]]] = (), ) -> compute.InstanceGroupManagerResizeRequest: r"""Call the get method over HTTP. @@ -590,8 +704,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: ~.compute.InstanceGroupManagerResizeRequest: @@ -609,6 +725,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -619,6 +736,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 = 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.compute_v1.InstanceGroupManagerResizeRequestsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagerResizeRequestsRestTransport._Get._get_response( @@ -641,7 +785,31 @@ def __call__( pb_resp = compute.InstanceGroupManagerResizeRequest.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstanceGroupManagerResizeRequest.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.compute_v1.InstanceGroupManagerResizeRequestsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -680,7 +848,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -692,8 +860,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: ~.compute.Operation: @@ -720,6 +890,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -734,6 +905,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 = 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.compute_v1.InstanceGroupManagerResizeRequestsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagerResizeRequestsRestTransport._Insert._get_response( @@ -757,7 +955,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagerResizeRequestsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -795,7 +1015,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]]] = (), ) -> compute.InstanceGroupManagerResizeRequestsListResponse: r"""Call the list method over HTTP. @@ -807,8 +1027,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: ~.compute.InstanceGroupManagerResizeRequestsListResponse: @@ -818,6 +1040,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseInstanceGroupManagerResizeRequestsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -828,6 +1051,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 = 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.compute_v1.InstanceGroupManagerResizeRequestsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagerResizeRequestsRestTransport._List._get_response( @@ -850,7 +1100,33 @@ def __call__( pb_resp = compute.InstanceGroupManagerResizeRequestsListResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstanceGroupManagerResizeRequestsListResponse.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.compute_v1.InstanceGroupManagerResizeRequestsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagerResizeRequests", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/client.py index 59c234a1629e..f06aca9cd640 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instance_group_managers import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.InstanceGroupManagersClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "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.compute.v1.InstanceGroupManagers", + "credentialsType": None, + }, + ) + def abandon_instances_unary( self, request: Optional[ @@ -644,7 +681,7 @@ def abandon_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not @@ -723,8 +760,10 @@ def sample_abandon_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -810,7 +849,7 @@ def abandon_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not @@ -889,8 +928,10 @@ def sample_abandon_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -996,7 +1037,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of managed instance groups and groups them by zone. To prevent failure, Google recommends that you set the @@ -1042,8 +1083,10 @@ def sample_aggregated_list(): 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.compute_v1.services.instance_group_managers.pagers.AggregatedListPager: @@ -1120,7 +1163,7 @@ def apply_updates_to_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Applies changes to selected instances on the managed instance group. This method can be used to apply new @@ -1187,8 +1230,10 @@ def sample_apply_updates_to_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1280,7 +1325,7 @@ def apply_updates_to_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Applies changes to selected instances on the managed instance group. This method can be used to apply new @@ -1347,8 +1392,10 @@ def sample_apply_updates_to_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1465,7 +1512,7 @@ def create_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates instances with per-instance configurations in this managed instance group. Instances are created using @@ -1537,8 +1584,10 @@ def sample_create_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1624,7 +1673,7 @@ def create_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates instances with per-instance configurations in this managed instance group. Instances are created using @@ -1696,8 +1745,10 @@ def sample_create_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1805,7 +1856,7 @@ def delete_unary( instance_group_manager: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified managed instance group and all of the instances in that group. Note that the instance @@ -1867,8 +1918,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1940,7 +1993,7 @@ def delete( instance_group_manager: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified managed instance group and all of the instances in that group. Note that the instance @@ -2002,8 +2055,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -2103,7 +2158,7 @@ def delete_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified instances in the managed instance group for immediate deletion. The instances are also @@ -2181,8 +2236,10 @@ def sample_delete_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2268,7 +2325,7 @@ def delete_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified instances in the managed instance group for immediate deletion. The instances are also @@ -2346,8 +2403,10 @@ def sample_delete_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2458,7 +2517,7 @@ def delete_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Deletes selected per-instance configurations for the managed instance group. @@ -2524,8 +2583,10 @@ def sample_delete_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -2620,7 +2681,7 @@ def delete_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes selected per-instance configurations for the managed instance group. @@ -2686,8 +2747,10 @@ def sample_delete_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -2802,7 +2865,7 @@ def get( instance_group_manager: 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]]] = (), ) -> compute.InstanceGroupManager: r"""Returns all of the details about the specified managed instance group. @@ -2862,8 +2925,10 @@ def sample_get(): 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.compute_v1.types.InstanceGroupManager: @@ -2942,7 +3007,7 @@ def insert_unary( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> compute.Operation: r"""Creates a managed instance group using the information that you specify in the request. After the @@ -3008,8 +3073,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -3082,7 +3149,7 @@ def insert( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a managed instance group using the information that you specify in the request. After the @@ -3148,8 +3215,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -3244,7 +3313,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of managed instance groups that are contained within the specified project and zone. @@ -3297,8 +3366,10 @@ def sample_list(): 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.compute_v1.services.instance_group_managers.pagers.ListPager: @@ -3380,7 +3451,7 @@ def list_errors( instance_group_manager: 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.ListErrorsPager: r"""Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy @@ -3445,8 +3516,10 @@ def sample_list_errors(): 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.compute_v1.services.instance_group_managers.pagers.ListErrorsPager: @@ -3530,7 +3603,7 @@ def list_managed_instances( instance_group_manager: 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.ListManagedInstancesPager: r"""Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the @@ -3598,8 +3671,10 @@ def sample_list_managed_instances(): 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.compute_v1.services.instance_group_managers.pagers.ListManagedInstancesPager: @@ -3685,7 +3760,7 @@ def list_per_instance_configs( instance_group_manager: 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.ListPerInstanceConfigsPager: r"""Lists all of the per-instance configurations defined for the managed instance group. The orderBy query @@ -3748,8 +3823,10 @@ def sample_list_per_instance_configs(): 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.compute_v1.services.instance_group_managers.pagers.ListPerInstanceConfigsPager: @@ -3838,7 +3915,7 @@ def patch_unary( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> compute.Operation: r"""Updates a managed instance group using the information that you specify in the request. This @@ -3915,8 +3992,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -3993,7 +4072,7 @@ def patch( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a managed instance group using the information that you specify in the request. This @@ -4070,8 +4149,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -4177,7 +4258,7 @@ def patch_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name @@ -4245,8 +4326,10 @@ def sample_patch_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -4341,7 +4424,7 @@ def patch_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name @@ -4409,8 +4492,10 @@ def sample_patch_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -4530,7 +4615,7 @@ def recreate_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified VM instances in the managed instance group to be immediately recreated. Each @@ -4607,8 +4692,10 @@ def sample_recreate_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -4696,7 +4783,7 @@ def recreate_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified VM instances in the managed instance group to be immediately recreated. Each @@ -4773,8 +4860,10 @@ def sample_recreate_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -4885,7 +4974,7 @@ def resize_unary( size: Optional[int] = 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]]] = (), ) -> compute.Operation: r"""Resizes the managed instance group. If you increase the size, the group creates new instances using the @@ -4975,8 +5064,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -5051,7 +5142,7 @@ def resize( size: Optional[int] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Resizes the managed instance group. If you increase the size, the group creates new instances using the @@ -5141,8 +5232,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -5230,27 +5323,39 @@ def error_code(self): # Done; return the response. return response - def set_instance_template_unary( + def resume_instances_unary( self, request: Optional[ - Union[compute.SetInstanceTemplateInstanceGroupManagerRequest, dict] + Union[compute.ResumeInstancesInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, zone: Optional[str] = None, instance_group_manager: Optional[str] = None, - instance_group_managers_set_instance_template_request_resource: Optional[ - compute.InstanceGroupManagersSetInstanceTemplateRequest + instance_group_managers_resume_instances_request_resource: Optional[ + compute.InstanceGroupManagersResumeInstancesRequest ] = 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]]] = (), ) -> compute.Operation: - r"""Specifies the instance template to use when creating - new instances in this group. The templates for existing - instances in the group do not change unless you run - recreateInstances, run applyUpdatesToInstances, or set - the group's updatePolicy.type to PROACTIVE. + r"""Flags the specified instances in the managed instance + group to be resumed. This method increases the + targetSize and decreases the targetSuspendedSize of the + managed instance group by the number of instances that + you resume. The resumeInstances operation is marked DONE + if the resumeInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the RESUMING action with + the listmanagedinstances method. In this request, you + can only specify instances that are suspended. For + example, if an instance was previously suspended using + the suspendInstances method, it can be resumed using the + resumeInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are resumed. You can + specify a maximum of 1000 instances with this method per + request. .. code-block:: python @@ -5263,27 +5368,27 @@ def set_instance_template_unary( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_instance_template(): + def sample_resume_instances(): # Create a client client = compute_v1.InstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetInstanceTemplateInstanceGroupManagerRequest( + request = compute_v1.ResumeInstancesInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", zone="zone_value", ) # Make the request - response = client.set_instance_template(request=request) + response = client.resume_instances(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.ResumeInstancesInstanceGroupManagerRequest, dict]): The request object. A request message for - InstanceGroupManagers.SetInstanceTemplate. + InstanceGroupManagers.ResumeInstances. See the method description for details. project (str): Project ID for this request. @@ -5304,16 +5409,18 @@ def sample_set_instance_template(): This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance_group_managers_set_instance_template_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest): + instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersResumeInstancesRequest): The body resource for this request - This corresponds to the ``instance_group_managers_set_instance_template_request_resource`` field + This corresponds to the ``instance_group_managers_resume_instances_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5329,7 +5436,7 @@ def sample_set_instance_template(): project, zone, instance_group_manager, - instance_group_managers_set_instance_template_request_resource, + instance_group_managers_resume_instances_request_resource, ] ) if request is not None and has_flattened_params: @@ -5340,10 +5447,8 @@ def sample_set_instance_template(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance( - request, compute.SetInstanceTemplateInstanceGroupManagerRequest - ): - request = compute.SetInstanceTemplateInstanceGroupManagerRequest(request) + if not isinstance(request, compute.ResumeInstancesInstanceGroupManagerRequest): + request = compute.ResumeInstancesInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5352,17 +5457,14 @@ def sample_set_instance_template(): request.zone = zone if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if ( - instance_group_managers_set_instance_template_request_resource - is not None - ): - request.instance_group_managers_set_instance_template_request_resource = ( - instance_group_managers_set_instance_template_request_resource + if instance_group_managers_resume_instances_request_resource is not None: + request.instance_group_managers_resume_instances_request_resource = ( + instance_group_managers_resume_instances_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + rpc = self._transport._wrapped_methods[self._transport.resume_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5390,27 +5492,39 @@ def sample_set_instance_template(): # Done; return the response. return response - def set_instance_template( + def resume_instances( self, request: Optional[ - Union[compute.SetInstanceTemplateInstanceGroupManagerRequest, dict] + Union[compute.ResumeInstancesInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, zone: Optional[str] = None, instance_group_manager: Optional[str] = None, - instance_group_managers_set_instance_template_request_resource: Optional[ - compute.InstanceGroupManagersSetInstanceTemplateRequest + instance_group_managers_resume_instances_request_resource: Optional[ + compute.InstanceGroupManagersResumeInstancesRequest ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: - r"""Specifies the instance template to use when creating - new instances in this group. The templates for existing - instances in the group do not change unless you run - recreateInstances, run applyUpdatesToInstances, or set - the group's updatePolicy.type to PROACTIVE. + r"""Flags the specified instances in the managed instance + group to be resumed. This method increases the + targetSize and decreases the targetSuspendedSize of the + managed instance group by the number of instances that + you resume. The resumeInstances operation is marked DONE + if the resumeInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the RESUMING action with + the listmanagedinstances method. In this request, you + can only specify instances that are suspended. For + example, if an instance was previously suspended using + the suspendInstances method, it can be resumed using the + resumeInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are resumed. You can + specify a maximum of 1000 instances with this method per + request. .. code-block:: python @@ -5423,27 +5537,27 @@ def set_instance_template( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_instance_template(): + def sample_resume_instances(): # Create a client client = compute_v1.InstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetInstanceTemplateInstanceGroupManagerRequest( + request = compute_v1.ResumeInstancesInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", zone="zone_value", ) # Make the request - response = client.set_instance_template(request=request) + response = client.resume_instances(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.ResumeInstancesInstanceGroupManagerRequest, dict]): The request object. A request message for - InstanceGroupManagers.SetInstanceTemplate. + InstanceGroupManagers.ResumeInstances. See the method description for details. project (str): Project ID for this request. @@ -5464,16 +5578,18 @@ def sample_set_instance_template(): This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance_group_managers_set_instance_template_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest): + instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersResumeInstancesRequest): The body resource for this request - This corresponds to the ``instance_group_managers_set_instance_template_request_resource`` field + This corresponds to the ``instance_group_managers_resume_instances_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5489,7 +5605,7 @@ def sample_set_instance_template(): project, zone, instance_group_manager, - instance_group_managers_set_instance_template_request_resource, + instance_group_managers_resume_instances_request_resource, ] ) if request is not None and has_flattened_params: @@ -5500,10 +5616,8 @@ def sample_set_instance_template(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance( - request, compute.SetInstanceTemplateInstanceGroupManagerRequest - ): - request = compute.SetInstanceTemplateInstanceGroupManagerRequest(request) + if not isinstance(request, compute.ResumeInstancesInstanceGroupManagerRequest): + request = compute.ResumeInstancesInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5512,17 +5626,14 @@ def sample_set_instance_template(): request.zone = zone if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if ( - instance_group_managers_set_instance_template_request_resource - is not None - ): - request.instance_group_managers_set_instance_template_request_resource = ( - instance_group_managers_set_instance_template_request_resource + if instance_group_managers_resume_instances_request_resource is not None: + request.instance_group_managers_resume_instances_request_resource = ( + instance_group_managers_resume_instances_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + rpc = self._transport._wrapped_methods[self._transport.resume_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5575,30 +5686,27 @@ def error_code(self): # Done; return the response. return response - def set_target_pools_unary( + def set_instance_template_unary( self, request: Optional[ - Union[compute.SetTargetPoolsInstanceGroupManagerRequest, dict] + Union[compute.SetInstanceTemplateInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, zone: Optional[str] = None, instance_group_manager: Optional[str] = None, - instance_group_managers_set_target_pools_request_resource: Optional[ - compute.InstanceGroupManagersSetTargetPoolsRequest + instance_group_managers_set_instance_template_request_resource: Optional[ + compute.InstanceGroupManagersSetInstanceTemplateRequest ] = 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]]] = (), ) -> compute.Operation: - r"""Modifies the target pools to which all instances in - this managed instance group are assigned. The target - pools automatically apply to all of the instances in the - managed instance group. This operation is marked DONE - when you make the request even if the instances have not - yet been added to their target pools. The change might - take some time to apply to all of the instances in the - group depending on the size of the group. + r"""Specifies the instance template to use when creating + new instances in this group. The templates for existing + instances in the group do not change unless you run + recreateInstances, run applyUpdatesToInstances, or set + the group's updatePolicy.type to PROACTIVE. .. code-block:: python @@ -5611,27 +5719,27 @@ def set_target_pools_unary( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_target_pools(): + def sample_set_instance_template(): # Create a client client = compute_v1.InstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetTargetPoolsInstanceGroupManagerRequest( + request = compute_v1.SetInstanceTemplateInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", zone="zone_value", ) # Make the request - response = client.set_target_pools(request=request) + response = client.set_instance_template(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest, dict]): The request object. A request message for - InstanceGroupManagers.SetTargetPools. + InstanceGroupManagers.SetInstanceTemplate. See the method description for details. project (str): Project ID for this request. @@ -5652,16 +5760,18 @@ def sample_set_target_pools(): This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest): + instance_group_managers_set_instance_template_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest): The body resource for this request - This corresponds to the ``instance_group_managers_set_target_pools_request_resource`` field + This corresponds to the ``instance_group_managers_set_instance_template_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5677,7 +5787,7 @@ def sample_set_target_pools(): project, zone, instance_group_manager, - instance_group_managers_set_target_pools_request_resource, + instance_group_managers_set_instance_template_request_resource, ] ) if request is not None and has_flattened_params: @@ -5688,8 +5798,10 @@ def sample_set_target_pools(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, compute.SetTargetPoolsInstanceGroupManagerRequest): - request = compute.SetTargetPoolsInstanceGroupManagerRequest(request) + if not isinstance( + request, compute.SetInstanceTemplateInstanceGroupManagerRequest + ): + request = compute.SetInstanceTemplateInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5698,14 +5810,17 @@ def sample_set_target_pools(): request.zone = zone if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if instance_group_managers_set_target_pools_request_resource is not None: - request.instance_group_managers_set_target_pools_request_resource = ( - instance_group_managers_set_target_pools_request_resource + if ( + instance_group_managers_set_instance_template_request_resource + is not None + ): + request.instance_group_managers_set_instance_template_request_resource = ( + instance_group_managers_set_instance_template_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + rpc = self._transport._wrapped_methods[self._transport.set_instance_template] # Certain fields should be provided within the metadata header; # add these here. @@ -5733,30 +5848,27 @@ def sample_set_target_pools(): # Done; return the response. return response - def set_target_pools( + def set_instance_template( self, request: Optional[ - Union[compute.SetTargetPoolsInstanceGroupManagerRequest, dict] + Union[compute.SetInstanceTemplateInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, zone: Optional[str] = None, instance_group_manager: Optional[str] = None, - instance_group_managers_set_target_pools_request_resource: Optional[ - compute.InstanceGroupManagersSetTargetPoolsRequest + instance_group_managers_set_instance_template_request_resource: Optional[ + compute.InstanceGroupManagersSetInstanceTemplateRequest ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: - r"""Modifies the target pools to which all instances in - this managed instance group are assigned. The target - pools automatically apply to all of the instances in the - managed instance group. This operation is marked DONE - when you make the request even if the instances have not - yet been added to their target pools. The change might - take some time to apply to all of the instances in the - group depending on the size of the group. + r"""Specifies the instance template to use when creating + new instances in this group. The templates for existing + instances in the group do not change unless you run + recreateInstances, run applyUpdatesToInstances, or set + the group's updatePolicy.type to PROACTIVE. .. code-block:: python @@ -5769,27 +5881,27 @@ def set_target_pools( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_target_pools(): + def sample_set_instance_template(): # Create a client client = compute_v1.InstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetTargetPoolsInstanceGroupManagerRequest( + request = compute_v1.SetInstanceTemplateInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", zone="zone_value", ) # Make the request - response = client.set_target_pools(request=request) + response = client.set_instance_template(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest, dict]): The request object. A request message for - InstanceGroupManagers.SetTargetPools. + InstanceGroupManagers.SetInstanceTemplate. See the method description for details. project (str): Project ID for this request. @@ -5810,16 +5922,18 @@ def sample_set_target_pools(): This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest): + instance_group_managers_set_instance_template_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest): The body resource for this request - This corresponds to the ``instance_group_managers_set_target_pools_request_resource`` field + This corresponds to the ``instance_group_managers_set_instance_template_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5835,7 +5949,7 @@ def sample_set_target_pools(): project, zone, instance_group_manager, - instance_group_managers_set_target_pools_request_resource, + instance_group_managers_set_instance_template_request_resource, ] ) if request is not None and has_flattened_params: @@ -5846,8 +5960,10 @@ def sample_set_target_pools(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, compute.SetTargetPoolsInstanceGroupManagerRequest): - request = compute.SetTargetPoolsInstanceGroupManagerRequest(request) + if not isinstance( + request, compute.SetInstanceTemplateInstanceGroupManagerRequest + ): + request = compute.SetInstanceTemplateInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5856,14 +5972,1483 @@ def sample_set_target_pools(): request.zone = zone if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if instance_group_managers_set_target_pools_request_resource is not None: - request.instance_group_managers_set_target_pools_request_resource = ( - instance_group_managers_set_target_pools_request_resource + if ( + instance_group_managers_set_instance_template_request_resource + is not None + ): + request.instance_group_managers_set_instance_template_request_resource = ( + instance_group_managers_set_instance_template_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._zone_operations_client + operation_request = compute.GetZoneOperationRequest() + operation_request.project = request.project + operation_request.zone = request.zone + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def set_target_pools_unary( + self, + request: Optional[ + Union[compute.SetTargetPoolsInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_set_target_pools_request_resource: Optional[ + compute.InstanceGroupManagersSetTargetPoolsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Modifies the target pools to which all instances in + this managed instance group are assigned. The target + pools automatically apply to all of the instances in the + managed instance group. This operation is marked DONE + when you make the request even if the instances have not + yet been added to their target pools. The change might + take some time to apply to all of the instances in the + group depending on the size of the group. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_target_pools(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SetTargetPoolsInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.set_target_pools(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.SetTargetPools. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_set_target_pools_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_set_target_pools_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SetTargetPoolsInstanceGroupManagerRequest): + request = compute.SetTargetPoolsInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_set_target_pools_request_resource is not None: + request.instance_group_managers_set_target_pools_request_resource = ( + instance_group_managers_set_target_pools_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def set_target_pools( + self, + request: Optional[ + Union[compute.SetTargetPoolsInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_set_target_pools_request_resource: Optional[ + compute.InstanceGroupManagersSetTargetPoolsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Modifies the target pools to which all instances in + this managed instance group are assigned. The target + pools automatically apply to all of the instances in the + managed instance group. This operation is marked DONE + when you make the request even if the instances have not + yet been added to their target pools. The change might + take some time to apply to all of the instances in the + group depending on the size of the group. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_target_pools(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SetTargetPoolsInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.set_target_pools(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.SetTargetPools. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_set_target_pools_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_set_target_pools_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SetTargetPoolsInstanceGroupManagerRequest): + request = compute.SetTargetPoolsInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_set_target_pools_request_resource is not None: + request.instance_group_managers_set_target_pools_request_resource = ( + instance_group_managers_set_target_pools_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._zone_operations_client + operation_request = compute.GetZoneOperationRequest() + operation_request.project = request.project + operation_request.zone = request.zone + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def start_instances_unary( + self, + request: Optional[ + Union[compute.StartInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_start_instances_request_resource: Optional[ + compute.InstanceGroupManagersStartInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be started. This method increases the + targetSize and decreases the targetStoppedSize of the + managed instance group by the number of instances that + you start. The startInstances operation is marked DONE + if the startInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the STARTING action with + the listmanagedinstances method. In this request, you + can only specify instances that are stopped. For + example, if an instance was previously stopped using the + stopInstances method, it can be started using the + startInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are started. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_start_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StartInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.StartInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStartInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_start_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_start_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.StartInstancesInstanceGroupManagerRequest): + request = compute.StartInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_start_instances_request_resource is not None: + request.instance_group_managers_start_instances_request_resource = ( + instance_group_managers_start_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.start_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def start_instances( + self, + request: Optional[ + Union[compute.StartInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_start_instances_request_resource: Optional[ + compute.InstanceGroupManagersStartInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be started. This method increases the + targetSize and decreases the targetStoppedSize of the + managed instance group by the number of instances that + you start. The startInstances operation is marked DONE + if the startInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the STARTING action with + the listmanagedinstances method. In this request, you + can only specify instances that are stopped. For + example, if an instance was previously stopped using the + stopInstances method, it can be started using the + startInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are started. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_start_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StartInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.StartInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStartInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_start_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_start_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.StartInstancesInstanceGroupManagerRequest): + request = compute.StartInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_start_instances_request_resource is not None: + request.instance_group_managers_start_instances_request_resource = ( + instance_group_managers_start_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.start_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._zone_operations_client + operation_request = compute.GetZoneOperationRequest() + operation_request.project = request.project + operation_request.zone = request.zone + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def stop_instances_unary( + self, + request: Optional[ + Union[compute.StopInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_stop_instances_request_resource: Optional[ + compute.InstanceGroupManagersStopInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be immediately stopped. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetStoppedSize of the managed instance group by the + number of instances that you stop. The stopInstances + operation is marked DONE if the stopInstances request is + successful. The underlying actions take additional time. + You must separately verify the status of the STOPPING + action with the listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays stopping the instances until initialDelaySec have + passed from instance.creationTimestamp (that is, when + the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is stopped. Stopped instances can be started + using the startInstances method. You can specify a + maximum of 1000 instances with this method per request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_stop_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StopInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.StopInstances. See + the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStopInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_stop_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_stop_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.StopInstancesInstanceGroupManagerRequest): + request = compute.StopInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_stop_instances_request_resource is not None: + request.instance_group_managers_stop_instances_request_resource = ( + instance_group_managers_stop_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def stop_instances( + self, + request: Optional[ + Union[compute.StopInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_stop_instances_request_resource: Optional[ + compute.InstanceGroupManagersStopInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be immediately stopped. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetStoppedSize of the managed instance group by the + number of instances that you stop. The stopInstances + operation is marked DONE if the stopInstances request is + successful. The underlying actions take additional time. + You must separately verify the status of the STOPPING + action with the listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays stopping the instances until initialDelaySec have + passed from instance.creationTimestamp (that is, when + the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is stopped. Stopped instances can be started + using the startInstances method. You can specify a + maximum of 1000 instances with this method per request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_stop_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StopInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.StopInstances. See + the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStopInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_stop_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_stop_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.StopInstancesInstanceGroupManagerRequest): + request = compute.StopInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_stop_instances_request_resource is not None: + request.instance_group_managers_stop_instances_request_resource = ( + instance_group_managers_stop_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._zone_operations_client + operation_request = compute.GetZoneOperationRequest() + operation_request.project = request.project + operation_request.zone = request.zone + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def suspend_instances_unary( + self, + request: Optional[ + Union[compute.SuspendInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_suspend_instances_request_resource: Optional[ + compute.InstanceGroupManagersSuspendInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be immediately suspended. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetSuspendedSize of the managed instance group by the + number of instances that you suspend. The + suspendInstances operation is marked DONE if the + suspendInstances request is successful. The underlying + actions take additional time. You must separately verify + the status of the SUSPENDING action with the + listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays suspension of the instances until initialDelaySec + have passed from instance.creationTimestamp (that is, + when the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is suspended. Suspended instances can be + resumed using the resumeInstances method. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_suspend_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SuspendInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.SuspendInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_suspend_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_suspend_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SuspendInstancesInstanceGroupManagerRequest): + request = compute.SuspendInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_suspend_instances_request_resource is not None: + request.instance_group_managers_suspend_instances_request_resource = ( + instance_group_managers_suspend_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suspend_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("zone", request.zone), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def suspend_instances( + self, + request: Optional[ + Union[compute.SuspendInstancesInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + zone: Optional[str] = None, + instance_group_manager: Optional[str] = None, + instance_group_managers_suspend_instances_request_resource: Optional[ + compute.InstanceGroupManagersSuspendInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be immediately suspended. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetSuspendedSize of the managed instance group by the + number of instances that you suspend. The + suspendInstances operation is marked DONE if the + suspendInstances request is successful. The underlying + actions take additional time. You must separately verify + the status of the SUSPENDING action with the + listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays suspension of the instances until initialDelaySec + have passed from instance.creationTimestamp (that is, + when the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is suspended. Suspended instances can be + resumed using the resumeInstances method. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_suspend_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SuspendInstancesInstanceGroupManagerRequest, dict]): + The request object. A request message for + InstanceGroupManagers.SuspendInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + zone (str): + The name of the zone where the + managed instance group is located. + + This corresponds to the ``zone`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + This corresponds to the ``instance_group_managers_suspend_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + zone, + instance_group_manager, + instance_group_managers_suspend_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SuspendInstancesInstanceGroupManagerRequest): + request = compute.SuspendInstancesInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if zone is not None: + request.zone = zone + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if instance_group_managers_suspend_instances_request_resource is not None: + request.instance_group_managers_suspend_instances_request_resource = ( + instance_group_managers_suspend_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suspend_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5930,7 +7515,7 @@ def update_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name @@ -5998,8 +7583,10 @@ def sample_update_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -6094,7 +7681,7 @@ def update_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name @@ -6162,8 +7749,10 @@ def sample_update_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/pagers.py index f2914cc94db6..5bb4a04bc102 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/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 = compute.AggregatedListInstanceGroupManagersRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListInstanceGroupManagersRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListErrorsInstanceGroupManagersRequest(request) @@ -294,7 +300,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. @@ -308,8 +314,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 = compute.ListManagedInstancesInstanceGroupManagersRequest( @@ -372,7 +380,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. @@ -386,8 +394,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 = compute.ListPerInstanceConfigsInstanceGroupManagersRequest( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/base.py index 726de97d5022..fb65a2f2f4e6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/base.py @@ -218,6 +218,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.resume_instances: gapic_v1.method.wrap_method( + self.resume_instances, + default_timeout=None, + client_info=client_info, + ), self.set_instance_template: gapic_v1.method.wrap_method( self.set_instance_template, default_timeout=None, @@ -228,6 +233,21 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.start_instances: gapic_v1.method.wrap_method( + self.start_instances, + default_timeout=None, + client_info=client_info, + ), + self.stop_instances: gapic_v1.method.wrap_method( + self.stop_instances, + default_timeout=None, + client_info=client_info, + ), + self.suspend_instances: gapic_v1.method.wrap_method( + self.suspend_instances, + default_timeout=None, + client_info=client_info, + ), self.update_per_instance_configs: gapic_v1.method.wrap_method( self.update_per_instance_configs, default_timeout=None, @@ -412,6 +432,15 @@ def resize( ]: raise NotImplementedError() + @property + def resume_instances( + self, + ) -> Callable[ + [compute.ResumeInstancesInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + @property def set_instance_template( self, @@ -430,6 +459,33 @@ def set_target_pools( ]: raise NotImplementedError() + @property + def start_instances( + self, + ) -> Callable[ + [compute.StartInstancesInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + + @property + def stop_instances( + self, + ) -> Callable[ + [compute.StopInstancesInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + + @property + def suspend_instances( + self, + ) -> Callable[ + [compute.SuspendInstancesInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + @property def update_per_instance_configs( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest.py index 99de5bda76da..edcde7634684 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/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 @@ -37,6 +37,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, @@ -196,6 +204,14 @@ def post_resize(self, response): logging.log(f"Received response: {response}") return response + def pre_resume_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_resume_instances(self, response): + logging.log(f"Received response: {response}") + return response + def pre_set_instance_template(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -212,6 +228,30 @@ def post_set_target_pools(self, response): logging.log(f"Received response: {response}") return response + def pre_start_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_start_instances(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_stop_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_stop_instances(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_suspend_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_suspend_instances(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_per_instance_configs(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -229,9 +269,10 @@ def post_update_per_instance_configs(self, response): def pre_abandon_instances( self, request: compute.AbandonInstancesInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AbandonInstancesInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.AbandonInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for abandon_instances @@ -252,9 +293,10 @@ def post_abandon_instances(self, response: compute.Operation) -> compute.Operati def pre_aggregated_list( self, request: compute.AggregatedListInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListInstanceGroupManagersRequest, Sequence[Tuple[str, str]] + compute.AggregatedListInstanceGroupManagersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -277,10 +319,10 @@ def post_aggregated_list( def pre_apply_updates_to_instances( self, request: compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for apply_updates_to_instances @@ -303,9 +345,10 @@ def post_apply_updates_to_instances( def pre_create_instances( self, request: compute.CreateInstancesInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.CreateInstancesInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.CreateInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_instances @@ -326,8 +369,11 @@ def post_create_instances(self, response: compute.Operation) -> compute.Operatio def pre_delete( self, request: compute.DeleteInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -347,9 +393,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_instances( self, request: compute.DeleteInstancesInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteInstancesInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.DeleteInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_instances @@ -370,10 +417,10 @@ def post_delete_instances(self, response: compute.Operation) -> compute.Operatio def pre_delete_per_instance_configs( self, request: compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_per_instance_configs @@ -396,8 +443,10 @@ def post_delete_per_instance_configs( def pre_get( self, request: compute.GetInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInstanceGroupManagerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -419,8 +468,11 @@ def post_get( def pre_insert( self, request: compute.InsertInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -440,8 +492,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInstanceGroupManagersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInstanceGroupManagersRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -463,9 +518,10 @@ def post_list( def pre_list_errors( self, request: compute.ListErrorsInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListErrorsInstanceGroupManagersRequest, Sequence[Tuple[str, str]] + compute.ListErrorsInstanceGroupManagersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_errors @@ -488,10 +544,10 @@ def post_list_errors( def pre_list_managed_instances( self, request: compute.ListManagedInstancesInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListManagedInstancesInstanceGroupManagersRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_managed_instances @@ -514,10 +570,10 @@ def post_list_managed_instances( def pre_list_per_instance_configs( self, request: compute.ListPerInstanceConfigsInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListPerInstanceConfigsInstanceGroupManagersRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_per_instance_configs @@ -540,8 +596,11 @@ def post_list_per_instance_configs( def pre_patch( self, request: compute.PatchInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -561,10 +620,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_per_instance_configs( self, request: compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch_per_instance_configs @@ -587,9 +646,10 @@ def post_patch_per_instance_configs( def pre_recreate_instances( self, request: compute.RecreateInstancesInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RecreateInstancesInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.RecreateInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for recreate_instances @@ -610,8 +670,11 @@ def post_recreate_instances(self, response: compute.Operation) -> compute.Operat def pre_resize( self, request: compute.ResizeInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ResizeInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ResizeInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for resize Override in a subclass to manipulate the request or metadata @@ -628,13 +691,37 @@ def post_resize(self, response: compute.Operation) -> compute.Operation: """ return response + def pre_resume_instances( + self, + request: compute.ResumeInstancesInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ResumeInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for resume_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the InstanceGroupManagers server. + """ + return request, metadata + + def post_resume_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for resume_instances + + Override in a subclass to manipulate the response + after it is returned by the InstanceGroupManagers server but before + it is returned to user code. + """ + return response + def pre_set_instance_template( self, request: compute.SetInstanceTemplateInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetInstanceTemplateInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_instance_template @@ -657,9 +744,10 @@ def post_set_instance_template( def pre_set_target_pools( self, request: compute.SetTargetPoolsInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetTargetPoolsInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.SetTargetPoolsInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_target_pools @@ -677,13 +765,85 @@ def post_set_target_pools(self, response: compute.Operation) -> compute.Operatio """ return response + def pre_start_instances( + self, + request: compute.StartInstancesInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StartInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for start_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the InstanceGroupManagers server. + """ + return request, metadata + + def post_start_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for start_instances + + Override in a subclass to manipulate the response + after it is returned by the InstanceGroupManagers server but before + it is returned to user code. + """ + return response + + def pre_stop_instances( + self, + request: compute.StopInstancesInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StopInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for stop_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the InstanceGroupManagers server. + """ + return request, metadata + + def post_stop_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for stop_instances + + Override in a subclass to manipulate the response + after it is returned by the InstanceGroupManagers server but before + it is returned to user code. + """ + return response + + def pre_suspend_instances( + self, + request: compute.SuspendInstancesInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SuspendInstancesInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for suspend_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the InstanceGroupManagers server. + """ + return request, metadata + + def post_suspend_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for suspend_instances + + Override in a subclass to manipulate the response + after it is returned by the InstanceGroupManagers server but before + it is returned to user code. + """ + return response + def pre_update_per_instance_configs( self, request: compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_per_instance_configs @@ -830,7 +990,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]]] = (), ) -> compute.Operation: r"""Call the abandon instances method over HTTP. @@ -842,8 +1002,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: ~.compute.Operation: @@ -870,6 +1032,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseAbandonInstances._get_http_options() ) + request, metadata = self._interceptor.pre_abandon_instances( request, metadata ) @@ -886,6 +1049,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 = 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.compute_v1.InstanceGroupManagersClient.AbandonInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "AbandonInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagersRestTransport._AbandonInstances._get_response( @@ -909,7 +1099,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_abandon_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.abandon_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "AbandonInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -947,7 +1159,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]]] = (), ) -> compute.InstanceGroupManagerAggregatedList: r"""Call the aggregated list method over HTTP. @@ -959,8 +1171,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: ~.compute.InstanceGroupManagerAggregatedList: @@ -970,6 +1184,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -980,6 +1195,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 = 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.compute_v1.InstanceGroupManagersClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._AggregatedList._get_response( self._host, @@ -1000,7 +1242,31 @@ def __call__( pb_resp = compute.InstanceGroupManagerAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstanceGroupManagerAggregatedList.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.compute_v1.InstanceGroupManagersClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApplyUpdatesToInstances( @@ -1039,7 +1305,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]]] = (), ) -> compute.Operation: r"""Call the apply updates to instances method over HTTP. @@ -1052,8 +1318,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: ~.compute.Operation: @@ -1080,6 +1348,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseApplyUpdatesToInstances._get_http_options() ) + request, metadata = self._interceptor.pre_apply_updates_to_instances( request, metadata ) @@ -1096,6 +1365,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 = 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.compute_v1.InstanceGroupManagersClient.ApplyUpdatesToInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ApplyUpdatesToInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._ApplyUpdatesToInstances._get_response( self._host, @@ -1117,7 +1413,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_updates_to_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.apply_updates_to_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ApplyUpdatesToInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstances( @@ -1156,7 +1474,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]]] = (), ) -> compute.Operation: r"""Call the create instances method over HTTP. @@ -1168,8 +1486,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: ~.compute.Operation: @@ -1196,6 +1516,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseCreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_instances( request, metadata ) @@ -1212,6 +1533,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 = 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.compute_v1.InstanceGroupManagersClient.CreateInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "CreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagersRestTransport._CreateInstances._get_response( @@ -1235,7 +1583,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.create_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "CreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -1273,7 +1643,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1285,8 +1655,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: ~.compute.Operation: @@ -1313,6 +1685,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -1323,6 +1696,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 = 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.compute_v1.InstanceGroupManagersClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._Delete._get_response( self._host, @@ -1343,7 +1743,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstances( @@ -1382,7 +1804,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]]] = (), ) -> compute.Operation: r"""Call the delete instances method over HTTP. @@ -1394,8 +1816,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: ~.compute.Operation: @@ -1422,6 +1846,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseDeleteInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instances( request, metadata ) @@ -1438,6 +1863,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 = 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.compute_v1.InstanceGroupManagersClient.DeleteInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "DeleteInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagersRestTransport._DeleteInstances._get_response( @@ -1461,7 +1913,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.delete_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "DeleteInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePerInstanceConfigs( @@ -1500,7 +1974,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]]] = (), ) -> compute.Operation: r"""Call the delete per instance configs method over HTTP. @@ -1513,8 +1987,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: ~.compute.Operation: @@ -1541,6 +2017,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseDeletePerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_delete_per_instance_configs( request, metadata ) @@ -1557,6 +2034,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 = 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.compute_v1.InstanceGroupManagersClient.DeletePerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "DeletePerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._DeletePerInstanceConfigs._get_response( self._host, @@ -1578,7 +2082,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.delete_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "DeletePerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -1615,7 +2141,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]]] = (), ) -> compute.InstanceGroupManager: r"""Call the get method over HTTP. @@ -1627,8 +2153,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: ~.compute.InstanceGroupManager: @@ -1647,6 +2175,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -1659,6 +2188,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.compute_v1.InstanceGroupManagersClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._Get._get_response( self._host, @@ -1679,7 +2235,29 @@ def __call__( pb_resp = compute.InstanceGroupManager.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupManager.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.compute_v1.InstanceGroupManagersClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1718,7 +2296,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1730,8 +2308,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: ~.compute.Operation: @@ -1758,6 +2338,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1772,6 +2353,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 = 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.compute_v1.InstanceGroupManagersClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._Insert._get_response( self._host, @@ -1793,7 +2401,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1830,7 +2460,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]]] = (), ) -> compute.InstanceGroupManagerList: r"""Call the list method over HTTP. @@ -1842,8 +2472,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: ~.compute.InstanceGroupManagerList: @@ -1853,6 +2485,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1863,6 +2496,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 = 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.compute_v1.InstanceGroupManagersClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._List._get_response( self._host, @@ -1883,7 +2543,31 @@ def __call__( pb_resp = compute.InstanceGroupManagerList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupManagerList.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.compute_v1.InstanceGroupManagersClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListErrors( @@ -1921,7 +2605,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]]] = (), ) -> compute.InstanceGroupManagersListErrorsResponse: r"""Call the list errors method over HTTP. @@ -1933,8 +2617,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: ~.compute.InstanceGroupManagersListErrorsResponse: @@ -1944,6 +2630,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseListErrors._get_http_options() ) + request, metadata = self._interceptor.pre_list_errors(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseListErrors._get_transcoded_request( http_options, request @@ -1954,6 +2641,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 = 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.compute_v1.InstanceGroupManagersClient.ListErrors", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListErrors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._ListErrors._get_response( self._host, @@ -1974,7 +2688,33 @@ def __call__( pb_resp = compute.InstanceGroupManagersListErrorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_errors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstanceGroupManagersListErrorsResponse.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.compute_v1.InstanceGroupManagersClient.list_errors", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListErrors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListManagedInstances( @@ -2012,7 +2752,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]]] = (), ) -> compute.InstanceGroupManagersListManagedInstancesResponse: r"""Call the list managed instances method over HTTP. @@ -2024,8 +2764,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: ~.compute.InstanceGroupManagersListManagedInstancesResponse: @@ -2035,6 +2777,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseListManagedInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_managed_instances( request, metadata ) @@ -2047,6 +2790,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 = 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.compute_v1.InstanceGroupManagersClient.ListManagedInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListManagedInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagersRestTransport._ListManagedInstances._get_response( @@ -2069,7 +2839,31 @@ def __call__( pb_resp = compute.InstanceGroupManagersListManagedInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_managed_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupManagersListManagedInstancesResponse.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.compute_v1.InstanceGroupManagersClient.list_managed_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListManagedInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPerInstanceConfigs( @@ -2107,7 +2901,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]]] = (), ) -> compute.InstanceGroupManagersListPerInstanceConfigsResp: r"""Call the list per instance configs method over HTTP. @@ -2119,8 +2913,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: ~.compute.InstanceGroupManagersListPerInstanceConfigsResp: @@ -2130,6 +2926,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseListPerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_per_instance_configs( request, metadata ) @@ -2142,6 +2939,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 = 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.compute_v1.InstanceGroupManagersClient.ListPerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListPerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._ListPerInstanceConfigs._get_response( self._host, @@ -2162,7 +2986,33 @@ def __call__( pb_resp = compute.InstanceGroupManagersListPerInstanceConfigsResp.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstanceGroupManagersListPerInstanceConfigsResp.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.compute_v1.InstanceGroupManagersClient.list_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ListPerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -2201,7 +3051,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -2213,8 +3063,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: ~.compute.Operation: @@ -2241,6 +3093,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -2255,6 +3108,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 = 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.compute_v1.InstanceGroupManagersClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._Patch._get_response( self._host, @@ -2276,7 +3156,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchPerInstanceConfigs( @@ -2315,7 +3217,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]]] = (), ) -> compute.Operation: r"""Call the patch per instance configs method over HTTP. @@ -2328,8 +3230,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: ~.compute.Operation: @@ -2356,6 +3260,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BasePatchPerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_patch_per_instance_configs( request, metadata ) @@ -2372,6 +3277,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 = 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.compute_v1.InstanceGroupManagersClient.PatchPerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "PatchPerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._PatchPerInstanceConfigs._get_response( self._host, @@ -2393,7 +3325,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.patch_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "PatchPerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RecreateInstances( @@ -2432,7 +3386,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]]] = (), ) -> compute.Operation: r"""Call the recreate instances method over HTTP. @@ -2444,8 +3398,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: ~.compute.Operation: @@ -2472,6 +3428,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseRecreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_recreate_instances( request, metadata ) @@ -2488,6 +3445,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 = 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.compute_v1.InstanceGroupManagersClient.RecreateInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "RecreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstanceGroupManagersRestTransport._RecreateInstances._get_response( @@ -2511,7 +3495,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_recreate_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.recreate_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "RecreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resize( @@ -2549,7 +3555,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]]] = (), ) -> compute.Operation: r"""Call the resize method over HTTP. @@ -2561,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: ~.compute.Operation: @@ -2589,6 +3597,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseResize._get_http_options() ) + request, metadata = self._interceptor.pre_resize(request, metadata) transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseResize._get_transcoded_request( http_options, request @@ -2599,6 +3608,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 = 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.compute_v1.InstanceGroupManagersClient.Resize", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Resize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._Resize._get_response( self._host, @@ -2619,15 +3655,37 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.resize", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "Resize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _SetInstanceTemplate( - _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate, + class _ResumeInstances( + _BaseInstanceGroupManagersRestTransport._BaseResumeInstances, InstanceGroupManagersRestStub, ): def __hash__(self): - return hash("InstanceGroupManagersRestTransport.SetInstanceTemplate") + return hash("InstanceGroupManagersRestTransport.ResumeInstances") @staticmethod def _get_response( @@ -2654,24 +3712,26 @@ def _get_response( def __call__( self, - request: compute.SetInstanceTemplateInstanceGroupManagerRequest, + request: compute.ResumeInstancesInstanceGroupManagerRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> compute.Operation: - r"""Call the set instance template method over HTTP. + r"""Call the resume instances method over HTTP. Args: - request (~.compute.SetInstanceTemplateInstanceGroupManagerRequest): + request (~.compute.ResumeInstancesInstanceGroupManagerRequest): The request object. A request message for - InstanceGroupManagers.SetInstanceTemplate. + InstanceGroupManagers.ResumeInstances. See the method description for details. 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: ~.compute.Operation: @@ -2696,27 +3756,55 @@ def __call__( """ http_options = ( - _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_http_options() + _BaseInstanceGroupManagersRestTransport._BaseResumeInstances._get_http_options() ) - request, metadata = self._interceptor.pre_set_instance_template( + + request, metadata = self._interceptor.pre_resume_instances( request, metadata ) - transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_transcoded_request( + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseResumeInstances._get_transcoded_request( http_options, request ) - body = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_request_body_json( + body = _BaseInstanceGroupManagersRestTransport._BaseResumeInstances._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_query_params_json( + query_params = _BaseInstanceGroupManagersRestTransport._BaseResumeInstances._get_query_params_json( 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 = 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.compute_v1.InstanceGroupManagersClient.ResumeInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ResumeInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( - InstanceGroupManagersRestTransport._SetInstanceTemplate._get_response( + InstanceGroupManagersRestTransport._ResumeInstances._get_response( self._host, metadata, query_params, @@ -2737,15 +3825,37 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_instance_template(resp) + + resp = self._interceptor.post_resume_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.resume_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "ResumeInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _SetTargetPools( - _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools, + class _SetInstanceTemplate( + _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate, InstanceGroupManagersRestStub, ): def __hash__(self): - return hash("InstanceGroupManagersRestTransport.SetTargetPools") + return hash("InstanceGroupManagersRestTransport.SetInstanceTemplate") @staticmethod def _get_response( @@ -2772,24 +3882,26 @@ def _get_response( def __call__( self, - request: compute.SetTargetPoolsInstanceGroupManagerRequest, + request: compute.SetInstanceTemplateInstanceGroupManagerRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> compute.Operation: - r"""Call the set target pools method over HTTP. + r"""Call the set instance template method over HTTP. Args: - request (~.compute.SetTargetPoolsInstanceGroupManagerRequest): + request (~.compute.SetInstanceTemplateInstanceGroupManagerRequest): The request object. A request message for - InstanceGroupManagers.SetTargetPools. + InstanceGroupManagers.SetInstanceTemplate. See the method description for details. 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: ~.compute.Operation: @@ -2814,27 +3926,225 @@ def __call__( """ http_options = ( - _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_http_options() + _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_http_options() ) - request, metadata = self._interceptor.pre_set_target_pools( + + request, metadata = self._interceptor.pre_set_instance_template( request, metadata ) - transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_transcoded_request( + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_transcoded_request( http_options, request ) - body = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_request_body_json( + body = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_query_params_json( + query_params = _BaseInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_query_params_json( 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 = 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.compute_v1.InstanceGroupManagersClient.SetInstanceTemplate", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SetInstanceTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request - response = InstanceGroupManagersRestTransport._SetTargetPools._get_response( - self._host, + response = ( + InstanceGroupManagersRestTransport._SetInstanceTemplate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_set_instance_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.set_instance_template", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SetInstanceTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SetTargetPools( + _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools, + InstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("InstanceGroupManagersRestTransport.SetTargetPools") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.SetTargetPoolsInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the set target pools method over HTTP. + + Args: + request (~.compute.SetTargetPoolsInstanceGroupManagerRequest): + The request object. A request message for + InstanceGroupManagers.SetTargetPools. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_http_options() + ) + + request, metadata = self._interceptor.pre_set_target_pools( + request, metadata + ) + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_transcoded_request( + http_options, request + ) + + body = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseInstanceGroupManagersRestTransport._BaseSetTargetPools._get_query_params_json( + 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 = 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.compute_v1.InstanceGroupManagersClient.SetTargetPools", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SetTargetPools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = InstanceGroupManagersRestTransport._SetTargetPools._get_response( + self._host, metadata, query_params, self._session, @@ -2853,7 +4163,531 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_target_pools(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.set_target_pools", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SetTargetPools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _StartInstances( + _BaseInstanceGroupManagersRestTransport._BaseStartInstances, + InstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("InstanceGroupManagersRestTransport.StartInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.StartInstancesInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the start instances method over HTTP. + + Args: + request (~.compute.StartInstancesInstanceGroupManagerRequest): + The request object. A request message for + InstanceGroupManagers.StartInstances. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseInstanceGroupManagersRestTransport._BaseStartInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_start_instances(request, metadata) + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseStartInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseInstanceGroupManagersRestTransport._BaseStartInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseInstanceGroupManagersRestTransport._BaseStartInstances._get_query_params_json( + 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 = 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.compute_v1.InstanceGroupManagersClient.StartInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "StartInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = InstanceGroupManagersRestTransport._StartInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_start_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.start_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "StartInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _StopInstances( + _BaseInstanceGroupManagersRestTransport._BaseStopInstances, + InstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("InstanceGroupManagersRestTransport.StopInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.StopInstancesInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the stop instances method over HTTP. + + Args: + request (~.compute.StopInstancesInstanceGroupManagerRequest): + The request object. A request message for + InstanceGroupManagers.StopInstances. See + the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseInstanceGroupManagersRestTransport._BaseStopInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_stop_instances(request, metadata) + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseStopInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseInstanceGroupManagersRestTransport._BaseStopInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseInstanceGroupManagersRestTransport._BaseStopInstances._get_query_params_json( + 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 = 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.compute_v1.InstanceGroupManagersClient.StopInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "StopInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = InstanceGroupManagersRestTransport._StopInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_stop_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.stop_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "StopInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SuspendInstances( + _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances, + InstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("InstanceGroupManagersRestTransport.SuspendInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.SuspendInstancesInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the suspend instances method over HTTP. + + Args: + request (~.compute.SuspendInstancesInstanceGroupManagerRequest): + The request object. A request message for + InstanceGroupManagers.SuspendInstances. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_suspend_instances( + request, metadata + ) + transcoded_request = _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances._get_query_params_json( + 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 = 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.compute_v1.InstanceGroupManagersClient.SuspendInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SuspendInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + InstanceGroupManagersRestTransport._SuspendInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_suspend_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.suspend_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "SuspendInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePerInstanceConfigs( @@ -2892,7 +4726,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]]] = (), ) -> compute.Operation: r"""Call the update per instance configs method over HTTP. @@ -2905,8 +4739,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: ~.compute.Operation: @@ -2933,6 +4769,7 @@ def __call__( http_options = ( _BaseInstanceGroupManagersRestTransport._BaseUpdatePerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_update_per_instance_configs( request, metadata ) @@ -2949,6 +4786,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 = 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.compute_v1.InstanceGroupManagersClient.UpdatePerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "UpdatePerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupManagersRestTransport._UpdatePerInstanceConfigs._get_response( self._host, @@ -2970,7 +4834,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupManagersClient.update_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroupManagers", + "rpcName": "UpdatePerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3139,6 +5025,16 @@ def resize( # In C++ this would require a dynamic_cast return self._Resize(self._session, self._host, self._interceptor) # type: ignore + @property + def resume_instances( + self, + ) -> Callable[ + [compute.ResumeInstancesInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ResumeInstances(self._session, self._host, self._interceptor) # type: ignore + @property def set_instance_template( self, @@ -3159,6 +5055,36 @@ def set_target_pools( # In C++ this would require a dynamic_cast return self._SetTargetPools(self._session, self._host, self._interceptor) # type: ignore + @property + def start_instances( + self, + ) -> Callable[ + [compute.StartInstancesInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._StartInstances(self._session, self._host, self._interceptor) # type: ignore + + @property + def stop_instances( + self, + ) -> Callable[ + [compute.StopInstancesInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._StopInstances(self._session, self._host, self._interceptor) # type: ignore + + @property + def suspend_instances( + self, + ) -> Callable[ + [compute.SuspendInstancesInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SuspendInstances(self._session, self._host, self._interceptor) # type: ignore + @property def update_per_instance_configs( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest_base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest_base.py index 5d4a3b5e4a3b..0d9d014b782d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest_base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_group_managers/transports/rest_base.py @@ -973,6 +973,62 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseResumeInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/resumeInstances", + "body": "instance_group_managers_resume_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.ResumeInstancesInstanceGroupManagerRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseInstanceGroupManagersRestTransport._BaseResumeInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + class _BaseSetInstanceTemplate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1087,6 +1143,174 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseStartInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/startInstances", + "body": "instance_group_managers_start_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.StartInstancesInstanceGroupManagerRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseInstanceGroupManagersRestTransport._BaseStartInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + + class _BaseStopInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/stopInstances", + "body": "instance_group_managers_stop_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.StopInstancesInstanceGroupManagerRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseInstanceGroupManagersRestTransport._BaseStopInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + + class _BaseSuspendInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/suspendInstances", + "body": "instance_group_managers_suspend_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.SuspendInstancesInstanceGroupManagerRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseInstanceGroupManagersRestTransport._BaseSuspendInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + class _BaseUpdatePerInstanceConfigs: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/client.py index 603848969af8..90b1be153830 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instance_groups import pagers @@ -558,6 +568,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( @@ -623,6 +637,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.compute_v1.InstanceGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "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.compute.v1.InstanceGroups", + "credentialsType": None, + }, + ) + def add_instances_unary( self, request: Optional[Union[compute.AddInstancesInstanceGroupRequest, dict]] = None, @@ -635,7 +672,7 @@ def add_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds a list of instances to the specified instance group. All of the instances in the instance group must @@ -702,8 +739,10 @@ def sample_add_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -787,7 +826,7 @@ def add_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds a list of instances to the specified instance group. All of the instances in the instance group must @@ -854,8 +893,10 @@ def sample_add_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -961,7 +1002,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of instance groups and sorts them by zone. To prevent failure, Google recommends that you set the @@ -1007,8 +1048,10 @@ def sample_aggregated_list(): 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.compute_v1.services.instance_groups.pagers.AggregatedListPager: @@ -1080,7 +1123,7 @@ def delete_unary( instance_group: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified instance group. The instances in the group are not deleted. Note that instance group @@ -1142,8 +1185,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1213,7 +1258,7 @@ def delete( instance_group: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified instance group. The instances in the group are not deleted. Note that instance group @@ -1275,8 +1320,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1371,7 +1418,7 @@ def get( instance_group: 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]]] = (), ) -> compute.InstanceGroup: r"""Returns the specified zonal instance group. Get a list of available zonal instance groups by making a @@ -1432,8 +1479,10 @@ def sample_get(): 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.compute_v1.types.InstanceGroup: @@ -1515,7 +1564,7 @@ def insert_unary( instance_group_resource: Optional[compute.InstanceGroup] = 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]]] = (), ) -> compute.Operation: r"""Creates an instance group in the specified project using the parameters that are included in the request. @@ -1572,8 +1621,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1642,7 +1693,7 @@ def insert( instance_group_resource: Optional[compute.InstanceGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instance group in the specified project using the parameters that are included in the request. @@ -1699,8 +1750,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1793,7 +1846,7 @@ def list( zone: 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.ListPager: r"""Retrieves the list of zonal instance group resources contained within the specified zone. For managed @@ -1848,8 +1901,10 @@ def sample_list(): 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.compute_v1.services.instance_groups.pagers.ListPager: @@ -1935,7 +1990,7 @@ def list_instances( ] = 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.ListInstancesPager: r"""Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is @@ -2004,8 +2059,10 @@ def sample_list_instances(): 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.compute_v1.services.instance_groups.pagers.ListInstancesPager: @@ -2103,7 +2160,7 @@ def remove_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes one or more instances from the specified instance group, but does not delete those instances. If @@ -2172,8 +2229,10 @@ def sample_remove_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2259,7 +2318,7 @@ def remove_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes one or more instances from the specified instance group, but does not delete those instances. If @@ -2328,8 +2387,10 @@ def sample_remove_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2440,7 +2501,7 @@ def set_named_ports_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the named ports for the specified instance group. @@ -2505,8 +2566,10 @@ def sample_set_named_ports(): 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.api_core.extended_operation.ExtendedOperation: @@ -2592,7 +2655,7 @@ def set_named_ports( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the named ports for the specified instance group. @@ -2657,8 +2720,10 @@ def sample_set_named_ports(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/pagers.py index 7565b4356259..ab413b4322e2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/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 = compute.AggregatedListInstanceGroupsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListInstanceGroupsRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListInstancesInstanceGroupsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/transports/rest.py index f70a525332f7..aa161a56217c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_groups/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 @@ -37,6 +37,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, @@ -141,8 +149,11 @@ def post_set_named_ports(self, response): def pre_add_instances( self, request: compute.AddInstancesInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddInstancesInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddInstancesInstanceGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_instances Override in a subclass to manipulate the request or metadata @@ -162,8 +173,11 @@ def post_add_instances(self, response: compute.Operation) -> compute.Operation: def pre_aggregated_list( self, request: compute.AggregatedListInstanceGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListInstanceGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListInstanceGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -185,8 +199,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInstanceGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -206,8 +222,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInstanceGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -227,8 +245,10 @@ def post_get(self, response: compute.InstanceGroup) -> compute.InstanceGroup: def pre_insert( self, request: compute.InsertInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInstanceGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -248,8 +268,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInstanceGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInstanceGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInstanceGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -271,8 +293,11 @@ def post_list( def pre_list_instances( self, request: compute.ListInstancesInstanceGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInstancesInstanceGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInstancesInstanceGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -294,8 +319,11 @@ def post_list_instances( def pre_remove_instances( self, request: compute.RemoveInstancesInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveInstancesInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveInstancesInstanceGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_instances Override in a subclass to manipulate the request or metadata @@ -315,8 +343,11 @@ def post_remove_instances(self, response: compute.Operation) -> compute.Operatio def pre_set_named_ports( self, request: compute.SetNamedPortsInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetNamedPortsInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetNamedPortsInstanceGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_named_ports Override in a subclass to manipulate the request or metadata @@ -459,7 +490,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]]] = (), ) -> compute.Operation: r"""Call the add instances method over HTTP. @@ -471,8 +502,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: ~.compute.Operation: @@ -499,6 +532,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseAddInstances._get_http_options() ) + request, metadata = self._interceptor.pre_add_instances(request, metadata) transcoded_request = _BaseInstanceGroupsRestTransport._BaseAddInstances._get_transcoded_request( http_options, request @@ -513,6 +547,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 = 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.compute_v1.InstanceGroupsClient.AddInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "AddInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._AddInstances._get_response( self._host, @@ -534,7 +595,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupsClient.add_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "AddInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -571,7 +654,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]]] = (), ) -> compute.InstanceGroupAggregatedList: r"""Call the aggregated list method over HTTP. @@ -583,8 +666,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: ~.compute.InstanceGroupAggregatedList: @@ -594,6 +679,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseInstanceGroupsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -604,6 +690,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 = 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.compute_v1.InstanceGroupsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._AggregatedList._get_response( self._host, @@ -624,7 +737,31 @@ def __call__( pb_resp = compute.InstanceGroupAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupAggregatedList.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.compute_v1.InstanceGroupsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseInstanceGroupsRestTransport._BaseDelete, InstanceGroupsRestStub): @@ -659,7 +796,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -671,8 +808,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: ~.compute.Operation: @@ -699,6 +838,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseInstanceGroupsRestTransport._BaseDelete._get_transcoded_request( @@ -713,6 +853,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.compute_v1.InstanceGroupsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._Delete._get_response( self._host, @@ -733,7 +900,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseInstanceGroupsRestTransport._BaseGet, InstanceGroupsRestStub): @@ -768,7 +957,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]]] = (), ) -> compute.InstanceGroup: r"""Call the get method over HTTP. @@ -780,8 +969,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: ~.compute.InstanceGroup: @@ -803,6 +994,7 @@ def __call__( """ http_options = _BaseInstanceGroupsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseInstanceGroupsRestTransport._BaseGet._get_transcoded_request( @@ -817,6 +1009,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.compute_v1.InstanceGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._Get._get_response( self._host, @@ -837,7 +1056,29 @@ def __call__( pb_resp = compute.InstanceGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroup.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.compute_v1.InstanceGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseInstanceGroupsRestTransport._BaseInsert, InstanceGroupsRestStub): @@ -873,7 +1114,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -885,8 +1126,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: ~.compute.Operation: @@ -913,6 +1156,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseInstanceGroupsRestTransport._BaseInsert._get_transcoded_request( @@ -931,6 +1175,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.compute_v1.InstanceGroupsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._Insert._get_response( self._host, @@ -952,7 +1223,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseInstanceGroupsRestTransport._BaseList, InstanceGroupsRestStub): @@ -987,7 +1280,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]]] = (), ) -> compute.InstanceGroupList: r"""Call the list method over HTTP. @@ -999,8 +1292,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: ~.compute.InstanceGroupList: @@ -1010,6 +1305,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseInstanceGroupsRestTransport._BaseList._get_transcoded_request( @@ -1024,6 +1320,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.compute_v1.InstanceGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._List._get_response( self._host, @@ -1044,7 +1367,29 @@ def __call__( pb_resp = compute.InstanceGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupList.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.compute_v1.InstanceGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -1082,7 +1427,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]]] = (), ) -> compute.InstanceGroupsListInstances: r"""Call the list instances method over HTTP. @@ -1094,8 +1439,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: ~.compute.InstanceGroupsListInstances: @@ -1105,6 +1452,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseInstanceGroupsRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -1119,6 +1467,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 = 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.compute_v1.InstanceGroupsClient.ListInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._ListInstances._get_response( self._host, @@ -1140,7 +1515,31 @@ def __call__( pb_resp = compute.InstanceGroupsListInstances.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupsListInstances.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.compute_v1.InstanceGroupsClient.list_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveInstances( @@ -1178,7 +1577,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]]] = (), ) -> compute.Operation: r"""Call the remove instances method over HTTP. @@ -1190,8 +1589,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: ~.compute.Operation: @@ -1218,6 +1619,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseRemoveInstances._get_http_options() ) + request, metadata = self._interceptor.pre_remove_instances( request, metadata ) @@ -1234,6 +1636,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 = 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.compute_v1.InstanceGroupsClient.RemoveInstances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "RemoveInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._RemoveInstances._get_response( self._host, @@ -1255,7 +1684,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupsClient.remove_instances", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "RemoveInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetNamedPorts( @@ -1293,7 +1744,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]]] = (), ) -> compute.Operation: r"""Call the set named ports method over HTTP. @@ -1305,8 +1756,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: ~.compute.Operation: @@ -1333,6 +1786,7 @@ def __call__( http_options = ( _BaseInstanceGroupsRestTransport._BaseSetNamedPorts._get_http_options() ) + request, metadata = self._interceptor.pre_set_named_ports(request, metadata) transcoded_request = _BaseInstanceGroupsRestTransport._BaseSetNamedPorts._get_transcoded_request( http_options, request @@ -1347,6 +1801,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 = 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.compute_v1.InstanceGroupsClient.SetNamedPorts", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "SetNamedPorts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceGroupsRestTransport._SetNamedPorts._get_response( self._host, @@ -1368,7 +1849,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_named_ports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceGroupsClient.set_named_ports", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceGroups", + "rpcName": "SetNamedPorts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/client.py index 16e2a1cf0315..fbdce52b0ada 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.types import compute @@ -565,6 +575,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( @@ -631,6 +645,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.compute_v1.InstanceSettingsServiceClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceSettingsService", + "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.compute.v1.InstanceSettingsService", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetInstanceSettingRequest, dict]] = None, @@ -639,7 +676,7 @@ def get( zone: 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]]] = (), ) -> compute.InstanceSettings: r"""Get Instance settings. @@ -688,8 +725,10 @@ def sample_get(): 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.compute_v1.types.InstanceSettings: @@ -761,7 +800,7 @@ def patch_unary( instance_settings_resource: Optional[compute.InstanceSettings] = 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]]] = (), ) -> compute.Operation: r"""Patch Instance settings @@ -817,8 +856,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -887,7 +928,7 @@ def patch( instance_settings_resource: Optional[compute.InstanceSettings] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patch Instance settings @@ -943,8 +984,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/transports/rest.py index 67edd878453e..959a34cac6a4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_settings_service/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 @@ -37,6 +37,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, @@ -85,8 +93,10 @@ def post_patch(self, response): def pre_get( self, request: compute.GetInstanceSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInstanceSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInstanceSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -106,8 +116,10 @@ def post_get(self, response: compute.InstanceSettings) -> compute.InstanceSettin def pre_patch( self, request: compute.PatchInstanceSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchInstanceSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchInstanceSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -250,7 +262,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]]] = (), ) -> compute.InstanceSettings: r"""Call the get method over HTTP. @@ -262,8 +274,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: ~.compute.InstanceSettings: @@ -280,6 +294,7 @@ def __call__( http_options = ( _BaseInstanceSettingsServiceRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInstanceSettingsServiceRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -290,6 +305,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 = 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.compute_v1.InstanceSettingsServiceClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceSettingsService", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceSettingsServiceRestTransport._Get._get_response( self._host, @@ -310,7 +352,29 @@ def __call__( pb_resp = compute.InstanceSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceSettings.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.compute_v1.InstanceSettingsServiceClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceSettingsService", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -349,7 +413,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -361,8 +425,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: ~.compute.Operation: @@ -389,6 +455,7 @@ def __call__( http_options = ( _BaseInstanceSettingsServiceRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseInstanceSettingsServiceRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -403,6 +470,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 = 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.compute_v1.InstanceSettingsServiceClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceSettingsService", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceSettingsServiceRestTransport._Patch._get_response( self._host, @@ -424,7 +518,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceSettingsServiceClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceSettingsService", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/client.py index e7a398af57cf..cc5f086155c4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instance_templates import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.InstanceTemplatesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "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.compute.v1.InstanceTemplates", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. To prevent @@ -686,8 +723,10 @@ def sample_aggregated_list(): 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.compute_v1.services.instance_templates.pagers.AggregatedListPager: @@ -760,7 +799,7 @@ def delete_unary( instance_template: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It @@ -814,8 +853,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -881,7 +922,7 @@ def delete( instance_template: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It @@ -935,8 +976,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1026,7 +1069,7 @@ def get( instance_template: 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]]] = (), ) -> compute.InstanceTemplate: r"""Returns the specified instance template. @@ -1075,8 +1118,10 @@ def sample_get(): 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.compute_v1.types.InstanceTemplate: @@ -1155,7 +1200,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1207,8 +1252,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.cloud.compute_v1.types.Policy: @@ -1294,7 +1341,7 @@ def insert_unary( instance_template_resource: Optional[compute.InstanceTemplate] = 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]]] = (), ) -> compute.Operation: r"""Creates an instance template in the specified project using the data that is included in the request. If you @@ -1347,8 +1394,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1409,7 +1458,7 @@ def insert( instance_template_resource: Optional[compute.InstanceTemplate] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instance template in the specified project using the data that is included in the request. If you @@ -1462,8 +1511,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1547,7 +1598,7 @@ def list( project: 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.ListPager: r"""Retrieves a list of instance templates that are contained within the specified project. @@ -1592,8 +1643,10 @@ def sample_list(): 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.compute_v1.services.instance_templates.pagers.ListPager: @@ -1671,7 +1724,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1728,8 +1781,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.cloud.compute_v1.types.Policy: @@ -1826,7 +1881,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -1883,8 +1938,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/pagers.py index 0349e1bdc1c0..dad5c3e4d632 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/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 = compute.AggregatedListInstanceTemplatesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListInstanceTemplatesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/transports/rest.py index 337ab160359f..1d63419650cd 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instance_templates/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 @@ -37,6 +37,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, @@ -133,9 +141,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListInstanceTemplatesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListInstanceTemplatesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListInstanceTemplatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -158,8 +167,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInstanceTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -179,8 +190,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInstanceTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -200,8 +213,11 @@ def post_get(self, response: compute.InstanceTemplate) -> compute.InstanceTempla def pre_get_iam_policy( self, request: compute.GetIamPolicyInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -221,8 +237,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInstanceTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -242,8 +260,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInstanceTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInstanceTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInstanceTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -265,8 +285,11 @@ def post_list( def pre_set_iam_policy( self, request: compute.SetIamPolicyInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -286,9 +309,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsInstanceTemplateRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -434,7 +458,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]]] = (), ) -> compute.InstanceTemplateAggregatedList: r"""Call the aggregated list method over HTTP. @@ -446,8 +470,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: ~.compute.InstanceTemplateAggregatedList: @@ -459,6 +485,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseInstanceTemplatesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -469,6 +496,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 = 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.compute_v1.InstanceTemplatesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._AggregatedList._get_response( self._host, @@ -489,7 +543,31 @@ def __call__( pb_resp = compute.InstanceTemplateAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceTemplateAggregatedList.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.compute_v1.InstanceTemplatesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -526,7 +604,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -538,8 +616,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: ~.compute.Operation: @@ -566,6 +646,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseInstanceTemplatesRestTransport._BaseDelete._get_transcoded_request( @@ -580,6 +661,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.compute_v1.InstanceTemplatesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._Delete._get_response( self._host, @@ -600,7 +708,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceTemplatesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseInstanceTemplatesRestTransport._BaseGet, InstanceTemplatesRestStub): @@ -635,7 +765,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]]] = (), ) -> compute.InstanceTemplate: r"""Call the get method over HTTP. @@ -647,8 +777,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: ~.compute.InstanceTemplate: @@ -671,6 +803,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseInstanceTemplatesRestTransport._BaseGet._get_transcoded_request( @@ -685,6 +818,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.compute_v1.InstanceTemplatesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._Get._get_response( self._host, @@ -705,7 +865,29 @@ def __call__( pb_resp = compute.InstanceTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceTemplate.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.compute_v1.InstanceTemplatesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -742,7 +924,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -754,8 +936,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: ~.compute.Policy: @@ -788,6 +972,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseInstanceTemplatesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -798,6 +983,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 = 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.compute_v1.InstanceTemplatesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._GetIamPolicy._get_response( self._host, @@ -818,7 +1030,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstanceTemplatesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -856,7 +1090,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -868,8 +1102,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: ~.compute.Operation: @@ -896,6 +1132,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseInstanceTemplatesRestTransport._BaseInsert._get_transcoded_request( @@ -916,6 +1153,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.compute_v1.InstanceTemplatesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._Insert._get_response( self._host, @@ -937,7 +1201,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstanceTemplatesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -974,7 +1260,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]]] = (), ) -> compute.InstanceTemplateList: r"""Call the list method over HTTP. @@ -986,8 +1272,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: ~.compute.InstanceTemplateList: @@ -997,6 +1285,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseInstanceTemplatesRestTransport._BaseList._get_transcoded_request( @@ -1011,6 +1300,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.compute_v1.InstanceTemplatesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._List._get_response( self._host, @@ -1031,7 +1347,29 @@ def __call__( pb_resp = compute.InstanceTemplateList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceTemplateList.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.compute_v1.InstanceTemplatesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1069,7 +1407,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1081,8 +1419,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: ~.compute.Policy: @@ -1115,6 +1455,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseInstanceTemplatesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1129,6 +1470,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 = 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.compute_v1.InstanceTemplatesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._SetIamPolicy._get_response( self._host, @@ -1150,7 +1518,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstanceTemplatesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1189,7 +1579,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1201,8 +1591,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: ~.compute.TestPermissionsResponse: @@ -1212,6 +1604,7 @@ def __call__( http_options = ( _BaseInstanceTemplatesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1228,6 +1621,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 = 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.compute_v1.InstanceTemplatesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstanceTemplatesRestTransport._TestIamPermissions._get_response( self._host, @@ -1249,7 +1669,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.InstanceTemplatesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.InstanceTemplates", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/client.py index 19127f30fa54..73fb9fb7f43f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instances import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.InstancesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "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.compute.v1.Instances", + "credentialsType": None, + }, + ) + def add_access_config_unary( self, request: Optional[Union[compute.AddAccessConfigInstanceRequest, dict]] = None, @@ -629,7 +666,7 @@ def add_access_config_unary( access_config_resource: Optional[compute.AccessConfig] = 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]]] = (), ) -> compute.Operation: r"""Adds an access config to an instance's network interface. @@ -700,8 +737,10 @@ def sample_add_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -779,7 +818,7 @@ def add_access_config( access_config_resource: Optional[compute.AccessConfig] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds an access config to an instance's network interface. @@ -850,8 +889,10 @@ def sample_add_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -957,7 +998,7 @@ def add_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds existing resource policies to an instance. You can only add one policy right now which will be applied @@ -1021,8 +1062,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -1103,7 +1146,7 @@ def add_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds existing resource policies to an instance. You can only add one policy right now which will be applied @@ -1167,8 +1210,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -1267,7 +1312,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this @@ -1316,8 +1361,10 @@ def sample_aggregated_list(): 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.compute_v1.services.instances.pagers.AggregatedListPager: @@ -1390,7 +1437,7 @@ def attach_disk_unary( attached_disk_resource: Optional[compute.AttachedDisk] = 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]]] = (), ) -> compute.Operation: r"""Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. @@ -1456,8 +1503,10 @@ def sample_attach_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -1530,7 +1579,7 @@ def attach_disk( attached_disk_resource: Optional[compute.AttachedDisk] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. @@ -1596,8 +1645,10 @@ def sample_attach_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -1696,7 +1747,7 @@ def bulk_insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates multiple instances. Count specifies the number of instances to create. For more information, see @@ -1754,8 +1805,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1830,7 +1883,7 @@ def bulk_insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates multiple instances. Count specifies the number of instances to create. For more information, see @@ -1888,8 +1941,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1987,7 +2042,7 @@ def delete_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified Instance resource. For more information, see Deleting an instance. @@ -2047,8 +2102,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -2118,7 +2175,7 @@ def delete( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified Instance resource. For more information, see Deleting an instance. @@ -2178,8 +2235,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -2278,7 +2337,7 @@ def delete_access_config_unary( network_interface: 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]]] = (), ) -> compute.Operation: r"""Deletes an access config from an instance's network interface. @@ -2350,8 +2409,10 @@ def sample_delete_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -2431,7 +2492,7 @@ def delete_access_config( network_interface: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes an access config from an instance's network interface. @@ -2503,8 +2564,10 @@ def sample_delete_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -2606,7 +2669,7 @@ def detach_disk_unary( device_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]]] = (), ) -> compute.Operation: r"""Detaches a disk from an instance. @@ -2673,8 +2736,10 @@ def sample_detach_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -2747,7 +2812,7 @@ def detach_disk( device_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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Detaches a disk from an instance. @@ -2814,8 +2879,10 @@ def sample_detach_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -2912,7 +2979,7 @@ def get( instance: 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]]] = (), ) -> compute.Instance: r"""Returns the specified Instance resource. @@ -2970,8 +3037,10 @@ def sample_get(): 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.compute_v1.types.Instance: @@ -3047,7 +3116,7 @@ def get_effective_firewalls( network_interface: 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]]] = (), ) -> compute.InstancesGetEffectiveFirewallsResponse: r"""Returns effective firewalls applied to an interface of the instance. @@ -3115,8 +3184,10 @@ def sample_get_effective_firewalls(): 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.compute_v1.types.InstancesGetEffectiveFirewallsResponse: @@ -3188,7 +3259,7 @@ def get_guest_attributes( instance: 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]]] = (), ) -> compute.GuestAttributes: r"""Returns the specified guest attributes entry. @@ -3247,8 +3318,10 @@ def sample_get_guest_attributes(): 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.compute_v1.types.GuestAttributes: @@ -3316,7 +3389,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -3376,8 +3449,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.cloud.compute_v1.types.Policy: @@ -3467,7 +3542,7 @@ def get_screenshot( instance: 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]]] = (), ) -> compute.Screenshot: r"""Returns the screenshot from the specified instance. @@ -3526,8 +3601,10 @@ def sample_get_screenshot(): 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.compute_v1.types.Screenshot: @@ -3597,7 +3674,7 @@ def get_serial_port_output( instance: 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]]] = (), ) -> compute.SerialPortOutput: r"""Returns the last 1 MB of serial port output from the specified instance. @@ -3657,8 +3734,10 @@ def sample_get_serial_port_output(): 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.compute_v1.types.SerialPortOutput: @@ -3728,7 +3807,7 @@ def get_shielded_instance_identity( instance: 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]]] = (), ) -> compute.ShieldedInstanceIdentity: r"""Returns the Shielded Instance Identity of an instance @@ -3787,8 +3866,10 @@ def sample_get_shielded_instance_identity(): 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.compute_v1.types.ShieldedInstanceIdentity: @@ -3858,7 +3939,7 @@ def insert_unary( instance_resource: Optional[compute.Instance] = 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]]] = (), ) -> compute.Operation: r"""Creates an instance resource in the specified project using the data included in the request. @@ -3915,8 +3996,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -3985,7 +4068,7 @@ def insert( instance_resource: Optional[compute.Instance] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instance resource in the specified project using the data included in the request. @@ -4042,8 +4125,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -4136,7 +4221,7 @@ def list( zone: 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.ListPager: r"""Retrieves the list of instances contained within the specified zone. @@ -4188,8 +4273,10 @@ def sample_list(): 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.compute_v1.services.instances.pagers.ListPager: @@ -4270,7 +4357,7 @@ def list_referrers( instance: 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.ListReferrersPager: r"""Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the @@ -4337,8 +4424,10 @@ def sample_list_referrers(): 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.compute_v1.services.instances.pagers.ListReferrersPager: @@ -4424,7 +4513,7 @@ def perform_maintenance_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Perform a manual maintenance on the instance. @@ -4483,8 +4572,10 @@ def sample_perform_maintenance(): 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.api_core.extended_operation.ExtendedOperation: @@ -4556,7 +4647,7 @@ def perform_maintenance( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Perform a manual maintenance on the instance. @@ -4615,8 +4706,10 @@ def sample_perform_maintenance(): 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.api_core.extended_operation.ExtendedOperation: @@ -4716,7 +4809,7 @@ def remove_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes resource policies from an instance. @@ -4778,8 +4871,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -4865,7 +4960,7 @@ def remove_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes resource policies from an instance. @@ -4927,8 +5022,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -5034,7 +5131,7 @@ def reset_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more @@ -5095,8 +5192,10 @@ def sample_reset(): 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.api_core.extended_operation.ExtendedOperation: @@ -5166,7 +5265,7 @@ def reset( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more @@ -5227,8 +5326,10 @@ def sample_reset(): 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.api_core.extended_operation.ExtendedOperation: @@ -5323,7 +5424,7 @@ def resume_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Resumes an instance that was suspended using the instances().suspend method. @@ -5383,8 +5484,10 @@ def sample_resume(): 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.api_core.extended_operation.ExtendedOperation: @@ -5454,7 +5557,7 @@ def resume( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Resumes an instance that was suspended using the instances().suspend method. @@ -5514,8 +5617,10 @@ def sample_resume(): 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.api_core.extended_operation.ExtendedOperation: @@ -5612,7 +5717,7 @@ def send_diagnostic_interrupt( instance: 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]]] = (), ) -> compute.SendDiagnosticInterruptInstanceResponse: r"""Sends diagnostic interrupt to the instance. @@ -5671,8 +5776,10 @@ def sample_send_diagnostic_interrupt(): 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.compute_v1.types.SendDiagnosticInterruptInstanceResponse: @@ -5747,7 +5854,7 @@ def set_deletion_protection_unary( 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]]] = (), ) -> compute.Operation: r"""Sets deletion protection on the instance. @@ -5806,8 +5913,10 @@ def sample_set_deletion_protection(): 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.api_core.extended_operation.ExtendedOperation: @@ -5879,7 +5988,7 @@ def set_deletion_protection( 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets deletion protection on the instance. @@ -5938,8 +6047,10 @@ def sample_set_deletion_protection(): 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.api_core.extended_operation.ExtendedOperation: @@ -6036,7 +6147,7 @@ def set_disk_auto_delete_unary( device_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]]] = (), ) -> compute.Operation: r"""Sets the auto-delete flag for a disk attached to an instance. @@ -6112,8 +6223,10 @@ def sample_set_disk_auto_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -6189,7 +6302,7 @@ def set_disk_auto_delete( device_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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the auto-delete flag for a disk attached to an instance. @@ -6265,8 +6378,10 @@ def sample_set_disk_auto_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -6366,7 +6481,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -6431,8 +6546,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.cloud.compute_v1.types.Policy: @@ -6531,7 +6648,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. @@ -6596,8 +6713,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -6676,7 +6795,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. @@ -6741,8 +6860,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -6848,7 +6969,7 @@ def set_machine_resources_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. @@ -6913,8 +7034,10 @@ def sample_set_machine_resources(): 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.api_core.extended_operation.ExtendedOperation: @@ -6995,7 +7118,7 @@ def set_machine_resources( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. @@ -7060,8 +7183,10 @@ def sample_set_machine_resources(): 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.api_core.extended_operation.ExtendedOperation: @@ -7165,7 +7290,7 @@ def set_machine_type_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the machine type for a stopped instance to the machine type specified in the request. @@ -7230,8 +7355,10 @@ def sample_set_machine_type(): 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.api_core.extended_operation.ExtendedOperation: @@ -7310,7 +7437,7 @@ def set_machine_type( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the machine type for a stopped instance to the machine type specified in the request. @@ -7375,8 +7502,10 @@ def sample_set_machine_type(): 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.api_core.extended_operation.ExtendedOperation: @@ -7478,7 +7607,7 @@ def set_metadata_unary( metadata_resource: Optional[compute.Metadata] = 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]]] = (), ) -> compute.Operation: r"""Sets metadata for the specified instance to the data included in the request. @@ -7543,8 +7672,10 @@ def sample_set_metadata(): 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.api_core.extended_operation.ExtendedOperation: @@ -7617,7 +7748,7 @@ def set_metadata( metadata_resource: Optional[compute.Metadata] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets metadata for the specified instance to the data included in the request. @@ -7682,8 +7813,10 @@ def sample_set_metadata(): 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.api_core.extended_operation.ExtendedOperation: @@ -7783,7 +7916,7 @@ def set_min_cpu_platform_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped @@ -7850,8 +7983,10 @@ def sample_set_min_cpu_platform(): 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.api_core.extended_operation.ExtendedOperation: @@ -7930,7 +8065,7 @@ def set_min_cpu_platform( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped @@ -7997,8 +8132,10 @@ def sample_set_min_cpu_platform(): 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.api_core.extended_operation.ExtendedOperation: @@ -8102,7 +8239,7 @@ def set_name_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets name of an instance. @@ -8164,8 +8301,10 @@ def sample_set_name(): 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.api_core.extended_operation.ExtendedOperation: @@ -8244,7 +8383,7 @@ def set_name( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets name of an instance. @@ -8306,8 +8445,10 @@ def sample_set_name(): 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.api_core.extended_operation.ExtendedOperation: @@ -8409,7 +8550,7 @@ def set_scheduling_unary( scheduling_resource: Optional[compute.Scheduling] = 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]]] = (), ) -> compute.Operation: r"""Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in @@ -8476,8 +8617,10 @@ def sample_set_scheduling(): 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.api_core.extended_operation.ExtendedOperation: @@ -8550,7 +8693,7 @@ def set_scheduling( scheduling_resource: Optional[compute.Scheduling] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in @@ -8617,8 +8760,10 @@ def sample_set_scheduling(): 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.api_core.extended_operation.ExtendedOperation: @@ -8718,7 +8863,7 @@ def set_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google @@ -8785,8 +8930,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -8865,7 +9012,7 @@ def set_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google @@ -8932,8 +9079,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -9037,7 +9186,7 @@ def set_service_account_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the service account on the instance. For more information, read Changing the service account and @@ -9103,8 +9252,10 @@ def sample_set_service_account(): 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.api_core.extended_operation.ExtendedOperation: @@ -9183,7 +9334,7 @@ def set_service_account( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the service account on the instance. For more information, read Changing the service account and @@ -9249,8 +9400,10 @@ def sample_set_service_account(): 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.api_core.extended_operation.ExtendedOperation: @@ -9356,7 +9509,7 @@ def set_shielded_instance_integrity_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running @@ -9423,8 +9576,10 @@ def sample_set_shielded_instance_integrity_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.api_core.extended_operation.ExtendedOperation: @@ -9509,7 +9664,7 @@ def set_shielded_instance_integrity_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running @@ -9576,8 +9731,10 @@ def sample_set_shielded_instance_integrity_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.api_core.extended_operation.ExtendedOperation: @@ -9683,7 +9840,7 @@ def set_tags_unary( tags_resource: Optional[compute.Tags] = 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]]] = (), ) -> compute.Operation: r"""Sets network tags for the specified instance to the data included in the request. @@ -9748,8 +9905,10 @@ def sample_set_tags(): 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.api_core.extended_operation.ExtendedOperation: @@ -9822,7 +9981,7 @@ def set_tags( tags_resource: Optional[compute.Tags] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets network tags for the specified instance to the data included in the request. @@ -9887,8 +10046,10 @@ def sample_set_tags(): 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.api_core.extended_operation.ExtendedOperation: @@ -9987,7 +10148,7 @@ def simulate_maintenance_event_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. @@ -10047,8 +10208,10 @@ def sample_simulate_maintenance_event(): 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.api_core.extended_operation.ExtendedOperation: @@ -10122,7 +10285,7 @@ def simulate_maintenance_event( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. @@ -10182,8 +10345,10 @@ def sample_simulate_maintenance_event(): 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.api_core.extended_operation.ExtendedOperation: @@ -10280,7 +10445,7 @@ def start_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Starts an instance that was stopped using the instances().stop method. For more information, see @@ -10341,8 +10506,10 @@ def sample_start(): 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.api_core.extended_operation.ExtendedOperation: @@ -10412,7 +10579,7 @@ def start( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Starts an instance that was stopped using the instances().stop method. For more information, see @@ -10473,8 +10640,10 @@ def sample_start(): 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.api_core.extended_operation.ExtendedOperation: @@ -10574,7 +10743,7 @@ def start_with_encryption_key_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Starts an instance that was stopped using the instances().stop method. For more information, see @@ -10640,8 +10809,10 @@ def sample_start_with_encryption_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -10729,7 +10900,7 @@ def start_with_encryption_key( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Starts an instance that was stopped using the instances().stop method. For more information, see @@ -10795,8 +10966,10 @@ def sample_start_with_encryption_key(): 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.api_core.extended_operation.ExtendedOperation: @@ -10904,7 +11077,7 @@ def stop_unary( instance: 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]]] = (), ) -> compute.Operation: r"""Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. @@ -10968,8 +11141,10 @@ def sample_stop(): 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.api_core.extended_operation.ExtendedOperation: @@ -11039,7 +11214,7 @@ def stop( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. @@ -11103,8 +11278,10 @@ def sample_stop(): 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.api_core.extended_operation.ExtendedOperation: @@ -11199,7 +11376,7 @@ def suspend_unary( instance: 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]]] = (), ) -> compute.Operation: r"""This method suspends a running instance, saving its state to persistent storage, and allows you to resume @@ -11266,8 +11443,10 @@ def sample_suspend(): 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.api_core.extended_operation.ExtendedOperation: @@ -11337,7 +11516,7 @@ def suspend( instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""This method suspends a running instance, saving its state to persistent storage, and allows you to resume @@ -11404,8 +11583,10 @@ def sample_suspend(): 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.api_core.extended_operation.ExtendedOperation: @@ -11505,7 +11686,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -11570,8 +11751,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -11646,7 +11829,7 @@ def update_unary( instance_resource: Optional[compute.Instance] = 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]]] = (), ) -> compute.Operation: r"""Updates an instance only if the necessary resources are available. This method can update only a specific @@ -11713,8 +11896,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -11787,7 +11972,7 @@ def update( instance_resource: Optional[compute.Instance] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an instance only if the necessary resources are available. This method can update only a specific @@ -11854,8 +12039,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -11956,7 +12143,7 @@ def update_access_config_unary( access_config_resource: Optional[compute.AccessConfig] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified access config from an instance's network interface with the data included in @@ -12029,8 +12216,10 @@ def sample_update_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -12110,7 +12299,7 @@ def update_access_config( access_config_resource: Optional[compute.AccessConfig] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified access config from an instance's network interface with the data included in @@ -12183,8 +12372,10 @@ def sample_update_access_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -12288,7 +12479,7 @@ def update_display_device_unary( display_device_resource: Optional[compute.DisplayDevice] = 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]]] = (), ) -> compute.Operation: r"""Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This @@ -12355,8 +12546,10 @@ def sample_update_display_device(): 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.api_core.extended_operation.ExtendedOperation: @@ -12431,7 +12624,7 @@ def update_display_device( display_device_resource: Optional[compute.DisplayDevice] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This @@ -12498,8 +12691,10 @@ def sample_update_display_device(): 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.api_core.extended_operation.ExtendedOperation: @@ -12600,7 +12795,7 @@ def update_network_interface_unary( network_interface_resource: Optional[compute.NetworkInterface] = 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]]] = (), ) -> compute.Operation: r"""Updates an instance's network interface. This method can only update an interface's alias IP range and @@ -12676,8 +12871,10 @@ def sample_update_network_interface(): 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.api_core.extended_operation.ExtendedOperation: @@ -12757,7 +12954,7 @@ def update_network_interface( network_interface_resource: Optional[compute.NetworkInterface] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an instance's network interface. This method can only update an interface's alias IP range and @@ -12833,8 +13030,10 @@ def sample_update_network_interface(): 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.api_core.extended_operation.ExtendedOperation: @@ -12940,7 +13139,7 @@ def update_shielded_instance_config_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This @@ -13007,8 +13206,10 @@ def sample_update_shielded_instance_config(): 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.api_core.extended_operation.ExtendedOperation: @@ -13091,7 +13292,7 @@ def update_shielded_instance_config( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This @@ -13158,8 +13359,10 @@ def sample_update_shielded_instance_config(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/pagers.py index a52295e469be..46ea9560aeb4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/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 = compute.AggregatedListInstancesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListInstancesRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListReferrersInstancesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/transports/rest.py index 6a9194f6c447..0dda8127c528 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instances/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 @@ -37,6 +37,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, @@ -453,8 +461,10 @@ def post_update_shielded_instance_config(self, response): def pre_add_access_config( self, request: compute.AddAccessConfigInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddAccessConfigInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddAccessConfigInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_access_config Override in a subclass to manipulate the request or metadata @@ -474,8 +484,11 @@ def post_add_access_config(self, response: compute.Operation) -> compute.Operati def pre_add_resource_policies( self, request: compute.AddResourcePoliciesInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddResourcePoliciesInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddResourcePoliciesInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_resource_policies Override in a subclass to manipulate the request or metadata @@ -497,8 +510,10 @@ def post_add_resource_policies( def pre_aggregated_list( self, request: compute.AggregatedListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -520,8 +535,10 @@ def post_aggregated_list( def pre_attach_disk( self, request: compute.AttachDiskInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AttachDiskInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AttachDiskInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for attach_disk Override in a subclass to manipulate the request or metadata @@ -541,8 +558,10 @@ def post_attach_disk(self, response: compute.Operation) -> compute.Operation: def pre_bulk_insert( self, request: compute.BulkInsertInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.BulkInsertInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.BulkInsertInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for bulk_insert Override in a subclass to manipulate the request or metadata @@ -562,8 +581,8 @@ def post_bulk_insert(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -583,8 +602,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_access_config( self, request: compute.DeleteAccessConfigInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteAccessConfigInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteAccessConfigInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_access_config Override in a subclass to manipulate the request or metadata @@ -606,8 +628,10 @@ def post_delete_access_config( def pre_detach_disk( self, request: compute.DetachDiskInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DetachDiskInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DetachDiskInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for detach_disk Override in a subclass to manipulate the request or metadata @@ -625,8 +649,10 @@ def post_detach_disk(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -646,8 +672,11 @@ def post_get(self, response: compute.Instance) -> compute.Instance: def pre_get_effective_firewalls( self, request: compute.GetEffectiveFirewallsInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetEffectiveFirewallsInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetEffectiveFirewallsInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_effective_firewalls Override in a subclass to manipulate the request or metadata @@ -669,8 +698,11 @@ def post_get_effective_firewalls( def pre_get_guest_attributes( self, request: compute.GetGuestAttributesInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetGuestAttributesInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetGuestAttributesInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_guest_attributes Override in a subclass to manipulate the request or metadata @@ -692,8 +724,10 @@ def post_get_guest_attributes( def pre_get_iam_policy( self, request: compute.GetIamPolicyInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -713,8 +747,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_get_screenshot( self, request: compute.GetScreenshotInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetScreenshotInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetScreenshotInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_screenshot Override in a subclass to manipulate the request or metadata @@ -734,8 +770,11 @@ def post_get_screenshot(self, response: compute.Screenshot) -> compute.Screensho def pre_get_serial_port_output( self, request: compute.GetSerialPortOutputInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetSerialPortOutputInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetSerialPortOutputInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_serial_port_output Override in a subclass to manipulate the request or metadata @@ -757,9 +796,10 @@ def post_get_serial_port_output( def pre_get_shielded_instance_identity( self, request: compute.GetShieldedInstanceIdentityInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetShieldedInstanceIdentityInstanceRequest, Sequence[Tuple[str, str]] + compute.GetShieldedInstanceIdentityInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_shielded_instance_identity @@ -782,8 +822,8 @@ def post_get_shielded_instance_identity( def pre_insert( self, request: compute.InsertInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -801,8 +841,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListInstancesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListInstancesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListInstancesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -822,8 +864,10 @@ def post_list(self, response: compute.InstanceList) -> compute.InstanceList: def pre_list_referrers( self, request: compute.ListReferrersInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListReferrersInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListReferrersInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_referrers Override in a subclass to manipulate the request or metadata @@ -845,8 +889,11 @@ def post_list_referrers( def pre_perform_maintenance( self, request: compute.PerformMaintenanceInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PerformMaintenanceInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PerformMaintenanceInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for perform_maintenance Override in a subclass to manipulate the request or metadata @@ -868,9 +915,10 @@ def post_perform_maintenance( def pre_remove_resource_policies( self, request: compute.RemoveResourcePoliciesInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveResourcePoliciesInstanceRequest, Sequence[Tuple[str, str]] + compute.RemoveResourcePoliciesInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_resource_policies @@ -891,8 +939,10 @@ def post_remove_resource_policies( return response def pre_reset( - self, request: compute.ResetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ResetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ResetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ResetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reset Override in a subclass to manipulate the request or metadata @@ -912,8 +962,8 @@ def post_reset(self, response: compute.Operation) -> compute.Operation: def pre_resume( self, request: compute.ResumeInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ResumeInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ResumeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resume Override in a subclass to manipulate the request or metadata @@ -933,9 +983,10 @@ def post_resume(self, response: compute.Operation) -> compute.Operation: def pre_send_diagnostic_interrupt( self, request: compute.SendDiagnosticInterruptInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SendDiagnosticInterruptInstanceRequest, Sequence[Tuple[str, str]] + compute.SendDiagnosticInterruptInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for send_diagnostic_interrupt @@ -958,8 +1009,11 @@ def post_send_diagnostic_interrupt( def pre_set_deletion_protection( self, request: compute.SetDeletionProtectionInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetDeletionProtectionInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetDeletionProtectionInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_deletion_protection Override in a subclass to manipulate the request or metadata @@ -981,8 +1035,11 @@ def post_set_deletion_protection( def pre_set_disk_auto_delete( self, request: compute.SetDiskAutoDeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetDiskAutoDeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetDiskAutoDeleteInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_disk_auto_delete Override in a subclass to manipulate the request or metadata @@ -1004,8 +1061,10 @@ def post_set_disk_auto_delete( def pre_set_iam_policy( self, request: compute.SetIamPolicyInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -1025,8 +1084,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -1046,8 +1107,11 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_set_machine_resources( self, request: compute.SetMachineResourcesInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetMachineResourcesInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetMachineResourcesInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_machine_resources Override in a subclass to manipulate the request or metadata @@ -1069,8 +1133,10 @@ def post_set_machine_resources( def pre_set_machine_type( self, request: compute.SetMachineTypeInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetMachineTypeInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetMachineTypeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_machine_type Override in a subclass to manipulate the request or metadata @@ -1090,8 +1156,10 @@ def post_set_machine_type(self, response: compute.Operation) -> compute.Operatio def pre_set_metadata( self, request: compute.SetMetadataInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetMetadataInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetMetadataInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_metadata Override in a subclass to manipulate the request or metadata @@ -1111,8 +1179,11 @@ def post_set_metadata(self, response: compute.Operation) -> compute.Operation: def pre_set_min_cpu_platform( self, request: compute.SetMinCpuPlatformInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetMinCpuPlatformInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetMinCpuPlatformInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_min_cpu_platform Override in a subclass to manipulate the request or metadata @@ -1134,8 +1205,8 @@ def post_set_min_cpu_platform( def pre_set_name( self, request: compute.SetNameInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetNameInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.SetNameInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_name Override in a subclass to manipulate the request or metadata @@ -1155,8 +1226,10 @@ def post_set_name(self, response: compute.Operation) -> compute.Operation: def pre_set_scheduling( self, request: compute.SetSchedulingInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetSchedulingInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetSchedulingInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_scheduling Override in a subclass to manipulate the request or metadata @@ -1176,8 +1249,11 @@ def post_set_scheduling(self, response: compute.Operation) -> compute.Operation: def pre_set_security_policy( self, request: compute.SetSecurityPolicyInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetSecurityPolicyInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetSecurityPolicyInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_security_policy Override in a subclass to manipulate the request or metadata @@ -1199,8 +1275,11 @@ def post_set_security_policy( def pre_set_service_account( self, request: compute.SetServiceAccountInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetServiceAccountInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetServiceAccountInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_service_account Override in a subclass to manipulate the request or metadata @@ -1222,10 +1301,10 @@ def post_set_service_account( def pre_set_shielded_instance_integrity_policy( self, request: compute.SetShieldedInstanceIntegrityPolicyInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetShieldedInstanceIntegrityPolicyInstanceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_shielded_instance_integrity_policy @@ -1248,8 +1327,8 @@ def post_set_shielded_instance_integrity_policy( def pre_set_tags( self, request: compute.SetTagsInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetTagsInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.SetTagsInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_tags Override in a subclass to manipulate the request or metadata @@ -1269,9 +1348,10 @@ def post_set_tags(self, response: compute.Operation) -> compute.Operation: def pre_simulate_maintenance_event( self, request: compute.SimulateMaintenanceEventInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SimulateMaintenanceEventInstanceRequest, Sequence[Tuple[str, str]] + compute.SimulateMaintenanceEventInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for simulate_maintenance_event @@ -1292,8 +1372,10 @@ def post_simulate_maintenance_event( return response def pre_start( - self, request: compute.StartInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.StartInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.StartInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.StartInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start Override in a subclass to manipulate the request or metadata @@ -1313,9 +1395,10 @@ def post_start(self, response: compute.Operation) -> compute.Operation: def pre_start_with_encryption_key( self, request: compute.StartWithEncryptionKeyInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.StartWithEncryptionKeyInstanceRequest, Sequence[Tuple[str, str]] + compute.StartWithEncryptionKeyInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for start_with_encryption_key @@ -1336,8 +1419,10 @@ def post_start_with_encryption_key( return response def pre_stop( - self, request: compute.StopInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.StopInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.StopInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.StopInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop Override in a subclass to manipulate the request or metadata @@ -1357,8 +1442,8 @@ def post_stop(self, response: compute.Operation) -> compute.Operation: def pre_suspend( self, request: compute.SuspendInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SuspendInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.SuspendInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for suspend Override in a subclass to manipulate the request or metadata @@ -1378,8 +1463,11 @@ def post_suspend(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -1401,8 +1489,8 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -1422,8 +1510,11 @@ def post_update(self, response: compute.Operation) -> compute.Operation: def pre_update_access_config( self, request: compute.UpdateAccessConfigInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateAccessConfigInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateAccessConfigInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_access_config Override in a subclass to manipulate the request or metadata @@ -1445,8 +1536,11 @@ def post_update_access_config( def pre_update_display_device( self, request: compute.UpdateDisplayDeviceInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateDisplayDeviceInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateDisplayDeviceInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_display_device Override in a subclass to manipulate the request or metadata @@ -1468,9 +1562,10 @@ def post_update_display_device( def pre_update_network_interface( self, request: compute.UpdateNetworkInterfaceInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.UpdateNetworkInterfaceInstanceRequest, Sequence[Tuple[str, str]] + compute.UpdateNetworkInterfaceInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_network_interface @@ -1493,9 +1588,10 @@ def post_update_network_interface( def pre_update_shielded_instance_config( self, request: compute.UpdateShieldedInstanceConfigInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.UpdateShieldedInstanceConfigInstanceRequest, Sequence[Tuple[str, str]] + compute.UpdateShieldedInstanceConfigInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_shielded_instance_config @@ -1641,7 +1737,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]]] = (), ) -> compute.Operation: r"""Call the add access config method over HTTP. @@ -1653,8 +1749,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: ~.compute.Operation: @@ -1681,6 +1779,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseAddAccessConfig._get_http_options() ) + request, metadata = self._interceptor.pre_add_access_config( request, metadata ) @@ -1701,6 +1800,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.compute_v1.InstancesClient.AddAccessConfig", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AddAccessConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._AddAccessConfig._get_response( self._host, @@ -1722,7 +1848,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_access_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.add_access_config", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AddAccessConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddResourcePolicies( @@ -1760,7 +1908,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]]] = (), ) -> compute.Operation: r"""Call the add resource policies method over HTTP. @@ -1772,8 +1920,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: ~.compute.Operation: @@ -1800,6 +1950,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseAddResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_add_resource_policies( request, metadata ) @@ -1816,6 +1967,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 = 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.compute_v1.InstancesClient.AddResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AddResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._AddResourcePolicies._get_response( self._host, @@ -1837,7 +2015,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.add_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AddResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -1874,7 +2074,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]]] = (), ) -> compute.InstanceAggregatedList: r"""Call the aggregated list method over HTTP. @@ -1886,8 +2086,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: ~.compute.InstanceAggregatedList: @@ -1897,6 +2099,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseAggregatedList._get_transcoded_request( @@ -1911,6 +2114,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.compute_v1.InstancesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._AggregatedList._get_response( self._host, @@ -1931,7 +2161,29 @@ def __call__( pb_resp = compute.InstanceAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceAggregatedList.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.compute_v1.InstancesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AttachDisk(_BaseInstancesRestTransport._BaseAttachDisk, InstancesRestStub): @@ -1967,7 +2219,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]]] = (), ) -> compute.Operation: r"""Call the attach disk method over HTTP. @@ -1979,8 +2231,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: ~.compute.Operation: @@ -2007,6 +2261,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseAttachDisk._get_http_options() ) + request, metadata = self._interceptor.pre_attach_disk(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseAttachDisk._get_transcoded_request( @@ -2025,6 +2280,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.compute_v1.InstancesClient.AttachDisk", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AttachDisk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._AttachDisk._get_response( self._host, @@ -2046,7 +2328,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_attach_disk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.attach_disk", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "AttachDisk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BulkInsert(_BaseInstancesRestTransport._BaseBulkInsert, InstancesRestStub): @@ -2082,7 +2386,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]]] = (), ) -> compute.Operation: r"""Call the bulk insert method over HTTP. @@ -2094,8 +2398,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: ~.compute.Operation: @@ -2122,6 +2428,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseBulkInsert._get_http_options() ) + request, metadata = self._interceptor.pre_bulk_insert(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseBulkInsert._get_transcoded_request( @@ -2140,6 +2447,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.compute_v1.InstancesClient.BulkInsert", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "BulkInsert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._BulkInsert._get_response( self._host, @@ -2161,7 +2495,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.bulk_insert", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "BulkInsert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseInstancesRestTransport._BaseDelete, InstancesRestStub): @@ -2196,7 +2552,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -2208,8 +2564,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: ~.compute.Operation: @@ -2234,6 +2592,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseDelete._get_transcoded_request( @@ -2248,6 +2607,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.compute_v1.InstancesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Delete._get_response( self._host, @@ -2268,7 +2654,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAccessConfig( @@ -2305,7 +2713,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]]] = (), ) -> compute.Operation: r"""Call the delete access config method over HTTP. @@ -2317,8 +2725,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: ~.compute.Operation: @@ -2345,6 +2755,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseDeleteAccessConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_access_config( request, metadata ) @@ -2357,6 +2768,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 = 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.compute_v1.InstancesClient.DeleteAccessConfig", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "DeleteAccessConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._DeleteAccessConfig._get_response( self._host, @@ -2377,7 +2815,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_access_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.delete_access_config", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "DeleteAccessConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetachDisk(_BaseInstancesRestTransport._BaseDetachDisk, InstancesRestStub): @@ -2412,7 +2872,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]]] = (), ) -> compute.Operation: r"""Call the detach disk method over HTTP. @@ -2424,8 +2884,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: ~.compute.Operation: @@ -2452,6 +2914,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseDetachDisk._get_http_options() ) + request, metadata = self._interceptor.pre_detach_disk(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseDetachDisk._get_transcoded_request( @@ -2466,6 +2929,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.compute_v1.InstancesClient.DetachDisk", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "DetachDisk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._DetachDisk._get_response( self._host, @@ -2486,7 +2976,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_disk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.detach_disk", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "DetachDisk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseInstancesRestTransport._BaseGet, InstancesRestStub): @@ -2521,7 +3033,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]]] = (), ) -> compute.Instance: r"""Call the get method over HTTP. @@ -2532,8 +3044,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: ~.compute.Instance: @@ -2546,6 +3060,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseGet._get_transcoded_request( @@ -2558,6 +3073,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 = 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.compute_v1.InstancesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Get._get_response( self._host, @@ -2578,7 +3120,29 @@ def __call__( pb_resp = compute.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Instance.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.compute_v1.InstancesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveFirewalls( @@ -2615,7 +3179,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]]] = (), ) -> compute.InstancesGetEffectiveFirewallsResponse: r"""Call the get effective firewalls method over HTTP. @@ -2627,8 +3191,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: ~.compute.InstancesGetEffectiveFirewallsResponse: @@ -2638,6 +3204,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetEffectiveFirewalls._get_http_options() ) + request, metadata = self._interceptor.pre_get_effective_firewalls( request, metadata ) @@ -2650,6 +3217,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 = 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.compute_v1.InstancesClient.GetEffectiveFirewalls", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetEffectiveFirewalls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetEffectiveFirewalls._get_response( self._host, @@ -2670,7 +3264,31 @@ def __call__( pb_resp = compute.InstancesGetEffectiveFirewallsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_firewalls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InstancesGetEffectiveFirewallsResponse.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.compute_v1.InstancesClient.get_effective_firewalls", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetEffectiveFirewalls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGuestAttributes( @@ -2707,7 +3325,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]]] = (), ) -> compute.GuestAttributes: r"""Call the get guest attributes method over HTTP. @@ -2719,8 +3337,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: ~.compute.GuestAttributes: @@ -2730,6 +3350,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetGuestAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_get_guest_attributes( request, metadata ) @@ -2742,6 +3363,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 = 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.compute_v1.InstancesClient.GetGuestAttributes", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetGuestAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetGuestAttributes._get_response( self._host, @@ -2762,7 +3410,29 @@ def __call__( pb_resp = compute.GuestAttributes.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_guest_attributes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.GuestAttributes.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.compute_v1.InstancesClient.get_guest_attributes", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetGuestAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -2799,7 +3469,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -2811,8 +3481,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: ~.compute.Policy: @@ -2845,6 +3517,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -2859,6 +3532,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.compute_v1.InstancesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetIamPolicy._get_response( self._host, @@ -2879,7 +3579,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstancesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetScreenshot( @@ -2916,7 +3638,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]]] = (), ) -> compute.Screenshot: r"""Call the get screenshot method over HTTP. @@ -2928,8 +3650,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: ~.compute.Screenshot: @@ -2939,6 +3663,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetScreenshot._get_http_options() ) + request, metadata = self._interceptor.pre_get_screenshot(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseGetScreenshot._get_transcoded_request( @@ -2953,6 +3678,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.compute_v1.InstancesClient.GetScreenshot", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetScreenshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetScreenshot._get_response( self._host, @@ -2973,7 +3725,29 @@ def __call__( pb_resp = compute.Screenshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_screenshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Screenshot.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.compute_v1.InstancesClient.get_screenshot", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetScreenshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSerialPortOutput( @@ -3010,7 +3784,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]]] = (), ) -> compute.SerialPortOutput: r"""Call the get serial port output method over HTTP. @@ -3022,8 +3796,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: ~.compute.SerialPortOutput: @@ -3033,6 +3809,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetSerialPortOutput._get_http_options() ) + request, metadata = self._interceptor.pre_get_serial_port_output( request, metadata ) @@ -3045,6 +3822,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 = 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.compute_v1.InstancesClient.GetSerialPortOutput", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetSerialPortOutput", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetSerialPortOutput._get_response( self._host, @@ -3065,7 +3869,29 @@ def __call__( pb_resp = compute.SerialPortOutput.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_serial_port_output(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SerialPortOutput.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.compute_v1.InstancesClient.get_serial_port_output", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetSerialPortOutput", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetShieldedInstanceIdentity( @@ -3102,7 +3928,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]]] = (), ) -> compute.ShieldedInstanceIdentity: r"""Call the get shielded instance identity method over HTTP. @@ -3115,8 +3941,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: ~.compute.ShieldedInstanceIdentity: @@ -3126,6 +3954,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetShieldedInstanceIdentity._get_http_options() ) + request, metadata = self._interceptor.pre_get_shielded_instance_identity( request, metadata ) @@ -3138,6 +3967,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 = 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.compute_v1.InstancesClient.GetShieldedInstanceIdentity", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetShieldedInstanceIdentity", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstancesRestTransport._GetShieldedInstanceIdentity._get_response( @@ -3160,7 +4016,31 @@ def __call__( pb_resp = compute.ShieldedInstanceIdentity.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_shielded_instance_identity(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ShieldedInstanceIdentity.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.compute_v1.InstancesClient.get_shielded_instance_identity", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "GetShieldedInstanceIdentity", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseInstancesRestTransport._BaseInsert, InstancesRestStub): @@ -3196,7 +4076,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -3208,8 +4088,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: ~.compute.Operation: @@ -3234,6 +4116,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseInsert._get_transcoded_request( @@ -3252,6 +4135,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.compute_v1.InstancesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Insert._get_response( self._host, @@ -3273,7 +4183,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseInstancesRestTransport._BaseList, InstancesRestStub): @@ -3308,7 +4240,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]]] = (), ) -> compute.InstanceList: r"""Call the list method over HTTP. @@ -3319,8 +4251,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: ~.compute.InstanceList: @@ -3328,6 +4262,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseList._get_transcoded_request( @@ -3340,6 +4275,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 = 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.compute_v1.InstancesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._List._get_response( self._host, @@ -3360,7 +4322,29 @@ def __call__( pb_resp = compute.InstanceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceList.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.compute_v1.InstancesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReferrers( @@ -3397,7 +4381,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]]] = (), ) -> compute.InstanceListReferrers: r"""Call the list referrers method over HTTP. @@ -3409,8 +4393,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: ~.compute.InstanceListReferrers: @@ -3422,6 +4408,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseListReferrers._get_http_options() ) + request, metadata = self._interceptor.pre_list_referrers(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseListReferrers._get_transcoded_request( @@ -3436,6 +4423,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.compute_v1.InstancesClient.ListReferrers", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "ListReferrers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._ListReferrers._get_response( self._host, @@ -3456,7 +4470,29 @@ def __call__( pb_resp = compute.InstanceListReferrers.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_referrers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceListReferrers.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.compute_v1.InstancesClient.list_referrers", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "ListReferrers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PerformMaintenance( @@ -3493,7 +4529,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]]] = (), ) -> compute.Operation: r"""Call the perform maintenance method over HTTP. @@ -3505,8 +4541,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: ~.compute.Operation: @@ -3533,6 +4571,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BasePerformMaintenance._get_http_options() ) + request, metadata = self._interceptor.pre_perform_maintenance( request, metadata ) @@ -3545,6 +4584,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 = 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.compute_v1.InstancesClient.PerformMaintenance", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "PerformMaintenance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._PerformMaintenance._get_response( self._host, @@ -3565,7 +4631,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_perform_maintenance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.perform_maintenance", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "PerformMaintenance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveResourcePolicies( @@ -3603,7 +4691,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]]] = (), ) -> compute.Operation: r"""Call the remove resource policies method over HTTP. @@ -3615,8 +4703,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: ~.compute.Operation: @@ -3643,6 +4733,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseRemoveResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_remove_resource_policies( request, metadata ) @@ -3659,6 +4750,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 = 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.compute_v1.InstancesClient.RemoveResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "RemoveResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._RemoveResourcePolicies._get_response( self._host, @@ -3680,7 +4798,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.remove_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "RemoveResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Reset(_BaseInstancesRestTransport._BaseReset, InstancesRestStub): @@ -3715,7 +4855,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]]] = (), ) -> compute.Operation: r"""Call the reset method over HTTP. @@ -3727,8 +4867,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: ~.compute.Operation: @@ -3753,6 +4895,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseReset._get_http_options() + request, metadata = self._interceptor.pre_reset(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseReset._get_transcoded_request( @@ -3767,6 +4910,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.compute_v1.InstancesClient.Reset", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Reset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Reset._get_response( self._host, @@ -3787,7 +4957,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.reset", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Reset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resume(_BaseInstancesRestTransport._BaseResume, InstancesRestStub): @@ -3822,7 +5014,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]]] = (), ) -> compute.Operation: r"""Call the resume method over HTTP. @@ -3834,8 +5026,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: ~.compute.Operation: @@ -3860,6 +5054,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseResume._get_http_options() + request, metadata = self._interceptor.pre_resume(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseResume._get_transcoded_request( @@ -3874,6 +5069,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.compute_v1.InstancesClient.Resume", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Resume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Resume._get_response( self._host, @@ -3894,7 +5116,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.resume", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Resume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SendDiagnosticInterrupt( @@ -3931,7 +5175,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]]] = (), ) -> compute.SendDiagnosticInterruptInstanceResponse: r"""Call the send diagnostic interrupt method over HTTP. @@ -3943,8 +5187,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: ~.compute.SendDiagnosticInterruptInstanceResponse: @@ -3957,6 +5203,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSendDiagnosticInterrupt._get_http_options() ) + request, metadata = self._interceptor.pre_send_diagnostic_interrupt( request, metadata ) @@ -3969,6 +5216,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 = 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.compute_v1.InstancesClient.SendDiagnosticInterrupt", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SendDiagnosticInterrupt", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SendDiagnosticInterrupt._get_response( self._host, @@ -3989,7 +5263,33 @@ def __call__( pb_resp = compute.SendDiagnosticInterruptInstanceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_send_diagnostic_interrupt(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.SendDiagnosticInterruptInstanceResponse.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.compute_v1.InstancesClient.send_diagnostic_interrupt", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SendDiagnosticInterrupt", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDeletionProtection( @@ -4026,7 +5326,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]]] = (), ) -> compute.Operation: r"""Call the set deletion protection method over HTTP. @@ -4038,8 +5338,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: ~.compute.Operation: @@ -4066,6 +5368,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetDeletionProtection._get_http_options() ) + request, metadata = self._interceptor.pre_set_deletion_protection( request, metadata ) @@ -4078,6 +5381,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 = 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.compute_v1.InstancesClient.SetDeletionProtection", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetDeletionProtection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetDeletionProtection._get_response( self._host, @@ -4098,7 +5428,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_deletion_protection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_deletion_protection", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetDeletionProtection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDiskAutoDelete( @@ -4135,7 +5487,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]]] = (), ) -> compute.Operation: r"""Call the set disk auto delete method over HTTP. @@ -4147,8 +5499,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: ~.compute.Operation: @@ -4175,6 +5529,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetDiskAutoDelete._get_http_options() ) + request, metadata = self._interceptor.pre_set_disk_auto_delete( request, metadata ) @@ -4187,6 +5542,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 = 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.compute_v1.InstancesClient.SetDiskAutoDelete", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetDiskAutoDelete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetDiskAutoDelete._get_response( self._host, @@ -4207,7 +5589,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_disk_auto_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_disk_auto_delete", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetDiskAutoDelete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -4245,7 +5649,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -4257,8 +5661,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: ~.compute.Policy: @@ -4291,6 +5697,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4309,6 +5716,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.compute_v1.InstancesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetIamPolicy._get_response( self._host, @@ -4330,7 +5764,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstancesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseInstancesRestTransport._BaseSetLabels, InstancesRestStub): @@ -4366,7 +5822,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -4378,8 +5834,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: ~.compute.Operation: @@ -4406,6 +5864,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetLabels._get_transcoded_request( @@ -4424,6 +5883,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.compute_v1.InstancesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetLabels._get_response( self._host, @@ -4445,7 +5931,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMachineResources( @@ -4483,7 +5991,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]]] = (), ) -> compute.Operation: r"""Call the set machine resources method over HTTP. @@ -4495,8 +6003,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: ~.compute.Operation: @@ -4523,6 +6033,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetMachineResources._get_http_options() ) + request, metadata = self._interceptor.pre_set_machine_resources( request, metadata ) @@ -4539,6 +6050,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 = 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.compute_v1.InstancesClient.SetMachineResources", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMachineResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetMachineResources._get_response( self._host, @@ -4560,7 +6098,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_machine_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_machine_resources", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMachineResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMachineType( @@ -4598,7 +6158,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]]] = (), ) -> compute.Operation: r"""Call the set machine type method over HTTP. @@ -4610,8 +6170,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: ~.compute.Operation: @@ -4638,6 +6200,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetMachineType._get_http_options() ) + request, metadata = self._interceptor.pre_set_machine_type( request, metadata ) @@ -4660,6 +6223,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.compute_v1.InstancesClient.SetMachineType", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMachineType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetMachineType._get_response( self._host, @@ -4681,7 +6271,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_machine_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_machine_type", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMachineType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMetadata(_BaseInstancesRestTransport._BaseSetMetadata, InstancesRestStub): @@ -4717,7 +6329,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]]] = (), ) -> compute.Operation: r"""Call the set metadata method over HTTP. @@ -4729,8 +6341,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: ~.compute.Operation: @@ -4757,6 +6371,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetMetadata._get_http_options() ) + request, metadata = self._interceptor.pre_set_metadata(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetMetadata._get_transcoded_request( @@ -4775,6 +6390,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.compute_v1.InstancesClient.SetMetadata", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMetadata", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetMetadata._get_response( self._host, @@ -4796,7 +6438,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_metadata(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_metadata", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMetadata", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetMinCpuPlatform( @@ -4834,7 +6498,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]]] = (), ) -> compute.Operation: r"""Call the set min cpu platform method over HTTP. @@ -4846,8 +6510,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: ~.compute.Operation: @@ -4874,6 +6540,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetMinCpuPlatform._get_http_options() ) + request, metadata = self._interceptor.pre_set_min_cpu_platform( request, metadata ) @@ -4890,6 +6557,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 = 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.compute_v1.InstancesClient.SetMinCpuPlatform", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMinCpuPlatform", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetMinCpuPlatform._get_response( self._host, @@ -4911,7 +6605,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_min_cpu_platform(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_min_cpu_platform", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetMinCpuPlatform", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetName(_BaseInstancesRestTransport._BaseSetName, InstancesRestStub): @@ -4947,7 +6663,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]]] = (), ) -> compute.Operation: r"""Call the set name method over HTTP. @@ -4959,8 +6675,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: ~.compute.Operation: @@ -4985,6 +6703,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseSetName._get_http_options() + request, metadata = self._interceptor.pre_set_name(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetName._get_transcoded_request( @@ -5003,6 +6722,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.compute_v1.InstancesClient.SetName", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetName", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetName._get_response( self._host, @@ -5024,7 +6770,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_name(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_name", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetName", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetScheduling( @@ -5062,7 +6830,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]]] = (), ) -> compute.Operation: r"""Call the set scheduling method over HTTP. @@ -5074,8 +6842,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: ~.compute.Operation: @@ -5102,6 +6872,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetScheduling._get_http_options() ) + request, metadata = self._interceptor.pre_set_scheduling(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetScheduling._get_transcoded_request( @@ -5122,6 +6893,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.compute_v1.InstancesClient.SetScheduling", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetScheduling", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetScheduling._get_response( self._host, @@ -5143,7 +6941,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_scheduling(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_scheduling", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetScheduling", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSecurityPolicy( @@ -5181,7 +7001,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]]] = (), ) -> compute.Operation: r"""Call the set security policy method over HTTP. @@ -5193,8 +7013,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: ~.compute.Operation: @@ -5221,6 +7043,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_security_policy( request, metadata ) @@ -5237,6 +7060,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 = 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.compute_v1.InstancesClient.SetSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetSecurityPolicy._get_response( self._host, @@ -5258,7 +7108,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetServiceAccount( @@ -5296,7 +7168,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]]] = (), ) -> compute.Operation: r"""Call the set service account method over HTTP. @@ -5308,8 +7180,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: ~.compute.Operation: @@ -5336,6 +7210,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetServiceAccount._get_http_options() ) + request, metadata = self._interceptor.pre_set_service_account( request, metadata ) @@ -5352,6 +7227,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 = 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.compute_v1.InstancesClient.SetServiceAccount", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetServiceAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetServiceAccount._get_response( self._host, @@ -5373,7 +7275,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_service_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_service_account", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetServiceAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetShieldedInstanceIntegrityPolicy( @@ -5412,7 +7336,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]]] = (), ) -> compute.Operation: r"""Call the set shielded instance integrity policy method over HTTP. @@ -5425,8 +7349,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: ~.compute.Operation: @@ -5453,6 +7379,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSetShieldedInstanceIntegrityPolicy._get_http_options() ) + ( request, metadata, @@ -5472,6 +7399,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 = 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.compute_v1.InstancesClient.SetShieldedInstanceIntegrityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetShieldedInstanceIntegrityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetShieldedInstanceIntegrityPolicy._get_response( self._host, @@ -5493,7 +7447,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_shielded_instance_integrity_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_shielded_instance_integrity_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetShieldedInstanceIntegrityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetTags(_BaseInstancesRestTransport._BaseSetTags, InstancesRestStub): @@ -5529,7 +7505,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]]] = (), ) -> compute.Operation: r"""Call the set tags method over HTTP. @@ -5541,8 +7517,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: ~.compute.Operation: @@ -5567,6 +7545,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseSetTags._get_http_options() + request, metadata = self._interceptor.pre_set_tags(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSetTags._get_transcoded_request( @@ -5585,6 +7564,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.compute_v1.InstancesClient.SetTags", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetTags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SetTags._get_response( self._host, @@ -5606,7 +7612,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_tags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.set_tags", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SetTags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SimulateMaintenanceEvent( @@ -5643,7 +7671,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]]] = (), ) -> compute.Operation: r"""Call the simulate maintenance event method over HTTP. @@ -5656,8 +7684,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: ~.compute.Operation: @@ -5684,6 +7714,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseSimulateMaintenanceEvent._get_http_options() ) + request, metadata = self._interceptor.pre_simulate_maintenance_event( request, metadata ) @@ -5696,6 +7727,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 = 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.compute_v1.InstancesClient.SimulateMaintenanceEvent", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SimulateMaintenanceEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._SimulateMaintenanceEvent._get_response( self._host, @@ -5716,7 +7774,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_simulate_maintenance_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.simulate_maintenance_event", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "SimulateMaintenanceEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Start(_BaseInstancesRestTransport._BaseStart, InstancesRestStub): @@ -5751,7 +7831,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]]] = (), ) -> compute.Operation: r"""Call the start method over HTTP. @@ -5763,8 +7843,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: ~.compute.Operation: @@ -5789,6 +7871,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseStart._get_http_options() + request, metadata = self._interceptor.pre_start(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseStart._get_transcoded_request( @@ -5803,6 +7886,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.compute_v1.InstancesClient.Start", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Start", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Start._get_response( self._host, @@ -5823,7 +7933,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.start", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Start", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartWithEncryptionKey( @@ -5861,7 +7993,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]]] = (), ) -> compute.Operation: r"""Call the start with encryption key method over HTTP. @@ -5873,8 +8005,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: ~.compute.Operation: @@ -5901,6 +8035,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseStartWithEncryptionKey._get_http_options() ) + request, metadata = self._interceptor.pre_start_with_encryption_key( request, metadata ) @@ -5917,6 +8052,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 = 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.compute_v1.InstancesClient.StartWithEncryptionKey", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "StartWithEncryptionKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._StartWithEncryptionKey._get_response( self._host, @@ -5938,7 +8100,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_with_encryption_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.start_with_encryption_key", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "StartWithEncryptionKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Stop(_BaseInstancesRestTransport._BaseStop, InstancesRestStub): @@ -5973,7 +8157,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]]] = (), ) -> compute.Operation: r"""Call the stop method over HTTP. @@ -5984,8 +8168,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: ~.compute.Operation: @@ -6010,6 +8196,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseStop._get_http_options() + request, metadata = self._interceptor.pre_stop(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseStop._get_transcoded_request( @@ -6022,6 +8209,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 = 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.compute_v1.InstancesClient.Stop", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Stop", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Stop._get_response( self._host, @@ -6042,7 +8256,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.stop", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Stop", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Suspend(_BaseInstancesRestTransport._BaseSuspend, InstancesRestStub): @@ -6077,7 +8313,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]]] = (), ) -> compute.Operation: r"""Call the suspend method over HTTP. @@ -6089,8 +8325,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: ~.compute.Operation: @@ -6115,6 +8353,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseSuspend._get_http_options() + request, metadata = self._interceptor.pre_suspend(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseSuspend._get_transcoded_request( @@ -6129,6 +8368,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.compute_v1.InstancesClient.Suspend", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Suspend", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Suspend._get_response( self._host, @@ -6149,7 +8415,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suspend(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.suspend", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Suspend", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -6187,7 +8475,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -6199,8 +8487,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: ~.compute.TestPermissionsResponse: @@ -6210,6 +8500,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -6226,6 +8517,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 = 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.compute_v1.InstancesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._TestIamPermissions._get_response( self._host, @@ -6247,7 +8565,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.InstancesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseInstancesRestTransport._BaseUpdate, InstancesRestStub): @@ -6283,7 +8623,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -6295,8 +8635,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: ~.compute.Operation: @@ -6321,6 +8663,7 @@ def __call__( """ http_options = _BaseInstancesRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseUpdate._get_transcoded_request( @@ -6339,6 +8682,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.compute_v1.InstancesClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._Update._get_response( self._host, @@ -6360,7 +8730,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccessConfig( @@ -6398,7 +8790,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]]] = (), ) -> compute.Operation: r"""Call the update access config method over HTTP. @@ -6410,8 +8802,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: ~.compute.Operation: @@ -6438,6 +8832,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseUpdateAccessConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_access_config( request, metadata ) @@ -6454,6 +8849,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 = 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.compute_v1.InstancesClient.UpdateAccessConfig", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateAccessConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._UpdateAccessConfig._get_response( self._host, @@ -6475,7 +8897,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_access_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.update_access_config", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateAccessConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDisplayDevice( @@ -6513,7 +8957,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]]] = (), ) -> compute.Operation: r"""Call the update display device method over HTTP. @@ -6525,8 +8969,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: ~.compute.Operation: @@ -6553,6 +8999,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseUpdateDisplayDevice._get_http_options() ) + request, metadata = self._interceptor.pre_update_display_device( request, metadata ) @@ -6569,6 +9016,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 = 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.compute_v1.InstancesClient.UpdateDisplayDevice", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateDisplayDevice", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._UpdateDisplayDevice._get_response( self._host, @@ -6590,7 +9064,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_display_device(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.update_display_device", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateDisplayDevice", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetworkInterface( @@ -6628,7 +9124,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]]] = (), ) -> compute.Operation: r"""Call the update network interface method over HTTP. @@ -6640,8 +9136,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: ~.compute.Operation: @@ -6668,6 +9166,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseUpdateNetworkInterface._get_http_options() ) + request, metadata = self._interceptor.pre_update_network_interface( request, metadata ) @@ -6684,6 +9183,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 = 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.compute_v1.InstancesClient.UpdateNetworkInterface", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateNetworkInterface", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._UpdateNetworkInterface._get_response( self._host, @@ -6705,7 +9231,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_network_interface(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.update_network_interface", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateNetworkInterface", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateShieldedInstanceConfig( @@ -6743,7 +9291,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]]] = (), ) -> compute.Operation: r"""Call the update shielded instance config method over HTTP. @@ -6756,8 +9304,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: ~.compute.Operation: @@ -6784,6 +9334,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseUpdateShieldedInstanceConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_shielded_instance_config( request, metadata ) @@ -6800,6 +9351,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 = 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.compute_v1.InstancesClient.UpdateShieldedInstanceConfig", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateShieldedInstanceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InstancesRestTransport._UpdateShieldedInstanceConfig._get_response( @@ -6823,7 +9401,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_shielded_instance_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstancesClient.update_shielded_instance_config", + extra={ + "serviceName": "google.cloud.compute.v1.Instances", + "rpcName": "UpdateShieldedInstanceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/client.py index f1b39d2a1396..f5d8ed835d02 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.instant_snapshots import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.InstantSnapshotsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "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.compute.v1.InstantSnapshots", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -635,7 +672,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of instantSnapshots. To prevent failure, Google recommends that you set the @@ -681,8 +718,10 @@ def sample_aggregated_list(): 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.compute_v1.services.instant_snapshots.pagers.AggregatedListPager: @@ -754,7 +793,7 @@ def delete_unary( instant_snapshot: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified InstantSnapshot resource. Keep in mind that deleting a single instantSnapshot might not @@ -820,8 +859,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -891,7 +932,7 @@ def delete( instant_snapshot: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified InstantSnapshot resource. Keep in mind that deleting a single instantSnapshot might not @@ -957,8 +998,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1053,7 +1096,7 @@ def get( instant_snapshot: 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]]] = (), ) -> compute.InstantSnapshot: r"""Returns the specified InstantSnapshot resource in the specified zone. @@ -1113,8 +1156,10 @@ def sample_get(): 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.compute_v1.types.InstantSnapshot: @@ -1187,7 +1232,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1247,8 +1292,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.cloud.compute_v1.types.Policy: @@ -1338,7 +1385,7 @@ def insert_unary( instant_snapshot_resource: Optional[compute.InstantSnapshot] = 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]]] = (), ) -> compute.Operation: r"""Creates an instant snapshot in the specified zone. @@ -1392,8 +1439,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1462,7 +1511,7 @@ def insert( instant_snapshot_resource: Optional[compute.InstantSnapshot] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instant snapshot in the specified zone. @@ -1516,8 +1565,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1610,7 +1661,7 @@ def list( zone: 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.ListPager: r"""Retrieves the list of InstantSnapshot resources contained within the specified zone. @@ -1663,8 +1714,10 @@ def sample_list(): 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.compute_v1.services.instant_snapshots.pagers.ListPager: @@ -1748,7 +1801,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1813,8 +1866,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.cloud.compute_v1.types.Policy: @@ -1911,7 +1966,7 @@ def set_labels_unary( zone_set_labels_request_resource: Optional[compute.ZoneSetLabelsRequest] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a instantSnapshot in the given zone. To learn more about labels, read the Labeling @@ -1977,8 +2032,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2055,7 +2112,7 @@ def set_labels( zone_set_labels_request_resource: Optional[compute.ZoneSetLabelsRequest] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a instantSnapshot in the given zone. To learn more about labels, read the Labeling @@ -2121,8 +2178,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2228,7 +2287,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2293,8 +2352,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/pagers.py index d7e92fb8f398..fbc85a010794 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/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 = compute.AggregatedListInstantSnapshotsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListInstantSnapshotsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/transports/rest.py index 3c73e81faaf8..d2cce9d83f8d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/instant_snapshots/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 @@ -37,6 +37,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, @@ -141,9 +149,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListInstantSnapshotsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListInstantSnapshotsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListInstantSnapshotsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -166,8 +175,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInstantSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -187,8 +198,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInstantSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -208,8 +221,11 @@ def post_get(self, response: compute.InstantSnapshot) -> compute.InstantSnapshot def pre_get_iam_policy( self, request: compute.GetIamPolicyInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -229,8 +245,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInstantSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -250,8 +268,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInstantSnapshotsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInstantSnapshotsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInstantSnapshotsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -273,8 +293,11 @@ def post_list( def pre_set_iam_policy( self, request: compute.SetIamPolicyInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -294,8 +317,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsInstantSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -315,9 +340,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsInstantSnapshotRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -462,7 +488,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]]] = (), ) -> compute.InstantSnapshotAggregatedList: r"""Call the aggregated list method over HTTP. @@ -474,8 +500,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: ~.compute.InstantSnapshotAggregatedList: @@ -485,6 +513,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseInstantSnapshotsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -495,6 +524,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 = 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.compute_v1.InstantSnapshotsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._AggregatedList._get_response( self._host, @@ -515,7 +571,31 @@ def __call__( pb_resp = compute.InstantSnapshotAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstantSnapshotAggregatedList.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.compute_v1.InstantSnapshotsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -552,7 +632,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -564,8 +644,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: ~.compute.Operation: @@ -592,6 +674,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseInstantSnapshotsRestTransport._BaseDelete._get_transcoded_request( @@ -606,6 +689,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.compute_v1.InstantSnapshotsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._Delete._get_response( self._host, @@ -626,7 +736,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstantSnapshotsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseInstantSnapshotsRestTransport._BaseGet, InstantSnapshotsRestStub): @@ -661,7 +793,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]]] = (), ) -> compute.InstantSnapshot: r"""Call the get method over HTTP. @@ -673,8 +805,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: ~.compute.InstantSnapshot: @@ -687,6 +821,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseInstantSnapshotsRestTransport._BaseGet._get_transcoded_request( @@ -701,6 +836,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.compute_v1.InstantSnapshotsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._Get._get_response( self._host, @@ -721,7 +883,29 @@ def __call__( pb_resp = compute.InstantSnapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstantSnapshot.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.compute_v1.InstantSnapshotsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -758,7 +942,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -770,8 +954,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: ~.compute.Policy: @@ -804,6 +990,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseInstantSnapshotsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -814,6 +1001,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 = 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.compute_v1.InstantSnapshotsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._GetIamPolicy._get_response( self._host, @@ -834,7 +1048,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstantSnapshotsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -872,7 +1108,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -884,8 +1120,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: ~.compute.Operation: @@ -912,6 +1150,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseInstantSnapshotsRestTransport._BaseInsert._get_transcoded_request( @@ -932,6 +1171,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.compute_v1.InstantSnapshotsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._Insert._get_response( self._host, @@ -953,7 +1219,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstantSnapshotsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseInstantSnapshotsRestTransport._BaseList, InstantSnapshotsRestStub): @@ -988,7 +1276,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]]] = (), ) -> compute.InstantSnapshotList: r"""Call the list method over HTTP. @@ -1000,8 +1288,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: ~.compute.InstantSnapshotList: @@ -1013,6 +1303,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseInstantSnapshotsRestTransport._BaseList._get_transcoded_request( @@ -1027,6 +1318,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.compute_v1.InstantSnapshotsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._List._get_response( self._host, @@ -1047,7 +1365,29 @@ def __call__( pb_resp = compute.InstantSnapshotList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstantSnapshotList.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.compute_v1.InstantSnapshotsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1085,7 +1425,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1097,8 +1437,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: ~.compute.Policy: @@ -1131,6 +1473,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseInstantSnapshotsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1145,6 +1488,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 = 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.compute_v1.InstantSnapshotsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._SetIamPolicy._get_response( self._host, @@ -1166,7 +1536,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.InstantSnapshotsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1204,7 +1596,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1216,8 +1608,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: ~.compute.Operation: @@ -1244,6 +1638,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseInstantSnapshotsRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -1258,6 +1653,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 = 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.compute_v1.InstantSnapshotsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._SetLabels._get_response( self._host, @@ -1279,7 +1701,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InstantSnapshotsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1318,7 +1762,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1330,8 +1774,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: ~.compute.TestPermissionsResponse: @@ -1341,6 +1787,7 @@ def __call__( http_options = ( _BaseInstantSnapshotsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1357,6 +1804,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 = 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.compute_v1.InstantSnapshotsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstantSnapshotsRestTransport._TestIamPermissions._get_response( self._host, @@ -1378,7 +1852,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.InstantSnapshotsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.InstantSnapshots", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/client.py index 5c532b970d23..d9a865e9f15a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.interconnect_attachments import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.InterconnectAttachmentsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "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.compute.v1.InterconnectAttachments", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -641,7 +678,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of interconnect attachments. To prevent failure, Google recommends that you set the @@ -687,8 +724,10 @@ def sample_aggregated_list(): 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.compute_v1.services.interconnect_attachments.pagers.AggregatedListPager: @@ -764,7 +803,7 @@ def delete_unary( interconnect_attachment: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified interconnect attachment. @@ -821,8 +860,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -894,7 +935,7 @@ def delete( interconnect_attachment: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified interconnect attachment. @@ -951,8 +992,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1047,7 +1090,7 @@ def get( interconnect_attachment: 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]]] = (), ) -> compute.InterconnectAttachment: r"""Returns the specified interconnect attachment. @@ -1104,8 +1147,10 @@ def sample_get(): 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.compute_v1.types.InterconnectAttachment: @@ -1185,7 +1230,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates an InterconnectAttachment in the specified project using the data included in the request. @@ -1240,8 +1285,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1316,7 +1363,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an InterconnectAttachment in the specified project using the data included in the request. @@ -1371,8 +1418,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1469,7 +1518,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of interconnect attachments contained within the specified region. @@ -1520,8 +1569,10 @@ def sample_list(): 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.compute_v1.services.interconnect_attachments.pagers.ListPager: @@ -1607,7 +1658,7 @@ def patch_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified interconnect attachment with the data included in the request. This method supports @@ -1674,8 +1725,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1756,7 +1809,7 @@ def patch( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified interconnect attachment with the data included in the request. This method supports @@ -1823,8 +1876,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1930,7 +1985,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources @@ -1994,8 +2049,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2076,7 +2133,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources @@ -2140,8 +2197,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/pagers.py index 3a21c80b03ef..bce8c395c284 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/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 = compute.AggregatedListInterconnectAttachmentsRequest(request) @@ -146,7 +148,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. @@ -160,8 +162,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 = compute.ListInterconnectAttachmentsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/transports/rest.py index f2209a4cc647..d34a2f82d66b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_attachments/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 @@ -37,6 +37,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, @@ -125,9 +133,10 @@ def post_set_labels(self, response): def pre_aggregated_list( self, request: compute.AggregatedListInterconnectAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListInterconnectAttachmentsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListInterconnectAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -150,8 +159,11 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteInterconnectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInterconnectAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInterconnectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -171,8 +183,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInterconnectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInterconnectAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInterconnectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -194,8 +209,11 @@ def post_get( def pre_insert( self, request: compute.InsertInterconnectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInterconnectAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInterconnectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -215,8 +233,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInterconnectAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInterconnectAttachmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInterconnectAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -238,8 +259,11 @@ def post_list( def pre_patch( self, request: compute.PatchInterconnectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchInterconnectAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchInterconnectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -259,9 +283,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsInterconnectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetLabelsInterconnectAttachmentRequest, Sequence[Tuple[str, str]] + compute.SetLabelsInterconnectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_labels @@ -405,7 +430,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]]] = (), ) -> compute.InterconnectAttachmentAggregatedList: r"""Call the aggregated list method over HTTP. @@ -417,8 +442,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: ~.compute.InterconnectAttachmentAggregatedList: @@ -428,6 +455,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -438,6 +466,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 = 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.compute_v1.InterconnectAttachmentsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( InterconnectAttachmentsRestTransport._AggregatedList._get_response( @@ -460,7 +515,31 @@ def __call__( pb_resp = compute.InterconnectAttachmentAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InterconnectAttachmentAggregatedList.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.compute_v1.InterconnectAttachmentsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -498,7 +577,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -510,8 +589,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: ~.compute.Operation: @@ -538,6 +619,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -548,6 +630,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 = 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.compute_v1.InterconnectAttachmentsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._Delete._get_response( self._host, @@ -568,7 +677,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectAttachmentsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -606,7 +737,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]]] = (), ) -> compute.InterconnectAttachment: r"""Call the get method over HTTP. @@ -618,8 +749,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: ~.compute.InterconnectAttachment: @@ -637,6 +770,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -647,6 +781,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 = 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.compute_v1.InterconnectAttachmentsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._Get._get_response( self._host, @@ -667,7 +828,29 @@ def __call__( pb_resp = compute.InterconnectAttachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectAttachment.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.compute_v1.InterconnectAttachmentsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -706,7 +889,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -718,8 +901,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: ~.compute.Operation: @@ -746,6 +931,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -760,6 +946,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 = 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.compute_v1.InterconnectAttachmentsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._Insert._get_response( self._host, @@ -781,7 +994,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectAttachmentsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -819,7 +1054,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]]] = (), ) -> compute.InterconnectAttachmentList: r"""Call the list method over HTTP. @@ -831,8 +1066,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: ~.compute.InterconnectAttachmentList: @@ -845,6 +1082,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -855,6 +1093,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 = 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.compute_v1.InterconnectAttachmentsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._List._get_response( self._host, @@ -875,7 +1140,31 @@ def __call__( pb_resp = compute.InterconnectAttachmentList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectAttachmentList.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.compute_v1.InterconnectAttachmentsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -914,7 +1203,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -926,8 +1215,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: ~.compute.Operation: @@ -954,6 +1245,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -968,6 +1260,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 = 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.compute_v1.InterconnectAttachmentsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._Patch._get_response( self._host, @@ -989,7 +1308,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectAttachmentsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1028,7 +1369,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1040,8 +1381,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: ~.compute.Operation: @@ -1068,6 +1411,7 @@ def __call__( http_options = ( _BaseInterconnectAttachmentsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseInterconnectAttachmentsRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -1082,6 +1426,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 = 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.compute_v1.InterconnectAttachmentsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectAttachmentsRestTransport._SetLabels._get_response( self._host, @@ -1103,7 +1474,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectAttachmentsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectAttachments", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/client.py index 772bcb8aa217..eac11cd73c81 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/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.compute_v1.services.interconnect_locations import pagers from google.cloud.compute_v1.types import compute @@ -561,6 +571,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( @@ -627,6 +641,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.compute_v1.InterconnectLocationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectLocations", + "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.compute.v1.InterconnectLocations", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetInterconnectLocationRequest, dict]] = None, @@ -635,7 +672,7 @@ def get( interconnect_location: 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]]] = (), ) -> compute.InterconnectLocation: r"""Returns the details for the specified interconnect location. Gets a list of available interconnect @@ -688,8 +725,10 @@ def sample_get(): 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.compute_v1.types.InterconnectLocation: @@ -759,7 +798,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of interconnect locations available to the specified project. @@ -804,8 +843,10 @@ def sample_list(): 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.compute_v1.services.interconnect_locations.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/pagers.py index 17ac4cd9f1a1..35cc5d1c66e3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/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 = compute.ListInterconnectLocationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/transports/rest.py index 578d7ceac65a..f013556c5b60 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_locations/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 @@ -37,6 +37,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, @@ -85,8 +93,10 @@ def post_list(self, response): def pre_get( self, request: compute.GetInterconnectLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInterconnectLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInterconnectLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -108,8 +118,11 @@ def post_get( def pre_list( self, request: compute.ListInterconnectLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInterconnectLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInterconnectLocationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -253,7 +266,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]]] = (), ) -> compute.InterconnectLocation: r"""Call the get method over HTTP. @@ -265,8 +278,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: ~.compute.InterconnectLocation: @@ -283,6 +298,7 @@ def __call__( http_options = ( _BaseInterconnectLocationsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInterconnectLocationsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -295,6 +311,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.compute_v1.InterconnectLocationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectLocations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectLocationsRestTransport._Get._get_response( self._host, @@ -315,7 +358,29 @@ def __call__( pb_resp = compute.InterconnectLocation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectLocation.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.compute_v1.InterconnectLocationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectLocations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -352,7 +417,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]]] = (), ) -> compute.InterconnectLocationList: r"""Call the list method over HTTP. @@ -364,8 +429,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: ~.compute.InterconnectLocationList: @@ -378,6 +445,7 @@ def __call__( http_options = ( _BaseInterconnectLocationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseInterconnectLocationsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -388,6 +456,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 = 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.compute_v1.InterconnectLocationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectLocations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectLocationsRestTransport._List._get_response( self._host, @@ -408,7 +503,31 @@ def __call__( pb_resp = compute.InterconnectLocationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectLocationList.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.compute_v1.InterconnectLocationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectLocations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/client.py index a156fef3d9b9..ff52cd42d4db 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/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.compute_v1.services.interconnect_remote_locations import pagers from google.cloud.compute_v1.types import compute @@ -565,6 +575,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( @@ -633,6 +647,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.compute_v1.InterconnectRemoteLocationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectRemoteLocations", + "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.compute.v1.InterconnectRemoteLocations", + "credentialsType": None, + }, + ) + def get( self, request: Optional[ @@ -643,7 +680,7 @@ def get( interconnect_remote_location: 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]]] = (), ) -> compute.InterconnectRemoteLocation: r"""Returns the details for the specified interconnect remote location. Gets a list of available interconnect @@ -696,8 +733,10 @@ def sample_get(): 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.compute_v1.types.InterconnectRemoteLocation: @@ -770,7 +809,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of interconnect remote locations available to the specified project. @@ -815,8 +854,10 @@ def sample_list(): 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.compute_v1.services.interconnect_remote_locations.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/pagers.py index c91c102216b6..210ff6093e39 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/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 = compute.ListInterconnectRemoteLocationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/transports/rest.py index 7be3a0d4ea82..ae52a5a8d009 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnect_remote_locations/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 @@ -37,6 +37,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, @@ -85,8 +93,11 @@ def post_list(self, response): def pre_get( self, request: compute.GetInterconnectRemoteLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInterconnectRemoteLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetInterconnectRemoteLocationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -108,9 +119,10 @@ def post_get( def pre_list( self, request: compute.ListInterconnectRemoteLocationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListInterconnectRemoteLocationsRequest, Sequence[Tuple[str, str]] + compute.ListInterconnectRemoteLocationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -258,7 +270,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]]] = (), ) -> compute.InterconnectRemoteLocation: r"""Call the get method over HTTP. @@ -270,8 +282,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: ~.compute.InterconnectRemoteLocation: @@ -286,6 +300,7 @@ def __call__( http_options = ( _BaseInterconnectRemoteLocationsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseInterconnectRemoteLocationsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -296,6 +311,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 = 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.compute_v1.InterconnectRemoteLocationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectRemoteLocations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectRemoteLocationsRestTransport._Get._get_response( self._host, @@ -316,7 +358,31 @@ def __call__( pb_resp = compute.InterconnectRemoteLocation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectRemoteLocation.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.compute_v1.InterconnectRemoteLocationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectRemoteLocations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -354,7 +420,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]]] = (), ) -> compute.InterconnectRemoteLocationList: r"""Call the list method over HTTP. @@ -366,8 +432,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: ~.compute.InterconnectRemoteLocationList: @@ -380,6 +448,7 @@ def __call__( http_options = ( _BaseInterconnectRemoteLocationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseInterconnectRemoteLocationsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -390,6 +459,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 = 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.compute_v1.InterconnectRemoteLocationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectRemoteLocations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectRemoteLocationsRestTransport._List._get_response( self._host, @@ -410,7 +506,31 @@ def __call__( pb_resp = compute.InterconnectRemoteLocationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectRemoteLocationList.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.compute_v1.InterconnectRemoteLocationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.InterconnectRemoteLocations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/client.py index 27a2081e65c3..c6903a51675e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.interconnects import pagers @@ -556,6 +566,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( @@ -621,6 +635,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.compute_v1.InterconnectsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "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.compute.v1.Interconnects", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteInterconnectRequest, dict]] = None, @@ -629,7 +666,7 @@ def delete_unary( interconnect: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified Interconnect. @@ -678,8 +715,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -745,7 +784,7 @@ def delete( interconnect: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified Interconnect. @@ -794,8 +833,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -885,7 +926,7 @@ def get( interconnect: 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]]] = (), ) -> compute.Interconnect: r"""Returns the specified Interconnect. Get a list of available Interconnects by making a list() request. @@ -935,8 +976,10 @@ def sample_get(): 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.compute_v1.types.Interconnect: @@ -1008,7 +1051,7 @@ def get_diagnostics( interconnect: 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]]] = (), ) -> compute.InterconnectsGetDiagnosticsResponse: r"""Returns the interconnectDiagnostics for the specified Interconnect. In the event of a global outage, do not @@ -1065,8 +1108,10 @@ def sample_get_diagnostics(): 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.compute_v1.types.InterconnectsGetDiagnosticsResponse: @@ -1134,7 +1179,7 @@ def get_macsec_config( interconnect: 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]]] = (), ) -> compute.InterconnectsGetMacsecConfigResponse: r"""Returns the interconnectMacsecConfig for the specified Interconnect. @@ -1186,8 +1231,10 @@ def sample_get_macsec_config(): 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.compute_v1.types.InterconnectsGetMacsecConfigResponse: @@ -1253,7 +1300,7 @@ def insert_unary( interconnect_resource: Optional[compute.Interconnect] = 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]]] = (), ) -> compute.Operation: r"""Creates an Interconnect in the specified project using the data included in the request. @@ -1302,8 +1349,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1364,7 +1413,7 @@ def insert( interconnect_resource: Optional[compute.Interconnect] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an Interconnect in the specified project using the data included in the request. @@ -1413,8 +1462,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1498,7 +1549,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of Interconnects available to the specified project. @@ -1543,8 +1594,10 @@ def sample_list(): 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.compute_v1.services.interconnects.pagers.ListPager: @@ -1618,7 +1671,7 @@ def patch_unary( interconnect_resource: Optional[compute.Interconnect] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified Interconnect with the data included in the request. This method supports PATCH @@ -1675,8 +1728,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1745,7 +1800,7 @@ def patch( interconnect_resource: Optional[compute.Interconnect] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified Interconnect with the data included in the request. This method supports PATCH @@ -1802,8 +1857,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1898,7 +1955,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. @@ -1955,8 +2012,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2031,7 +2090,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. @@ -2088,8 +2147,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/pagers.py index 42b0697fd0ef..99929f0f6050 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/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 = compute.ListInterconnectsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/transports/rest.py index 306fd40fb8fb..9e6c92da9135 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/interconnects/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 @@ -37,6 +37,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, @@ -133,8 +141,10 @@ def post_set_labels(self, response): def pre_delete( self, request: compute.DeleteInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteInterconnectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -154,8 +164,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetInterconnectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -175,8 +185,11 @@ def post_get(self, response: compute.Interconnect) -> compute.Interconnect: def pre_get_diagnostics( self, request: compute.GetDiagnosticsInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetDiagnosticsInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetDiagnosticsInterconnectRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_diagnostics Override in a subclass to manipulate the request or metadata @@ -198,8 +211,11 @@ def post_get_diagnostics( def pre_get_macsec_config( self, request: compute.GetMacsecConfigInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetMacsecConfigInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetMacsecConfigInterconnectRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_macsec_config Override in a subclass to manipulate the request or metadata @@ -221,8 +237,10 @@ def post_get_macsec_config( def pre_insert( self, request: compute.InsertInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertInterconnectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -242,8 +260,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListInterconnectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListInterconnectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListInterconnectsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -263,8 +283,10 @@ def post_list(self, response: compute.InterconnectList) -> compute.InterconnectL def pre_patch( self, request: compute.PatchInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchInterconnectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -284,8 +306,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsInterconnectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsInterconnectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsInterconnectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -425,7 +449,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -437,8 +461,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: ~.compute.Operation: @@ -465,6 +491,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BaseDelete._get_transcoded_request( @@ -479,6 +506,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.compute_v1.InterconnectsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._Delete._get_response( self._host, @@ -499,7 +553,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseInterconnectsRestTransport._BaseGet, InterconnectsRestStub): @@ -534,7 +610,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]]] = (), ) -> compute.Interconnect: r"""Call the get method over HTTP. @@ -546,8 +622,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: ~.compute.Interconnect: @@ -561,6 +639,7 @@ def __call__( """ http_options = _BaseInterconnectsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BaseGet._get_transcoded_request( @@ -575,6 +654,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.compute_v1.InterconnectsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._Get._get_response( self._host, @@ -595,7 +701,29 @@ def __call__( pb_resp = compute.Interconnect.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Interconnect.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.compute_v1.InterconnectsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDiagnostics( @@ -632,7 +760,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]]] = (), ) -> compute.InterconnectsGetDiagnosticsResponse: r"""Call the get diagnostics method over HTTP. @@ -644,8 +772,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: ~.compute.InterconnectsGetDiagnosticsResponse: @@ -657,6 +787,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BaseGetDiagnostics._get_http_options() ) + request, metadata = self._interceptor.pre_get_diagnostics(request, metadata) transcoded_request = _BaseInterconnectsRestTransport._BaseGetDiagnostics._get_transcoded_request( http_options, request @@ -667,6 +798,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 = 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.compute_v1.InterconnectsClient.GetDiagnostics", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "GetDiagnostics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._GetDiagnostics._get_response( self._host, @@ -687,7 +845,31 @@ def __call__( pb_resp = compute.InterconnectsGetDiagnosticsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_diagnostics(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InterconnectsGetDiagnosticsResponse.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.compute_v1.InterconnectsClient.get_diagnostics", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "GetDiagnostics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMacsecConfig( @@ -724,7 +906,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]]] = (), ) -> compute.InterconnectsGetMacsecConfigResponse: r"""Call the get macsec config method over HTTP. @@ -736,8 +918,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: ~.compute.InterconnectsGetMacsecConfigResponse: @@ -749,6 +933,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BaseGetMacsecConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_macsec_config( request, metadata ) @@ -761,6 +946,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 = 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.compute_v1.InterconnectsClient.GetMacsecConfig", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "GetMacsecConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._GetMacsecConfig._get_response( self._host, @@ -781,7 +993,31 @@ def __call__( pb_resp = compute.InterconnectsGetMacsecConfigResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_macsec_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.InterconnectsGetMacsecConfigResponse.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.compute_v1.InterconnectsClient.get_macsec_config", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "GetMacsecConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseInterconnectsRestTransport._BaseInsert, InterconnectsRestStub): @@ -817,7 +1053,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -829,8 +1065,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: ~.compute.Operation: @@ -857,6 +1095,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BaseInsert._get_transcoded_request( @@ -875,6 +1114,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.compute_v1.InterconnectsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._Insert._get_response( self._host, @@ -896,7 +1162,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseInterconnectsRestTransport._BaseList, InterconnectsRestStub): @@ -931,7 +1219,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]]] = (), ) -> compute.InterconnectList: r"""Call the list method over HTTP. @@ -943,8 +1231,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: ~.compute.InterconnectList: @@ -954,6 +1244,7 @@ def __call__( """ http_options = _BaseInterconnectsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BaseList._get_transcoded_request( @@ -968,6 +1259,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.compute_v1.InterconnectsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._List._get_response( self._host, @@ -988,7 +1306,29 @@ def __call__( pb_resp = compute.InterconnectList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InterconnectList.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.compute_v1.InterconnectsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseInterconnectsRestTransport._BasePatch, InterconnectsRestStub): @@ -1024,7 +1364,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1036,8 +1376,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: ~.compute.Operation: @@ -1064,6 +1406,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BasePatch._get_transcoded_request( @@ -1082,6 +1425,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.compute_v1.InterconnectsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._Patch._get_response( self._host, @@ -1103,7 +1473,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1141,7 +1533,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1153,8 +1545,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: ~.compute.Operation: @@ -1181,6 +1575,7 @@ def __call__( http_options = ( _BaseInterconnectsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseInterconnectsRestTransport._BaseSetLabels._get_transcoded_request( @@ -1201,6 +1596,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.compute_v1.InterconnectsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InterconnectsRestTransport._SetLabels._get_response( self._host, @@ -1222,7 +1644,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.InterconnectsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Interconnects", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/client.py index d2ef87ed2844..596f8823fbef 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/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.compute_v1.types import compute from .transports.base import DEFAULT_CLIENT_INFO, LicenseCodesTransport @@ -552,6 +562,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( @@ -614,6 +628,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.compute_v1.LicenseCodesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.LicenseCodes", + "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.compute.v1.LicenseCodes", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetLicenseCodeRequest, dict]] = None, @@ -622,7 +659,7 @@ def get( license_code: 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]]] = (), ) -> compute.LicenseCode: r"""Return a specified license code. License codes are mirrored across all projects that have permissions to read the License @@ -676,8 +713,10 @@ def sample_get(): 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.compute_v1.types.LicenseCode: @@ -751,7 +790,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party @@ -809,8 +848,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/transports/rest.py index 0aea72cd826c..61a092695a7c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/license_codes/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 @@ -37,6 +37,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, @@ -85,8 +93,8 @@ def post_test_iam_permissions(self, response): def pre_get( self, request: compute.GetLicenseCodeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetLicenseCodeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetLicenseCodeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -106,8 +114,11 @@ def post_get(self, response: compute.LicenseCode) -> compute.LicenseCode: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsLicenseCodeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsLicenseCodeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsLicenseCodeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -249,7 +260,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]]] = (), ) -> compute.LicenseCode: r"""Call the get method over HTTP. @@ -261,8 +272,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: ~.compute.LicenseCode: @@ -275,6 +288,7 @@ def __call__( """ http_options = _BaseLicenseCodesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseLicenseCodesRestTransport._BaseGet._get_transcoded_request( @@ -289,6 +303,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.compute_v1.LicenseCodesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.LicenseCodes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicenseCodesRestTransport._Get._get_response( self._host, @@ -309,7 +350,29 @@ def __call__( pb_resp = compute.LicenseCode.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.LicenseCode.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.compute_v1.LicenseCodesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.LicenseCodes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -347,7 +410,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -359,8 +422,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: ~.compute.TestPermissionsResponse: @@ -370,6 +435,7 @@ def __call__( http_options = ( _BaseLicenseCodesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -386,6 +452,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 = 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.compute_v1.LicenseCodesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.LicenseCodes", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicenseCodesRestTransport._TestIamPermissions._get_response( self._host, @@ -407,7 +500,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.LicenseCodesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.LicenseCodes", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/client.py index 1e462d31cc90..726d920c3163 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.licenses import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.LicensesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "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.compute.v1.Licenses", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteLicenseRequest, dict]] = None, @@ -626,7 +663,7 @@ def delete_unary( license_: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating @@ -679,8 +716,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -746,7 +785,7 @@ def delete( license_: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating @@ -799,8 +838,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -890,7 +931,7 @@ def get( license_: 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]]] = (), ) -> compute.License: r"""Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are @@ -942,8 +983,10 @@ def sample_get(): 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.compute_v1.types.License: @@ -1012,7 +1055,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is @@ -1066,8 +1109,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.cloud.compute_v1.types.Policy: @@ -1153,7 +1198,7 @@ def insert_unary( license_resource: Optional[compute.License] = 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]]] = (), ) -> compute.Operation: r"""Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners @@ -1203,8 +1248,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1265,7 +1312,7 @@ def insert( license_resource: Optional[compute.License] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners @@ -1315,8 +1362,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1400,7 +1449,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to @@ -1451,8 +1500,10 @@ def sample_list(): 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.compute_v1.services.licenses.pagers.ListPager: @@ -1526,7 +1577,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is @@ -1585,8 +1636,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.cloud.compute_v1.types.Policy: @@ -1681,7 +1734,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party @@ -1739,8 +1792,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/pagers.py index d3aede5e4122..82ecab637edd 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/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 = compute.ListLicensesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/transports/rest.py index a50d79de2bd5..c17b9f1fc1c2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/licenses/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 @@ -37,6 +37,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, @@ -123,8 +131,10 @@ def post_test_iam_permissions(self, response): """ def pre_delete( - self, request: compute.DeleteLicenseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteLicenseRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteLicenseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteLicenseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -142,8 +152,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetLicenseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetLicenseRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetLicenseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetLicenseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -163,8 +175,10 @@ def post_get(self, response: compute.License) -> compute.License: def pre_get_iam_policy( self, request: compute.GetIamPolicyLicenseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyLicenseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyLicenseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -182,8 +196,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: return response def pre_insert( - self, request: compute.InsertLicenseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertLicenseRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertLicenseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertLicenseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -201,8 +217,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListLicensesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListLicensesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListLicensesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListLicensesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -224,8 +242,10 @@ def post_list( def pre_set_iam_policy( self, request: compute.SetIamPolicyLicenseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyLicenseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyLicenseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -245,8 +265,11 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsLicenseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsLicenseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsLicenseRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -388,7 +411,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -400,8 +423,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: ~.compute.Operation: @@ -426,6 +451,7 @@ def __call__( """ http_options = _BaseLicensesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseDelete._get_transcoded_request( @@ -440,6 +466,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.compute_v1.LicensesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._Delete._get_response( self._host, @@ -460,7 +513,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.LicensesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseLicensesRestTransport._BaseGet, LicensesRestStub): @@ -495,7 +570,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]]] = (), ) -> compute.License: r"""Call the get method over HTTP. @@ -506,8 +581,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: ~.compute.License: @@ -520,6 +597,7 @@ def __call__( """ http_options = _BaseLicensesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseGet._get_transcoded_request( @@ -532,6 +610,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 = 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.compute_v1.LicensesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._Get._get_response( self._host, @@ -552,7 +657,29 @@ def __call__( pb_resp = compute.License.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.License.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.compute_v1.LicensesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy(_BaseLicensesRestTransport._BaseGetIamPolicy, LicensesRestStub): @@ -587,7 +714,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -599,8 +726,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: ~.compute.Policy: @@ -633,6 +762,7 @@ def __call__( http_options = ( _BaseLicensesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -647,6 +777,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.compute_v1.LicensesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._GetIamPolicy._get_response( self._host, @@ -667,7 +824,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.LicensesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseLicensesRestTransport._BaseInsert, LicensesRestStub): @@ -703,7 +882,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -715,8 +894,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: ~.compute.Operation: @@ -741,6 +922,7 @@ def __call__( """ http_options = _BaseLicensesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseInsert._get_transcoded_request( @@ -759,6 +941,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.compute_v1.LicensesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._Insert._get_response( self._host, @@ -780,7 +989,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.LicensesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseLicensesRestTransport._BaseList, LicensesRestStub): @@ -815,7 +1046,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]]] = (), ) -> compute.LicensesListResponse: r"""Call the list method over HTTP. @@ -826,8 +1057,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: ~.compute.LicensesListResponse: @@ -835,6 +1068,7 @@ def __call__( """ http_options = _BaseLicensesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseList._get_transcoded_request( @@ -847,6 +1081,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 = 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.compute_v1.LicensesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._List._get_response( self._host, @@ -867,7 +1128,29 @@ def __call__( pb_resp = compute.LicensesListResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.LicensesListResponse.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.compute_v1.LicensesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy(_BaseLicensesRestTransport._BaseSetIamPolicy, LicensesRestStub): @@ -903,7 +1186,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -915,8 +1198,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: ~.compute.Policy: @@ -949,6 +1234,7 @@ def __call__( http_options = ( _BaseLicensesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseLicensesRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -967,6 +1253,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.compute_v1.LicensesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._SetIamPolicy._get_response( self._host, @@ -988,7 +1301,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.LicensesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1026,7 +1361,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1038,8 +1373,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: ~.compute.TestPermissionsResponse: @@ -1049,6 +1386,7 @@ def __call__( http_options = ( _BaseLicensesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1065,6 +1403,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 = 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.compute_v1.LicensesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LicensesRestTransport._TestIamPermissions._get_response( self._host, @@ -1086,7 +1451,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.LicensesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Licenses", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/client.py index a0fa79be98ae..238bc73d5002 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.machine_images import pagers @@ -556,6 +566,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( @@ -621,6 +635,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.compute_v1.MachineImagesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "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.compute.v1.MachineImages", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteMachineImageRequest, dict]] = None, @@ -629,7 +666,7 @@ def delete_unary( machine_image: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. @@ -681,8 +718,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -748,7 +787,7 @@ def delete( machine_image: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. @@ -800,8 +839,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -891,7 +932,7 @@ def get( machine_image: 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]]] = (), ) -> compute.MachineImage: r"""Returns the specified machine image. @@ -940,8 +981,10 @@ def sample_get(): 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.compute_v1.types.MachineImage: @@ -1013,7 +1056,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1065,8 +1108,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.cloud.compute_v1.types.Policy: @@ -1152,7 +1197,7 @@ def insert_unary( machine_image_resource: Optional[compute.MachineImage] = 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]]] = (), ) -> compute.Operation: r"""Creates a machine image in the specified project using the data that is included in the request. If you @@ -1205,8 +1250,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1267,7 +1314,7 @@ def insert( machine_image_resource: Optional[compute.MachineImage] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a machine image in the specified project using the data that is included in the request. If you @@ -1320,8 +1367,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1405,7 +1454,7 @@ def list( project: 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.ListPager: r"""Retrieves a list of machine images that are contained within the specified project. @@ -1450,8 +1499,10 @@ def sample_list(): 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.compute_v1.services.machine_images.pagers.ListPager: @@ -1527,7 +1578,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1584,8 +1635,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.cloud.compute_v1.types.Policy: @@ -1682,7 +1735,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -1739,8 +1792,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/pagers.py index a0786d79bd19..a3f18fc1c221 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/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 = compute.ListMachineImagesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/transports/rest.py index 6c0877bf2726..104e9f290c2f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_images/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 @@ -37,6 +37,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, @@ -125,8 +133,10 @@ def post_test_iam_permissions(self, response): def pre_delete( self, request: compute.DeleteMachineImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteMachineImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteMachineImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -146,8 +156,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetMachineImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetMachineImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetMachineImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -167,8 +177,10 @@ def post_get(self, response: compute.MachineImage) -> compute.MachineImage: def pre_get_iam_policy( self, request: compute.GetIamPolicyMachineImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyMachineImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyMachineImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -188,8 +200,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertMachineImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertMachineImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertMachineImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -209,8 +223,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListMachineImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListMachineImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListMachineImagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -230,8 +246,10 @@ def post_list(self, response: compute.MachineImageList) -> compute.MachineImageL def pre_set_iam_policy( self, request: compute.SetIamPolicyMachineImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyMachineImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyMachineImageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -251,9 +269,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsMachineImageRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsMachineImageRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsMachineImageRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -396,7 +415,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -408,8 +427,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: ~.compute.Operation: @@ -436,6 +457,7 @@ def __call__( http_options = ( _BaseMachineImagesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseMachineImagesRestTransport._BaseDelete._get_transcoded_request( @@ -450,6 +472,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.compute_v1.MachineImagesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._Delete._get_response( self._host, @@ -470,7 +519,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.MachineImagesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseMachineImagesRestTransport._BaseGet, MachineImagesRestStub): @@ -505,7 +576,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]]] = (), ) -> compute.MachineImage: r"""Call the get method over HTTP. @@ -517,8 +588,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: ~.compute.MachineImage: @@ -534,6 +607,7 @@ def __call__( """ http_options = _BaseMachineImagesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseMachineImagesRestTransport._BaseGet._get_transcoded_request( @@ -548,6 +622,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.compute_v1.MachineImagesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._Get._get_response( self._host, @@ -568,7 +669,29 @@ def __call__( pb_resp = compute.MachineImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.MachineImage.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.compute_v1.MachineImagesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -605,7 +728,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -617,8 +740,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: ~.compute.Policy: @@ -651,6 +776,7 @@ def __call__( http_options = ( _BaseMachineImagesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseMachineImagesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -661,6 +787,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 = 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.compute_v1.MachineImagesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._GetIamPolicy._get_response( self._host, @@ -681,7 +834,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.MachineImagesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseMachineImagesRestTransport._BaseInsert, MachineImagesRestStub): @@ -717,7 +892,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -729,8 +904,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: ~.compute.Operation: @@ -757,6 +934,7 @@ def __call__( http_options = ( _BaseMachineImagesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseMachineImagesRestTransport._BaseInsert._get_transcoded_request( @@ -775,6 +953,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.compute_v1.MachineImagesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._Insert._get_response( self._host, @@ -796,7 +1001,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.MachineImagesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseMachineImagesRestTransport._BaseList, MachineImagesRestStub): @@ -831,7 +1058,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]]] = (), ) -> compute.MachineImageList: r"""Call the list method over HTTP. @@ -843,8 +1070,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: ~.compute.MachineImageList: @@ -852,6 +1081,7 @@ def __call__( """ http_options = _BaseMachineImagesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseMachineImagesRestTransport._BaseList._get_transcoded_request( @@ -866,6 +1096,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.compute_v1.MachineImagesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._List._get_response( self._host, @@ -886,7 +1143,29 @@ def __call__( pb_resp = compute.MachineImageList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.MachineImageList.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.compute_v1.MachineImagesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -924,7 +1203,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -936,8 +1215,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: ~.compute.Policy: @@ -970,6 +1251,7 @@ def __call__( http_options = ( _BaseMachineImagesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseMachineImagesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -984,6 +1266,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 = 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.compute_v1.MachineImagesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._SetIamPolicy._get_response( self._host, @@ -1005,7 +1314,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.MachineImagesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1043,7 +1374,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1055,8 +1386,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: ~.compute.TestPermissionsResponse: @@ -1066,6 +1399,7 @@ def __call__( http_options = ( _BaseMachineImagesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1082,6 +1416,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 = 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.compute_v1.MachineImagesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineImagesRestTransport._TestIamPermissions._get_response( self._host, @@ -1103,7 +1464,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.MachineImagesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.MachineImages", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/client.py index 4d9e53608a0d..db82778e69d7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/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.compute_v1.services.machine_types import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.MachineTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "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.compute.v1.MachineTypes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -624,7 +661,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of machine types. To prevent failure, Google recommends that you set the @@ -670,8 +707,10 @@ def sample_aggregated_list(): 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.compute_v1.services.machine_types.pagers.AggregatedListPager: @@ -743,7 +782,7 @@ def get( machine_type: 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]]] = (), ) -> compute.MachineType: r"""Returns the specified machine type. @@ -800,8 +839,10 @@ def sample_get(): 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.compute_v1.types.MachineType: @@ -873,7 +914,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of machine types available to the specified project. @@ -926,8 +967,10 @@ def sample_list(): 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.compute_v1.services.machine_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/pagers.py index 45bdff52572f..9229d6f92c13 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/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 = compute.AggregatedListMachineTypesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListMachineTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/transports/rest.py index 53e597c4e1bb..c344ffdce171 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/machine_types/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 @@ -37,6 +37,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, @@ -93,8 +101,11 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListMachineTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListMachineTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListMachineTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -116,8 +127,8 @@ def post_aggregated_list( def pre_get( self, request: compute.GetMachineTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetMachineTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetMachineTypeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -137,8 +148,10 @@ def post_get(self, response: compute.MachineType) -> compute.MachineType: def pre_list( self, request: compute.ListMachineTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListMachineTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListMachineTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -280,7 +293,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]]] = (), ) -> compute.MachineTypeAggregatedList: r"""Call the aggregated list method over HTTP. @@ -292,8 +305,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: ~.compute.MachineTypeAggregatedList: @@ -303,6 +318,7 @@ def __call__( http_options = ( _BaseMachineTypesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseMachineTypesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -313,6 +329,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 = 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.compute_v1.MachineTypesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineTypesRestTransport._AggregatedList._get_response( self._host, @@ -333,7 +376,31 @@ def __call__( pb_resp = compute.MachineTypeAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.MachineTypeAggregatedList.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.compute_v1.MachineTypesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseMachineTypesRestTransport._BaseGet, MachineTypesRestStub): @@ -368,7 +435,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]]] = (), ) -> compute.MachineType: r"""Call the get method over HTTP. @@ -380,8 +447,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: ~.compute.MachineType: @@ -394,6 +463,7 @@ def __call__( """ http_options = _BaseMachineTypesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseMachineTypesRestTransport._BaseGet._get_transcoded_request( @@ -408,6 +478,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.compute_v1.MachineTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineTypesRestTransport._Get._get_response( self._host, @@ -428,7 +525,29 @@ def __call__( pb_resp = compute.MachineType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.MachineType.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.compute_v1.MachineTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseMachineTypesRestTransport._BaseList, MachineTypesRestStub): @@ -463,7 +582,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]]] = (), ) -> compute.MachineTypeList: r"""Call the list method over HTTP. @@ -475,8 +594,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: ~.compute.MachineTypeList: @@ -484,6 +605,7 @@ def __call__( """ http_options = _BaseMachineTypesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseMachineTypesRestTransport._BaseList._get_transcoded_request( @@ -498,6 +620,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.compute_v1.MachineTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MachineTypesRestTransport._List._get_response( self._host, @@ -518,7 +667,29 @@ def __call__( pb_resp = compute.MachineTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.MachineTypeList.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.compute_v1.MachineTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.MachineTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/client.py index 76ae30b54d43..7916d20e1543 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.network_attachments import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.NetworkAttachmentsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "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.compute.v1.NetworkAttachments", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. To prevent @@ -684,8 +721,10 @@ def sample_aggregated_list(): 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.compute_v1.services.network_attachments.pagers.AggregatedListPager: @@ -759,7 +798,7 @@ def delete_unary( network_attachment: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified NetworkAttachment in the given scope @@ -817,8 +856,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -888,7 +929,7 @@ def delete( network_attachment: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified NetworkAttachment in the given scope @@ -946,8 +987,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1042,7 +1085,7 @@ def get( network_attachment: 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]]] = (), ) -> compute.NetworkAttachment: r"""Returns the specified NetworkAttachment resource in the given scope. @@ -1100,8 +1143,10 @@ def sample_get(): 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.compute_v1.types.NetworkAttachment: @@ -1173,7 +1218,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1233,8 +1278,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.cloud.compute_v1.types.Policy: @@ -1324,7 +1371,7 @@ def insert_unary( network_attachment_resource: Optional[compute.NetworkAttachment] = 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]]] = (), ) -> compute.Operation: r"""Creates a NetworkAttachment in the specified project in the given scope using the parameters that are @@ -1380,8 +1427,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1450,7 +1499,7 @@ def insert( network_attachment_resource: Optional[compute.NetworkAttachment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a NetworkAttachment in the specified project in the given scope using the parameters that are @@ -1506,8 +1555,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1600,7 +1651,7 @@ def list( region: 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.ListPager: r"""Lists the NetworkAttachments for a project in the given scope. @@ -1651,8 +1702,10 @@ def sample_list(): 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.compute_v1.services.network_attachments.pagers.ListPager: @@ -1732,7 +1785,7 @@ def patch_unary( network_attachment_resource: Optional[compute.NetworkAttachment] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified NetworkAttachment resource with the data included in the request. This method supports @@ -1797,8 +1850,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1873,7 +1928,7 @@ def patch( network_attachment_resource: Optional[compute.NetworkAttachment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified NetworkAttachment resource with the data included in the request. This method supports @@ -1938,8 +1993,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2043,7 +2100,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2108,8 +2165,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.cloud.compute_v1.types.Policy: @@ -2210,7 +2269,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2275,8 +2334,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/pagers.py index 67a10f045ebb..f6c1e4f91697 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/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 = compute.AggregatedListNetworkAttachmentsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListNetworkAttachmentsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/transports/rest.py index b58e7b271bf3..188a56103cd6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_attachments/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 @@ -37,6 +37,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, @@ -141,9 +149,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListNetworkAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListNetworkAttachmentsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListNetworkAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -166,8 +175,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteNetworkAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -187,8 +198,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNetworkAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -210,8 +223,11 @@ def post_get( def pre_get_iam_policy( self, request: compute.GetIamPolicyNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyNetworkAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -231,8 +247,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertNetworkAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -252,8 +270,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListNetworkAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNetworkAttachmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNetworkAttachmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -275,8 +295,10 @@ def post_list( def pre_patch( self, request: compute.PatchNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchNetworkAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -296,8 +318,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyNetworkAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyNetworkAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -317,9 +342,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsNetworkAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsNetworkAttachmentRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsNetworkAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -465,7 +491,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]]] = (), ) -> compute.NetworkAttachmentAggregatedList: r"""Call the aggregated list method over HTTP. @@ -477,8 +503,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: ~.compute.NetworkAttachmentAggregatedList: @@ -490,6 +518,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseNetworkAttachmentsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -500,6 +529,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 = 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.compute_v1.NetworkAttachmentsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._AggregatedList._get_response( self._host, @@ -520,7 +576,31 @@ def __call__( pb_resp = compute.NetworkAttachmentAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkAttachmentAggregatedList.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.compute_v1.NetworkAttachmentsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -557,7 +637,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -569,8 +649,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: ~.compute.Operation: @@ -597,6 +679,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseNetworkAttachmentsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -609,6 +692,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.compute_v1.NetworkAttachmentsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._Delete._get_response( self._host, @@ -629,7 +739,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkAttachmentsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -666,7 +798,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]]] = (), ) -> compute.NetworkAttachment: r"""Call the get method over HTTP. @@ -678,8 +810,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: ~.compute.NetworkAttachment: @@ -691,6 +825,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseNetworkAttachmentsRestTransport._BaseGet._get_transcoded_request( @@ -705,6 +840,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.compute_v1.NetworkAttachmentsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._Get._get_response( self._host, @@ -725,7 +887,29 @@ def __call__( pb_resp = compute.NetworkAttachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkAttachment.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.compute_v1.NetworkAttachmentsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -763,7 +947,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -775,8 +959,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: ~.compute.Policy: @@ -809,6 +995,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseNetworkAttachmentsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -819,6 +1006,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 = 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.compute_v1.NetworkAttachmentsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._GetIamPolicy._get_response( self._host, @@ -839,7 +1053,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NetworkAttachmentsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -877,7 +1113,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -889,8 +1125,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: ~.compute.Operation: @@ -917,6 +1155,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseNetworkAttachmentsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -935,6 +1174,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.compute_v1.NetworkAttachmentsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._Insert._get_response( self._host, @@ -956,7 +1222,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkAttachmentsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -993,7 +1281,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]]] = (), ) -> compute.NetworkAttachmentList: r"""Call the list method over HTTP. @@ -1005,8 +1293,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: ~.compute.NetworkAttachmentList: @@ -1016,6 +1306,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseNetworkAttachmentsRestTransport._BaseList._get_transcoded_request( @@ -1030,6 +1321,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.compute_v1.NetworkAttachmentsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._List._get_response( self._host, @@ -1050,7 +1368,29 @@ def __call__( pb_resp = compute.NetworkAttachmentList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkAttachmentList.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.compute_v1.NetworkAttachmentsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1088,7 +1428,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1100,8 +1440,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: ~.compute.Operation: @@ -1128,6 +1470,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseNetworkAttachmentsRestTransport._BasePatch._get_transcoded_request( @@ -1148,6 +1491,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.compute_v1.NetworkAttachmentsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._Patch._get_response( self._host, @@ -1169,7 +1539,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkAttachmentsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1208,7 +1600,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1220,8 +1612,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: ~.compute.Policy: @@ -1254,6 +1648,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseNetworkAttachmentsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1268,6 +1663,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 = 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.compute_v1.NetworkAttachmentsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkAttachmentsRestTransport._SetIamPolicy._get_response( self._host, @@ -1289,7 +1711,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NetworkAttachmentsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1328,7 +1772,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1340,8 +1784,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: ~.compute.TestPermissionsResponse: @@ -1351,6 +1797,7 @@ def __call__( http_options = ( _BaseNetworkAttachmentsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1367,6 +1814,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 = 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.compute_v1.NetworkAttachmentsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkAttachmentsRestTransport._TestIamPermissions._get_response( @@ -1390,7 +1864,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.NetworkAttachmentsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkAttachments", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/client.py index f936ca6897e7..fdcf09a73eb2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.network_edge_security_services import pagers @@ -568,6 +578,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( @@ -636,6 +650,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.compute_v1.NetworkEdgeSecurityServicesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "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.compute.v1.NetworkEdgeSecurityServices", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -645,7 +682,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. To prevent failure, Google @@ -694,8 +731,10 @@ def sample_aggregated_list(): 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.compute_v1.services.network_edge_security_services.pagers.AggregatedListPager: @@ -771,7 +810,7 @@ def delete_unary( network_edge_security_service: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified service. @@ -830,8 +869,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -906,7 +947,7 @@ def delete( network_edge_security_service: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified service. @@ -965,8 +1006,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1066,7 +1109,7 @@ def get( network_edge_security_service: 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]]] = (), ) -> compute.NetworkEdgeSecurityService: r"""Gets a specified NetworkEdgeSecurityService. @@ -1125,8 +1168,10 @@ def sample_get(): 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.compute_v1.types.NetworkEdgeSecurityService: @@ -1203,7 +1248,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates a new service in the specified project using the data included in the request. @@ -1260,8 +1305,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1338,7 +1385,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new service in the specified project using the data included in the request. @@ -1395,8 +1442,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1499,7 +1548,7 @@ def patch_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified policy with the data included in the request. @@ -1564,8 +1613,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1654,7 +1705,7 @@ def patch( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified policy with the data included in the request. @@ -1719,8 +1770,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/pagers.py index daed307873e6..cd62aed8ce64 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/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 = compute.AggregatedListNetworkEdgeSecurityServicesRequest( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/transports/rest.py index a76191cb6865..c2a28f890fb2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_edge_security_services/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 @@ -37,6 +37,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, @@ -109,10 +117,10 @@ def post_patch(self, response): def pre_aggregated_list( self, request: compute.AggregatedListNetworkEdgeSecurityServicesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AggregatedListNetworkEdgeSecurityServicesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -135,9 +143,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteNetworkEdgeSecurityServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteNetworkEdgeSecurityServiceRequest, Sequence[Tuple[str, str]] + compute.DeleteNetworkEdgeSecurityServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -158,8 +167,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetNetworkEdgeSecurityServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNetworkEdgeSecurityServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNetworkEdgeSecurityServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -181,9 +193,10 @@ def post_get( def pre_insert( self, request: compute.InsertNetworkEdgeSecurityServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertNetworkEdgeSecurityServiceRequest, Sequence[Tuple[str, str]] + compute.InsertNetworkEdgeSecurityServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -204,9 +217,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_patch( self, request: compute.PatchNetworkEdgeSecurityServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchNetworkEdgeSecurityServiceRequest, Sequence[Tuple[str, str]] + compute.PatchNetworkEdgeSecurityServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch @@ -352,7 +366,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]]] = (), ) -> compute.NetworkEdgeSecurityServiceAggregatedList: r"""Call the aggregated list method over HTTP. @@ -364,8 +378,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: ~.compute.NetworkEdgeSecurityServiceAggregatedList: @@ -375,6 +391,7 @@ def __call__( http_options = ( _BaseNetworkEdgeSecurityServicesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseNetworkEdgeSecurityServicesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -385,6 +402,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 = 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.compute_v1.NetworkEdgeSecurityServicesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkEdgeSecurityServicesRestTransport._AggregatedList._get_response( @@ -407,7 +451,33 @@ def __call__( pb_resp = compute.NetworkEdgeSecurityServiceAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkEdgeSecurityServiceAggregatedList.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.compute_v1.NetworkEdgeSecurityServicesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -445,7 +515,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -457,8 +527,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: ~.compute.Operation: @@ -485,6 +557,7 @@ def __call__( http_options = ( _BaseNetworkEdgeSecurityServicesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseNetworkEdgeSecurityServicesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -495,6 +568,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 = 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.compute_v1.NetworkEdgeSecurityServicesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEdgeSecurityServicesRestTransport._Delete._get_response( self._host, @@ -515,7 +615,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEdgeSecurityServicesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -553,7 +675,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]]] = (), ) -> compute.NetworkEdgeSecurityService: r"""Call the get method over HTTP. @@ -565,8 +687,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: ~.compute.NetworkEdgeSecurityService: @@ -578,6 +702,7 @@ def __call__( http_options = ( _BaseNetworkEdgeSecurityServicesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseNetworkEdgeSecurityServicesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -588,6 +713,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 = 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.compute_v1.NetworkEdgeSecurityServicesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEdgeSecurityServicesRestTransport._Get._get_response( self._host, @@ -608,7 +760,31 @@ def __call__( pb_resp = compute.NetworkEdgeSecurityService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEdgeSecurityService.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.compute_v1.NetworkEdgeSecurityServicesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -647,7 +823,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -659,8 +835,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: ~.compute.Operation: @@ -687,6 +865,7 @@ def __call__( http_options = ( _BaseNetworkEdgeSecurityServicesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseNetworkEdgeSecurityServicesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -701,6 +880,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 = 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.compute_v1.NetworkEdgeSecurityServicesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEdgeSecurityServicesRestTransport._Insert._get_response( self._host, @@ -722,7 +928,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEdgeSecurityServicesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -761,7 +989,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -773,8 +1001,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: ~.compute.Operation: @@ -801,6 +1031,7 @@ def __call__( http_options = ( _BaseNetworkEdgeSecurityServicesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseNetworkEdgeSecurityServicesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -815,6 +1046,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 = 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.compute_v1.NetworkEdgeSecurityServicesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEdgeSecurityServicesRestTransport._Patch._get_response( self._host, @@ -836,7 +1094,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEdgeSecurityServicesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEdgeSecurityServices", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/client.py index ce11b9915b2c..0d91efec9d6a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.network_endpoint_groups import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.NetworkEndpointGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "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.compute.v1.NetworkEndpointGroups", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -639,7 +676,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of network endpoint groups and sorts them by zone. To prevent failure, Google recommends that you set the @@ -685,8 +722,10 @@ def sample_aggregated_list(): 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.compute_v1.services.network_endpoint_groups.pagers.AggregatedListPager: @@ -763,7 +802,7 @@ def attach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Attach a list of network endpoints to the specified network endpoint group. @@ -831,8 +870,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -920,7 +961,7 @@ def attach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Attach a list of network endpoints to the specified network endpoint group. @@ -988,8 +1029,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1099,7 +1142,7 @@ def delete_unary( network_endpoint_group: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they @@ -1164,8 +1207,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1237,7 +1282,7 @@ def delete( network_endpoint_group: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they @@ -1302,8 +1347,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1403,7 +1450,7 @@ def detach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Detach a list of network endpoints from the specified network endpoint group. @@ -1471,8 +1518,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1560,7 +1609,7 @@ def detach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Detach a list of network endpoints from the specified network endpoint group. @@ -1628,8 +1677,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1737,7 +1788,7 @@ def get( network_endpoint_group: 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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Returns the specified network endpoint group. @@ -1797,8 +1848,10 @@ def sample_get(): 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.compute_v1.types.NetworkEndpointGroup: @@ -1876,7 +1929,7 @@ def insert_unary( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> compute.Operation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -1935,8 +1988,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2009,7 +2064,7 @@ def insert( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -2068,8 +2123,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2164,7 +2221,7 @@ def list( zone: 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.ListPager: r"""Retrieves the list of network endpoint groups that are located in the specified project and zone. @@ -2218,8 +2275,10 @@ def sample_list(): 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.compute_v1.services.network_endpoint_groups.pagers.ListPager: @@ -2303,7 +2362,7 @@ def list_network_endpoints( ] = 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.ListNetworkEndpointsPager: r"""Lists the network endpoints in the specified network endpoint group. @@ -2372,8 +2431,10 @@ def sample_list_network_endpoints(): 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.compute_v1.services.network_endpoint_groups.pagers.ListNetworkEndpointsPager: @@ -2473,7 +2534,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2538,8 +2599,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/pagers.py index 42f73015468a..1c497e719946 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/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 = compute.AggregatedListNetworkEndpointGroupsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListNetworkEndpointGroupsRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListNetworkEndpointsNetworkEndpointGroupsRequest( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/transports/rest.py index 3c0db06acca3..1f660c604392 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_endpoint_groups/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 @@ -37,6 +37,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, @@ -141,9 +149,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListNetworkEndpointGroupsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListNetworkEndpointGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -166,10 +175,10 @@ def post_aggregated_list( def pre_attach_network_endpoints( self, request: compute.AttachNetworkEndpointsNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AttachNetworkEndpointsNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for attach_network_endpoints @@ -192,8 +201,11 @@ def post_attach_network_endpoints( def pre_delete( self, request: compute.DeleteNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNetworkEndpointGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -213,10 +225,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_detach_network_endpoints( self, request: compute.DetachNetworkEndpointsNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DetachNetworkEndpointsNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for detach_network_endpoints @@ -239,8 +251,10 @@ def post_detach_network_endpoints( def pre_get( self, request: compute.GetNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNetworkEndpointGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNetworkEndpointGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -262,8 +276,11 @@ def post_get( def pre_insert( self, request: compute.InsertNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertNetworkEndpointGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -283,8 +300,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNetworkEndpointGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNetworkEndpointGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -306,10 +326,10 @@ def post_list( def pre_list_network_endpoints( self, request: compute.ListNetworkEndpointsNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListNetworkEndpointsNetworkEndpointGroupsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_network_endpoints @@ -332,9 +352,10 @@ def post_list_network_endpoints( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsNetworkEndpointGroupRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -480,7 +501,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]]] = (), ) -> compute.NetworkEndpointGroupAggregatedList: r"""Call the aggregated list method over HTTP. @@ -492,8 +513,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: ~.compute.NetworkEndpointGroupAggregatedList: @@ -503,6 +526,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseNetworkEndpointGroupsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -513,6 +537,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 = 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.compute_v1.NetworkEndpointGroupsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._AggregatedList._get_response( self._host, @@ -533,7 +584,31 @@ def __call__( pb_resp = compute.NetworkEndpointGroupAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkEndpointGroupAggregatedList.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.compute_v1.NetworkEndpointGroupsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AttachNetworkEndpoints( @@ -572,7 +647,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]]] = (), ) -> compute.Operation: r"""Call the attach network endpoints method over HTTP. @@ -584,8 +659,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: ~.compute.Operation: @@ -612,6 +689,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseAttachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_attach_network_endpoints( request, metadata ) @@ -628,6 +706,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 = 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.compute_v1.NetworkEndpointGroupsClient.AttachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._AttachNetworkEndpoints._get_response( self._host, @@ -649,7 +754,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_attach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEndpointGroupsClient.attach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -687,7 +814,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -699,8 +826,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: ~.compute.Operation: @@ -727,6 +856,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseNetworkEndpointGroupsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -737,6 +867,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 = 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.compute_v1.NetworkEndpointGroupsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._Delete._get_response( self._host, @@ -757,7 +914,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEndpointGroupsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetachNetworkEndpoints( @@ -796,7 +975,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]]] = (), ) -> compute.Operation: r"""Call the detach network endpoints method over HTTP. @@ -808,8 +987,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: ~.compute.Operation: @@ -836,6 +1017,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseDetachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_detach_network_endpoints( request, metadata ) @@ -852,6 +1034,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 = 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.compute_v1.NetworkEndpointGroupsClient.DetachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._DetachNetworkEndpoints._get_response( self._host, @@ -873,7 +1082,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEndpointGroupsClient.detach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -910,7 +1141,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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Call the get method over HTTP. @@ -922,8 +1153,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: ~.compute.NetworkEndpointGroup: @@ -941,6 +1174,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseNetworkEndpointGroupsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -953,6 +1187,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.compute_v1.NetworkEndpointGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._Get._get_response( self._host, @@ -973,7 +1234,29 @@ def __call__( pb_resp = compute.NetworkEndpointGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroup.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.compute_v1.NetworkEndpointGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1012,7 +1295,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1024,8 +1307,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: ~.compute.Operation: @@ -1052,6 +1337,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseNetworkEndpointGroupsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1066,6 +1352,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 = 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.compute_v1.NetworkEndpointGroupsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._Insert._get_response( self._host, @@ -1087,7 +1400,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkEndpointGroupsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1124,7 +1459,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]]] = (), ) -> compute.NetworkEndpointGroupList: r"""Call the list method over HTTP. @@ -1136,8 +1471,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: ~.compute.NetworkEndpointGroupList: @@ -1147,6 +1484,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseNetworkEndpointGroupsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1157,6 +1495,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 = 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.compute_v1.NetworkEndpointGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkEndpointGroupsRestTransport._List._get_response( self._host, @@ -1177,7 +1542,31 @@ def __call__( pb_resp = compute.NetworkEndpointGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroupList.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.compute_v1.NetworkEndpointGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkEndpoints( @@ -1216,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]]] = (), ) -> compute.NetworkEndpointGroupsListNetworkEndpoints: r"""Call the list network endpoints method over HTTP. @@ -1228,8 +1617,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: ~.compute.NetworkEndpointGroupsListNetworkEndpoints: @@ -1239,6 +1630,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseListNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_endpoints( request, metadata ) @@ -1255,6 +1647,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 = 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.compute_v1.NetworkEndpointGroupsClient.ListNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkEndpointGroupsRestTransport._ListNetworkEndpoints._get_response( @@ -1278,7 +1697,33 @@ def __call__( pb_resp = compute.NetworkEndpointGroupsListNetworkEndpoints.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkEndpointGroupsListNetworkEndpoints.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.compute_v1.NetworkEndpointGroupsClient.list_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1317,7 +1762,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1329,8 +1774,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: ~.compute.TestPermissionsResponse: @@ -1340,6 +1787,7 @@ def __call__( http_options = ( _BaseNetworkEndpointGroupsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1356,6 +1804,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 = 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.compute_v1.NetworkEndpointGroupsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkEndpointGroupsRestTransport._TestIamPermissions._get_response( @@ -1379,7 +1854,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.NetworkEndpointGroupsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkEndpointGroups", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py index 7a6099444cfa..86042cde4d69 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.network_firewall_policies import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.NetworkFirewallPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "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.compute.v1.NetworkFirewallPolicies", + "credentialsType": None, + }, + ) + def add_association_unary( self, request: Optional[ @@ -645,7 +682,7 @@ def add_association_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts an association for the specified firewall policy. @@ -702,8 +739,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -780,7 +819,7 @@ def add_association( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts an association for the specified firewall policy. @@ -837,8 +876,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -937,7 +978,7 @@ def add_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Inserts a rule into a firewall policy. @@ -993,8 +1034,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1067,7 +1110,7 @@ def add_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts a rule into a firewall policy. @@ -1123,8 +1166,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1220,7 +1265,7 @@ def clone_rules_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Copies rules to the specified firewall policy. @@ -1271,8 +1316,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1340,7 +1387,7 @@ def clone_rules( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Copies rules to the specified firewall policy. @@ -1391,8 +1438,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1484,7 +1533,7 @@ def delete_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified policy. @@ -1535,8 +1584,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1604,7 +1655,7 @@ def delete( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified policy. @@ -1655,8 +1706,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1746,7 +1799,7 @@ def get( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicy: r"""Returns the specified network firewall policy. @@ -1795,8 +1848,10 @@ def sample_get(): 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.compute_v1.types.FirewallPolicy: @@ -1864,7 +1919,7 @@ def get_association( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Gets an association with the specified name. @@ -1915,8 +1970,10 @@ def sample_get_association(): 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.compute_v1.types.FirewallPolicyAssociation: @@ -1982,7 +2039,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -2034,8 +2091,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.cloud.compute_v1.types.Policy: @@ -2123,7 +2182,7 @@ def get_rule( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyRule: r"""Gets a rule of the specified priority. @@ -2174,8 +2233,10 @@ def sample_get_rule(): 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.compute_v1.types.FirewallPolicyRule: @@ -2245,7 +2306,7 @@ def insert_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new policy in the specified project using the data included in the request. @@ -2294,8 +2355,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2358,7 +2421,7 @@ def insert( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new policy in the specified project using the data included in the request. @@ -2407,8 +2470,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2494,7 +2559,7 @@ def list( project: 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.ListPager: r"""Lists all the policies that have been configured for the specified project. @@ -2539,8 +2604,10 @@ def sample_list(): 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.compute_v1.services.network_firewall_policies.pagers.ListPager: @@ -2614,7 +2681,7 @@ def patch_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified policy with the data included in the request. @@ -2671,8 +2738,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2743,7 +2812,7 @@ def patch( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified policy with the data included in the request. @@ -2800,8 +2869,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2896,7 +2967,7 @@ def patch_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Patches a rule of the specified priority. @@ -2952,8 +3023,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3026,7 +3099,7 @@ def patch_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches a rule of the specified priority. @@ -3082,8 +3155,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3179,7 +3254,7 @@ def remove_association_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Removes an association for the specified firewall policy. @@ -3231,8 +3306,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3302,7 +3379,7 @@ def remove_association( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes an association for the specified firewall policy. @@ -3354,8 +3431,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3449,7 +3528,7 @@ def remove_rule_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes a rule of the specified priority. @@ -3500,8 +3579,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3569,7 +3650,7 @@ def remove_rule( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a rule of the specified priority. @@ -3620,8 +3701,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3716,7 +3799,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3773,8 +3856,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.cloud.compute_v1.types.Policy: @@ -3871,7 +3956,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -3928,8 +4013,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py index cab03b6ada97..5e1a7afcaeeb 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/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 = compute.ListNetworkFirewallPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py index b690fa505b64..3f1974d73269 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/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 @@ -37,6 +37,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,9 +205,10 @@ def post_test_iam_permissions(self, response): def pre_add_association( self, request: compute.AddAssociationNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AddAssociationNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.AddAssociationNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_association @@ -220,8 +229,11 @@ def post_add_association(self, response: compute.Operation) -> compute.Operation def pre_add_rule( self, request: compute.AddRuleNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddRuleNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddRuleNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_rule Override in a subclass to manipulate the request or metadata @@ -241,9 +253,10 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: def pre_clone_rules( self, request: compute.CloneRulesNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.CloneRulesNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.CloneRulesNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for clone_rules @@ -264,8 +277,11 @@ def post_clone_rules(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -285,8 +301,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNetworkFirewallPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -306,9 +324,10 @@ def post_get(self, response: compute.FirewallPolicy) -> compute.FirewallPolicy: def pre_get_association( self, request: compute.GetAssociationNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetAssociationNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.GetAssociationNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_association @@ -331,9 +350,10 @@ def post_get_association( def pre_get_iam_policy( self, request: compute.GetIamPolicyNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetIamPolicyNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.GetIamPolicyNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_iam_policy @@ -354,8 +374,11 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_get_rule( self, request: compute.GetRuleNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRuleNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRuleNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_rule Override in a subclass to manipulate the request or metadata @@ -377,8 +400,11 @@ def post_get_rule( def pre_insert( self, request: compute.InsertNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -398,8 +424,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListNetworkFirewallPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNetworkFirewallPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNetworkFirewallPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -421,8 +450,11 @@ def post_list( def pre_patch( self, request: compute.PatchNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -442,9 +474,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_rule( self, request: compute.PatchRuleNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchRuleNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.PatchRuleNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch_rule @@ -465,9 +498,10 @@ def post_patch_rule(self, response: compute.Operation) -> compute.Operation: def pre_remove_association( self, request: compute.RemoveAssociationNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveAssociationNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.RemoveAssociationNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_association @@ -488,9 +522,10 @@ def post_remove_association(self, response: compute.Operation) -> compute.Operat def pre_remove_rule( self, request: compute.RemoveRuleNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveRuleNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.RemoveRuleNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_rule @@ -511,9 +546,10 @@ def post_remove_rule(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetIamPolicyNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.SetIamPolicyNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_iam_policy @@ -534,10 +570,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.TestIamPermissionsNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -684,7 +720,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]]] = (), ) -> compute.Operation: r"""Call the add association method over HTTP. @@ -696,8 +732,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: ~.compute.Operation: @@ -724,6 +762,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseAddAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_add_association(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseAddAssociation._get_transcoded_request( http_options, request @@ -738,6 +777,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 = 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.compute_v1.NetworkFirewallPoliciesClient.AddAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AddAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkFirewallPoliciesRestTransport._AddAssociation._get_response( @@ -761,7 +827,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.add_association", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AddAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddRule( @@ -800,7 +888,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]]] = (), ) -> compute.Operation: r"""Call the add rule method over HTTP. @@ -812,8 +900,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: ~.compute.Operation: @@ -840,6 +930,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseAddRule._get_http_options() ) + request, metadata = self._interceptor.pre_add_rule(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseAddRule._get_transcoded_request( http_options, request @@ -854,6 +945,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 = 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.compute_v1.NetworkFirewallPoliciesClient.AddRule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AddRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._AddRule._get_response( self._host, @@ -875,7 +993,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.add_rule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AddRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CloneRules( @@ -913,7 +1053,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]]] = (), ) -> compute.Operation: r"""Call the clone rules method over HTTP. @@ -925,8 +1065,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: ~.compute.Operation: @@ -953,6 +1095,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseCloneRules._get_http_options() ) + request, metadata = self._interceptor.pre_clone_rules(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseCloneRules._get_transcoded_request( http_options, request @@ -963,6 +1106,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 = 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.compute_v1.NetworkFirewallPoliciesClient.CloneRules", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "CloneRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._CloneRules._get_response( self._host, @@ -983,7 +1153,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clone_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.clone_rules", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "CloneRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -1021,7 +1213,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1033,8 +1225,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: ~.compute.Operation: @@ -1061,6 +1255,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -1071,6 +1266,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 = 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.compute_v1.NetworkFirewallPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._Delete._get_response( self._host, @@ -1091,7 +1313,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -1129,7 +1373,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]]] = (), ) -> compute.FirewallPolicy: r"""Call the get method over HTTP. @@ -1141,8 +1385,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: ~.compute.FirewallPolicy: @@ -1154,6 +1400,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -1164,6 +1411,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 = 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.compute_v1.NetworkFirewallPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._Get._get_response( self._host, @@ -1184,7 +1458,29 @@ def __call__( pb_resp = compute.FirewallPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicy.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.compute_v1.NetworkFirewallPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAssociation( @@ -1222,7 +1518,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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Call the get association method over HTTP. @@ -1234,8 +1530,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: ~.compute.FirewallPolicyAssociation: @@ -1245,6 +1543,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseGetAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_get_association(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseGetAssociation._get_transcoded_request( http_options, request @@ -1255,6 +1554,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 = 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.compute_v1.NetworkFirewallPoliciesClient.GetAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkFirewallPoliciesRestTransport._GetAssociation._get_response( @@ -1277,7 +1603,31 @@ def __call__( pb_resp = compute.FirewallPolicyAssociation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyAssociation.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.compute_v1.NetworkFirewallPoliciesClient.get_association", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1315,7 +1665,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1327,8 +1677,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: ~.compute.Policy: @@ -1361,6 +1713,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1371,6 +1724,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 = 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.compute_v1.NetworkFirewallPoliciesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._GetIamPolicy._get_response( self._host, @@ -1391,7 +1771,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NetworkFirewallPoliciesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -1429,7 +1831,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]]] = (), ) -> compute.FirewallPolicyRule: r"""Call the get rule method over HTTP. @@ -1441,8 +1843,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: ~.compute.FirewallPolicyRule: @@ -1456,6 +1860,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseGetRule._get_transcoded_request( http_options, request @@ -1466,6 +1871,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 = 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.compute_v1.NetworkFirewallPoliciesClient.GetRule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._GetRule._get_response( self._host, @@ -1486,7 +1918,29 @@ def __call__( pb_resp = compute.FirewallPolicyRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyRule.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.compute_v1.NetworkFirewallPoliciesClient.get_rule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1525,7 +1979,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1537,8 +1991,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: ~.compute.Operation: @@ -1565,6 +2021,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1579,6 +2036,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 = 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.compute_v1.NetworkFirewallPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._Insert._get_response( self._host, @@ -1600,7 +2084,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1638,7 +2144,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]]] = (), ) -> compute.FirewallPolicyList: r"""Call the list method over HTTP. @@ -1650,8 +2156,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: ~.compute.FirewallPolicyList: @@ -1661,6 +2169,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1671,6 +2180,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 = 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.compute_v1.NetworkFirewallPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._List._get_response( self._host, @@ -1691,7 +2227,29 @@ def __call__( pb_resp = compute.FirewallPolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyList.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.compute_v1.NetworkFirewallPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1730,7 +2288,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1742,8 +2300,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: ~.compute.Operation: @@ -1770,6 +2330,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -1784,6 +2345,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 = 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.compute_v1.NetworkFirewallPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._Patch._get_response( self._host, @@ -1805,7 +2393,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchRule( @@ -1844,7 +2454,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]]] = (), ) -> compute.Operation: r"""Call the patch rule method over HTTP. @@ -1856,8 +2466,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: ~.compute.Operation: @@ -1884,6 +2496,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BasePatchRule._get_http_options() ) + request, metadata = self._interceptor.pre_patch_rule(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BasePatchRule._get_transcoded_request( http_options, request @@ -1898,6 +2511,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 = 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.compute_v1.NetworkFirewallPoliciesClient.PatchRule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "PatchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._PatchRule._get_response( self._host, @@ -1919,7 +2559,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.patch_rule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "PatchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveAssociation( @@ -1957,7 +2619,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]]] = (), ) -> compute.Operation: r"""Call the remove association method over HTTP. @@ -1969,8 +2631,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: ~.compute.Operation: @@ -1997,6 +2661,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseRemoveAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_remove_association( request, metadata ) @@ -2009,6 +2674,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 = 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.compute_v1.NetworkFirewallPoliciesClient.RemoveAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "RemoveAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkFirewallPoliciesRestTransport._RemoveAssociation._get_response( @@ -2031,7 +2723,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.remove_association", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "RemoveAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveRule( @@ -2069,7 +2783,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]]] = (), ) -> compute.Operation: r"""Call the remove rule method over HTTP. @@ -2081,8 +2795,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: ~.compute.Operation: @@ -2109,6 +2825,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseRemoveRule._get_http_options() ) + request, metadata = self._interceptor.pre_remove_rule(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseRemoveRule._get_transcoded_request( http_options, request @@ -2119,6 +2836,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 = 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.compute_v1.NetworkFirewallPoliciesClient.RemoveRule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "RemoveRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._RemoveRule._get_response( self._host, @@ -2139,7 +2883,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworkFirewallPoliciesClient.remove_rule", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "RemoveRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2178,7 +2944,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -2190,8 +2956,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: ~.compute.Policy: @@ -2224,6 +2992,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2238,6 +3007,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 = 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.compute_v1.NetworkFirewallPoliciesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkFirewallPoliciesRestTransport._SetIamPolicy._get_response( self._host, @@ -2259,7 +3055,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NetworkFirewallPoliciesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2298,7 +3116,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2310,8 +3128,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: ~.compute.TestPermissionsResponse: @@ -2321,6 +3141,7 @@ def __call__( http_options = ( _BaseNetworkFirewallPoliciesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2337,6 +3158,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 = 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.compute_v1.NetworkFirewallPoliciesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( NetworkFirewallPoliciesRestTransport._TestIamPermissions._get_response( @@ -2360,7 +3208,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.NetworkFirewallPoliciesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/__init__.py new file mode 100644 index 000000000000..68387b40a108 --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import NetworkProfilesClient + +__all__ = ("NetworkProfilesClient",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/client.py new file mode 100644 index 000000000000..e50c56271b10 --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/client.py @@ -0,0 +1,921 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import logging as std_logging +import os +import re +from typing import ( + Callable, + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) +import warnings + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.compute_v1 import gapic_version as package_version + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] +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.compute_v1.services.network_profiles import pagers +from google.cloud.compute_v1.types import compute + +from .transports.base import DEFAULT_CLIENT_INFO, NetworkProfilesTransport +from .transports.rest import NetworkProfilesRestTransport + + +class NetworkProfilesClientMeta(type): + """Metaclass for the NetworkProfiles client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + + _transport_registry = ( + OrderedDict() + ) # type: Dict[str, Type[NetworkProfilesTransport]] + _transport_registry["rest"] = NetworkProfilesRestTransport + + def get_transport_class( + cls, + label: Optional[str] = None, + ) -> Type[NetworkProfilesTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class NetworkProfilesClient(metaclass=NetworkProfilesClientMeta): + """The NetworkProfiles API.""" + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. + DEFAULT_ENDPOINT = "compute.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + _DEFAULT_ENDPOINT_TEMPLATE = "compute.{UNIVERSE_DOMAIN}" + _DEFAULT_UNIVERSE = "googleapis.com" + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + NetworkProfilesClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + NetworkProfilesClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> NetworkProfilesTransport: + """Returns the transport used by the client instance. + + Returns: + NetworkProfilesTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def common_billing_account_path( + billing_account: str, + ) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path( + folder: str, + ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format( + folder=folder, + ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path( + organization: str, + ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format( + organization=organization, + ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path( + project: str, + ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format( + project=project, + ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path( + project: str, + location: str, + ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, + location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Deprecated. Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + + warnings.warn( + "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", + DeprecationWarning, + ) + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + + @staticmethod + def _read_environment_variables(): + """Returns the environment variables used by the client. + + Returns: + Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, + GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. + + Raises: + ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not + any of ["true", "false"]. + google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT + is not any of ["auto", "never", "always"]. + """ + use_client_cert = os.getenv( + "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false" + ).lower() + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() + universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + return use_client_cert == "true", use_mtls_endpoint, universe_domain_env + + @staticmethod + def _get_client_cert_source(provided_cert_source, use_cert_flag): + """Return the client cert source to be used by the client. + + Args: + provided_cert_source (bytes): The client certificate source provided. + use_cert_flag (bool): A flag indicating whether to use the client certificate. + + Returns: + bytes or None: The client cert source to be used by the client. + """ + client_cert_source = None + if use_cert_flag: + if provided_cert_source: + client_cert_source = provided_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + return client_cert_source + + @staticmethod + def _get_api_endpoint( + api_override, client_cert_source, universe_domain, use_mtls_endpoint + ): + """Return the API endpoint used by the client. + + Args: + api_override (str): The API endpoint override. If specified, this is always + the return value of this function and the other arguments are not used. + client_cert_source (bytes): The client certificate source used by the client. + universe_domain (str): The universe domain used by the client. + use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. + Possible values are "always", "auto", or "never". + + Returns: + str: The API endpoint to be used by the client. + """ + if api_override is not None: + api_endpoint = api_override + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + _default_universe = NetworkProfilesClient._DEFAULT_UNIVERSE + if universe_domain != _default_universe: + raise MutualTLSChannelError( + f"mTLS is not supported in any universe other than {_default_universe}." + ) + api_endpoint = NetworkProfilesClient.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = NetworkProfilesClient._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=universe_domain + ) + return api_endpoint + + @staticmethod + def _get_universe_domain( + client_universe_domain: Optional[str], universe_domain_env: Optional[str] + ) -> str: + """Return the universe domain used by the client. + + Args: + client_universe_domain (Optional[str]): The universe domain configured via the client options. + universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. + + Returns: + str: The universe domain to be used by the client. + + Raises: + ValueError: If the universe domain is an empty string. + """ + universe_domain = NetworkProfilesClient._DEFAULT_UNIVERSE + if client_universe_domain is not None: + universe_domain = client_universe_domain + elif universe_domain_env is not None: + universe_domain = universe_domain_env + if len(universe_domain.strip()) == 0: + raise ValueError("Universe Domain cannot be an empty string.") + return universe_domain + + def _validate_universe_domain(self): + """Validates client's and credentials' universe domains are consistent. + + Returns: + bool: True iff the configured universe domain is valid. + + Raises: + ValueError: If the configured universe domain is not valid. + """ + + # NOTE (b/349488459): universe validation is disabled until further notice. + return True + + @property + def api_endpoint(self): + """Return the API endpoint used by the client instance. + + Returns: + str: The API endpoint used by the client instance. + """ + return self._api_endpoint + + @property + def universe_domain(self) -> str: + """Return the universe domain used by the client instance. + + Returns: + str: The universe domain used by the client instance. + """ + return self._universe_domain + + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[ + Union[ + str, NetworkProfilesTransport, Callable[..., NetworkProfilesTransport] + ] + ] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the network profiles client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Optional[Union[str,NetworkProfilesTransport,Callable[..., NetworkProfilesTransport]]]): + The transport to use, or a Callable that constructs and returns a new transport. + If a Callable is given, it will be called with the same set of initialization + arguments as used in the NetworkProfilesTransport constructor. + If set to None, a transport is chosen automatically. + NOTE: "rest" transport functionality is currently in a + beta state (preview). We welcome your feedback via an + issue in this library's source repository. + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): + Custom options for the client. + + 1. The ``api_endpoint`` property can be used to override the + default endpoint provided by the client when ``transport`` is + not explicitly provided. Only if this property is not set and + ``transport`` was not explicitly provided, the endpoint is + determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment + variable, which have one of the following values: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto-switch to the + default mTLS endpoint if client certificate is present; this is + the default value). + + 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide a client certificate for mTLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + 3. The ``universe_domain`` property can be used to override the + default "googleapis.com" universe. Note that the ``api_endpoint`` + property still takes precedence; and ``universe_domain`` is + currently not supported for mTLS. + + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client_options = client_options + if isinstance(self._client_options, dict): + self._client_options = client_options_lib.from_dict(self._client_options) + if self._client_options is None: + self._client_options = client_options_lib.ClientOptions() + self._client_options = cast( + client_options_lib.ClientOptions, self._client_options + ) + + universe_domain_opt = getattr(self._client_options, "universe_domain", None) + + ( + self._use_client_cert, + self._use_mtls_endpoint, + self._universe_domain_env, + ) = NetworkProfilesClient._read_environment_variables() + self._client_cert_source = NetworkProfilesClient._get_client_cert_source( + self._client_options.client_cert_source, self._use_client_cert + ) + self._universe_domain = NetworkProfilesClient._get_universe_domain( + universe_domain_opt, self._universe_domain_env + ) + self._api_endpoint = None # updated below, depending on `transport` + + # 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( + "client_options.api_key and credentials are mutually exclusive" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + transport_provided = isinstance(transport, NetworkProfilesTransport) + if transport_provided: + # transport is a NetworkProfilesTransport instance. + if credentials or self._client_options.credentials_file or api_key_value: + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) + if self._client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = cast(NetworkProfilesTransport, transport) + self._api_endpoint = self._transport.host + + self._api_endpoint = ( + self._api_endpoint + or NetworkProfilesClient._get_api_endpoint( + self._client_options.api_endpoint, + self._client_cert_source, + self._universe_domain, + self._use_mtls_endpoint, + ) + ) + + if not transport_provided: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + + transport_init: Union[ + Type[NetworkProfilesTransport], Callable[..., NetworkProfilesTransport] + ] = ( + NetworkProfilesClient.get_transport_class(transport) + if isinstance(transport, str) or transport is None + else cast(Callable[..., NetworkProfilesTransport], transport) + ) + # initialize with the provided callable or the passed in class + self._transport = transport_init( + credentials=credentials, + credentials_file=self._client_options.credentials_file, + host=self._api_endpoint, + scopes=self._client_options.scopes, + client_cert_source_for_mtls=self._client_cert_source, + quota_project_id=self._client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + 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.compute_v1.NetworkProfilesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkProfiles", + "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.compute.v1.NetworkProfiles", + "credentialsType": None, + }, + ) + + def get( + self, + request: Optional[Union[compute.GetNetworkProfileRequest, dict]] = None, + *, + project: Optional[str] = None, + network_profile: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.NetworkProfile: + r"""Returns the specified network profile. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_get(): + # Create a client + client = compute_v1.NetworkProfilesClient() + + # Initialize request argument(s) + request = compute_v1.GetNetworkProfileRequest( + network_profile="network_profile_value", + project="project_value", + ) + + # Make the request + response = client.get(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.GetNetworkProfileRequest, dict]): + The request object. A request message for + NetworkProfiles.Get. See the method + description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + network_profile (str): + Name of the network profile to + return. + + This corresponds to the ``network_profile`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.compute_v1.types.NetworkProfile: + NetworkProfile represents a Google + managed network profile resource. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([project, network_profile]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.GetNetworkProfileRequest): + request = compute.GetNetworkProfileRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if network_profile is not None: + request.network_profile = network_profile + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("network_profile", request.network_profile), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list( + self, + request: Optional[Union[compute.ListNetworkProfilesRequest, dict]] = None, + *, + project: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPager: + r"""Retrieves a list of network profiles available to the + specified project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_list(): + # Create a client + client = compute_v1.NetworkProfilesClient() + + # Initialize request argument(s) + request = compute_v1.ListNetworkProfilesRequest( + project="project_value", + ) + + # Make the request + page_result = client.list(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.ListNetworkProfilesRequest, dict]): + The request object. A request message for + NetworkProfiles.List. See the method + description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.compute_v1.services.network_profiles.pagers.ListPager: + Contains a list of network profiles. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([project]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.ListNetworkProfilesRequest): + request = compute.ListNetworkProfilesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def __enter__(self) -> "NetworkProfilesClient": + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) + + +__all__ = ("NetworkProfilesClient",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/pagers.py new file mode 100644 index 000000000000..9d7ce847b681 --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/pagers.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import ( + Any, + AsyncIterator, + Awaitable, + Callable, + Iterator, + Optional, + Sequence, + Tuple, + Union, +) + +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import retry_async as retries_async + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] + OptionalAsyncRetry = Union[ + retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None + ] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object, None] # type: ignore + OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore + +from google.cloud.compute_v1.types import compute + + +class ListPager: + """A pager for iterating through ``list`` requests. + + This class thinly wraps an initial + :class:`google.cloud.compute_v1.types.NetworkProfilesListResponse` object, and + provides an ``__iter__`` method to iterate through its + ``items`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``List`` requests and continue to iterate + through the ``items`` field on the + corresponding responses. + + All the usual :class:`google.cloud.compute_v1.types.NetworkProfilesListResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., compute.NetworkProfilesListResponse], + request: compute.ListNetworkProfilesRequest, + response: compute.NetworkProfilesListResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.compute_v1.types.ListNetworkProfilesRequest): + The initial request object. + response (google.cloud.compute_v1.types.NetworkProfilesListResponse): + The initial response object. + 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, 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 = compute.ListNetworkProfilesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[compute.NetworkProfilesListResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[compute.NetworkProfile]: + for page in self.pages: + yield from page.items + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/README.rst b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/README.rst new file mode 100644 index 000000000000..a640a3575956 --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/README.rst @@ -0,0 +1,9 @@ + +transport inheritance structure +_______________________________ + +`NetworkProfilesTransport` is the ABC for all transports. +- public child `NetworkProfilesGrpcTransport` for sync gRPC transport (defined in `grpc.py`). +- public child `NetworkProfilesGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). +- private child `_BaseNetworkProfilesRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). +- public child `NetworkProfilesRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/__init__.py new file mode 100644 index 000000000000..b4efe0556fbc --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/__init__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import NetworkProfilesTransport +from .rest import NetworkProfilesRestInterceptor, NetworkProfilesRestTransport + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[NetworkProfilesTransport]] +_transport_registry["rest"] = NetworkProfilesRestTransport + +__all__ = ( + "NetworkProfilesTransport", + "NetworkProfilesRestTransport", + "NetworkProfilesRestInterceptor", +) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/base.py new file mode 100644 index 000000000000..8adad8671dbf --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/base.py @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union + +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.compute_v1 import gapic_version as package_version +from google.cloud.compute_v1.types import compute + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) + + +class NetworkProfilesTransport(abc.ABC): + """Abstract transport class for NetworkProfiles.""" + + AUTH_SCOPES = ( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform", + ) + + DEFAULT_HOST: str = "compute.googleapis.com" + + def __init__( + self, + *, + host: str = DEFAULT_HOST, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to (default: 'compute.googleapis.com'). + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} + + # Save the scopes. + self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) + elif credentials is None and not self._ignore_credentials: + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience( + api_audience if api_audience else host + ) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + + @property + def host(self): + return self._host + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.get: gapic_v1.method.wrap_method( + self.get, + default_timeout=None, + client_info=client_info, + ), + self.list: gapic_v1.method.wrap_method( + self.list, + default_timeout=None, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def get( + self, + ) -> Callable[ + [compute.GetNetworkProfileRequest], + Union[compute.NetworkProfile, Awaitable[compute.NetworkProfile]], + ]: + raise NotImplementedError() + + @property + def list( + self, + ) -> Callable[ + [compute.ListNetworkProfilesRequest], + Union[ + compute.NetworkProfilesListResponse, + Awaitable[compute.NetworkProfilesListResponse], + ], + ]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ("NetworkProfilesTransport",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest.py new file mode 100644 index 000000000000..b1b3f27cf9d6 --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest.py @@ -0,0 +1,550 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# 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 + +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1, rest_helpers, rest_streaming +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.requests import AuthorizedSession # type: ignore +from google.protobuf import json_format +from requests import __version__ as requests_version + +from google.cloud.compute_v1.types import compute + +from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO +from .rest_base import _BaseNetworkProfilesRestTransport + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] +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, + grpc_version=None, + rest_version=f"requests@{requests_version}", +) + + +class NetworkProfilesRestInterceptor: + """Interceptor for NetworkProfiles. + + Interceptors are used to manipulate requests, request metadata, and responses + in arbitrary ways. + Example use cases include: + * Logging + * Verifying requests according to service or custom semantics + * Stripping extraneous information from responses + + These use cases and more can be enabled by injecting an + instance of a custom subclass when constructing the NetworkProfilesRestTransport. + + .. code-block:: python + class MyCustomNetworkProfilesInterceptor(NetworkProfilesRestInterceptor): + def pre_get(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list(self, response): + logging.log(f"Received response: {response}") + return response + + transport = NetworkProfilesRestTransport(interceptor=MyCustomNetworkProfilesInterceptor()) + client = NetworkProfilesClient(transport=transport) + + + """ + + def pre_get( + self, + request: compute.GetNetworkProfileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNetworkProfileRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetworkProfiles server. + """ + return request, metadata + + def post_get(self, response: compute.NetworkProfile) -> compute.NetworkProfile: + """Post-rpc interceptor for get + + Override in a subclass to manipulate the response + after it is returned by the NetworkProfiles server but before + it is returned to user code. + """ + return response + + def pre_list( + self, + request: compute.ListNetworkProfilesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNetworkProfilesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetworkProfiles server. + """ + return request, metadata + + def post_list( + self, response: compute.NetworkProfilesListResponse + ) -> compute.NetworkProfilesListResponse: + """Post-rpc interceptor for list + + Override in a subclass to manipulate the response + after it is returned by the NetworkProfiles server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class NetworkProfilesRestStub: + _session: AuthorizedSession + _host: str + _interceptor: NetworkProfilesRestInterceptor + + +class NetworkProfilesRestTransport(_BaseNetworkProfilesRestTransport): + """REST backend synchronous transport for NetworkProfiles. + + The NetworkProfiles API. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + """ + + def __init__( + self, + *, + host: str = "compute.googleapis.com", + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = "https", + interceptor: Optional[NetworkProfilesRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + NOTE: This REST transport functionality is currently in a beta + state (preview). We welcome your feedback via a GitHub issue in + this library's repository. Thank you! + + Args: + host (Optional[str]): + The hostname to connect to (default: 'compute.googleapis.com'). + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + url_scheme=url_scheme, + api_audience=api_audience, + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST + ) + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or NetworkProfilesRestInterceptor() + self._prep_wrapped_messages(client_info) + + class _Get(_BaseNetworkProfilesRestTransport._BaseGet, NetworkProfilesRestStub): + def __hash__(self): + return hash("NetworkProfilesRestTransport.Get") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: compute.GetNetworkProfileRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.NetworkProfile: + r"""Call the get method over HTTP. + + Args: + request (~.compute.GetNetworkProfileRequest): + The request object. A request message for + NetworkProfiles.Get. See the method + description for details. + 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, 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: + ~.compute.NetworkProfile: + NetworkProfile represents a Google + managed network profile resource. + + """ + + http_options = ( + _BaseNetworkProfilesRestTransport._BaseGet._get_http_options() + ) + + request, metadata = self._interceptor.pre_get(request, metadata) + transcoded_request = ( + _BaseNetworkProfilesRestTransport._BaseGet._get_transcoded_request( + http_options, request + ) + ) + + # Jsonify the query params + query_params = ( + _BaseNetworkProfilesRestTransport._BaseGet._get_query_params_json( + 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 = 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.compute_v1.NetworkProfilesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkProfiles", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetworkProfilesRestTransport._Get._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.NetworkProfile() + pb_resp = compute.NetworkProfile.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkProfile.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.compute_v1.NetworkProfilesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkProfiles", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _List(_BaseNetworkProfilesRestTransport._BaseList, NetworkProfilesRestStub): + def __hash__(self): + return hash("NetworkProfilesRestTransport.List") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: compute.ListNetworkProfilesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.NetworkProfilesListResponse: + r"""Call the list method over HTTP. + + Args: + request (~.compute.ListNetworkProfilesRequest): + The request object. A request message for + NetworkProfiles.List. See the method + description for details. + 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, 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: + ~.compute.NetworkProfilesListResponse: + Contains a list of network profiles. + """ + + http_options = ( + _BaseNetworkProfilesRestTransport._BaseList._get_http_options() + ) + + request, metadata = self._interceptor.pre_list(request, metadata) + transcoded_request = ( + _BaseNetworkProfilesRestTransport._BaseList._get_transcoded_request( + http_options, request + ) + ) + + # Jsonify the query params + query_params = ( + _BaseNetworkProfilesRestTransport._BaseList._get_query_params_json( + 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 = 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.compute_v1.NetworkProfilesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkProfiles", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = NetworkProfilesRestTransport._List._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.NetworkProfilesListResponse() + pb_resp = compute.NetworkProfilesListResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkProfilesListResponse.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.compute_v1.NetworkProfilesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkProfiles", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + @property + def get( + self, + ) -> Callable[[compute.GetNetworkProfileRequest], compute.NetworkProfile]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._Get(self._session, self._host, self._interceptor) # type: ignore + + @property + def list( + self, + ) -> Callable[ + [compute.ListNetworkProfilesRequest], compute.NetworkProfilesListResponse + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._List(self._session, self._host, self._interceptor) # type: ignore + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__ = ("NetworkProfilesRestTransport",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest_base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest_base.py new file mode 100644 index 000000000000..84c23caada1b --- /dev/null +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_profiles/transports/rest_base.py @@ -0,0 +1,183 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import json # type: ignore +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1, path_template +from google.protobuf import json_format + +from google.cloud.compute_v1.types import compute + +from .base import DEFAULT_CLIENT_INFO, NetworkProfilesTransport + + +class _BaseNetworkProfilesRestTransport(NetworkProfilesTransport): + """Base REST backend transport for NetworkProfiles. + + Note: This class is not meant to be used directly. Use its sync and + async sub-classes instead. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + """ + + def __init__( + self, + *, + host: str = "compute.googleapis.com", + credentials: Optional[Any] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = "https", + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + Args: + host (Optional[str]): + The hostname to connect to (default: 'compute.googleapis.com'). + credentials (Optional[Any]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) + if maybe_url_match is None: + raise ValueError( + f"Unexpected hostname structure: {host}" + ) # pragma: NO COVER + + url_match_items = maybe_url_match.groupdict() + + host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + + class _BaseGet: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/compute/v1/projects/{project}/global/networkProfiles/{network_profile}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.GetNetworkProfileRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseNetworkProfilesRestTransport._BaseGet._get_unset_required_fields( + query_params + ) + ) + + return query_params + + class _BaseList: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/compute/v1/projects/{project}/global/networkProfiles", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.ListNetworkProfilesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseNetworkProfilesRestTransport._BaseList._get_unset_required_fields( + query_params + ) + ) + + return query_params + + +__all__ = ("_BaseNetworkProfilesRestTransport",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/client.py index f717cc871469..ac1d43bd8c92 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.networks import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.NetworksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "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.compute.v1.Networks", + "credentialsType": None, + }, + ) + def add_peering_unary( self, request: Optional[Union[compute.AddPeeringNetworkRequest, dict]] = None, @@ -629,7 +666,7 @@ def add_peering_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds a peering to the specified network. @@ -685,8 +722,10 @@ def sample_add_peering(): 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.api_core.extended_operation.ExtendedOperation: @@ -761,7 +800,7 @@ def add_peering( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds a peering to the specified network. @@ -817,8 +856,10 @@ def sample_add_peering(): 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.api_core.extended_operation.ExtendedOperation: @@ -914,7 +955,7 @@ def delete_unary( network: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified network. @@ -963,8 +1004,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1030,7 +1073,7 @@ def delete( network: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified network. @@ -1079,8 +1122,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1170,7 +1215,7 @@ def get( network: 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]]] = (), ) -> compute.Network: r"""Returns the specified network. @@ -1218,8 +1263,10 @@ def sample_get(): 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.compute_v1.types.Network: @@ -1290,7 +1337,7 @@ def get_effective_firewalls( network: 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]]] = (), ) -> compute.NetworksGetEffectiveFirewallsResponse: r"""Returns the effective firewalls on a given network. @@ -1339,8 +1386,10 @@ def sample_get_effective_firewalls(): 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.compute_v1.types.NetworksGetEffectiveFirewallsResponse: @@ -1404,7 +1453,7 @@ def insert_unary( network_resource: Optional[compute.Network] = 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]]] = (), ) -> compute.Operation: r"""Creates a network in the specified project using the data included in the request. @@ -1453,8 +1502,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1515,7 +1566,7 @@ def insert( network_resource: Optional[compute.Network] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a network in the specified project using the data included in the request. @@ -1564,8 +1615,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1649,7 +1702,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of networks available to the specified project. @@ -1693,8 +1746,10 @@ def sample_list(): 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.compute_v1.services.networks.pagers.ListPager: @@ -1767,7 +1822,7 @@ def list_peering_routes( network: 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.ListPeeringRoutesPager: r"""Lists the peering routes exchanged over peering connection. @@ -1818,8 +1873,10 @@ def sample_list_peering_routes(): 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.compute_v1.services.networks.pagers.ListPeeringRoutesPager: @@ -1898,7 +1955,7 @@ def patch_unary( network_resource: Optional[compute.Network] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified network with the data included in the request. Only routingConfig can be modified. @@ -1952,8 +2009,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2022,7 +2081,7 @@ def patch( network_resource: Optional[compute.Network] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified network with the data included in the request. Only routingConfig can be modified. @@ -2076,8 +2135,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2172,7 +2233,7 @@ def remove_peering_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes a peering from the specified network. @@ -2228,8 +2289,10 @@ def sample_remove_peering(): 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.api_core.extended_operation.ExtendedOperation: @@ -2304,7 +2367,7 @@ def remove_peering( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes a peering from the specified network. @@ -2360,8 +2423,10 @@ def sample_remove_peering(): 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.api_core.extended_operation.ExtendedOperation: @@ -2457,7 +2522,7 @@ def switch_to_custom_mode_unary( network: 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]]] = (), ) -> compute.Operation: r"""Switches the network mode from auto subnet mode to custom subnet mode. @@ -2507,8 +2572,10 @@ def sample_switch_to_custom_mode(): 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.api_core.extended_operation.ExtendedOperation: @@ -2574,7 +2641,7 @@ def switch_to_custom_mode( network: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Switches the network mode from auto subnet mode to custom subnet mode. @@ -2624,8 +2691,10 @@ def sample_switch_to_custom_mode(): 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.api_core.extended_operation.ExtendedOperation: @@ -2718,7 +2787,7 @@ def update_peering_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified network peering with the data included in the request. You can only modify the @@ -2777,8 +2846,10 @@ def sample_update_peering(): 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.api_core.extended_operation.ExtendedOperation: @@ -2853,7 +2924,7 @@ def update_peering( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified network peering with the data included in the request. You can only modify the @@ -2912,8 +2983,10 @@ def sample_update_peering(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/pagers.py index 9124250d2c66..b97ed87db9f5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/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 = compute.ListNetworksRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListPeeringRoutesNetworksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/transports/rest.py index 8a278930336b..db29bebbf255 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/networks/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 @@ -37,6 +37,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, @@ -157,8 +165,10 @@ def post_update_peering(self, response): def pre_add_peering( self, request: compute.AddPeeringNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddPeeringNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddPeeringNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_peering Override in a subclass to manipulate the request or metadata @@ -176,8 +186,10 @@ def post_add_peering(self, response: compute.Operation) -> compute.Operation: return response def pre_delete( - self, request: compute.DeleteNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -195,8 +207,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -216,8 +230,11 @@ def post_get(self, response: compute.Network) -> compute.Network: def pre_get_effective_firewalls( self, request: compute.GetEffectiveFirewallsNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetEffectiveFirewallsNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetEffectiveFirewallsNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_effective_firewalls Override in a subclass to manipulate the request or metadata @@ -237,8 +254,10 @@ def post_get_effective_firewalls( return response def pre_insert( - self, request: compute.InsertNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -256,8 +275,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListNetworksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListNetworksRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListNetworksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListNetworksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -277,8 +298,11 @@ def post_list(self, response: compute.NetworkList) -> compute.NetworkList: def pre_list_peering_routes( self, request: compute.ListPeeringRoutesNetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListPeeringRoutesNetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListPeeringRoutesNetworksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_peering_routes Override in a subclass to manipulate the request or metadata @@ -298,8 +322,10 @@ def post_list_peering_routes( return response def pre_patch( - self, request: compute.PatchNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PatchNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PatchNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -319,8 +345,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_remove_peering( self, request: compute.RemovePeeringNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemovePeeringNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemovePeeringNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_peering Override in a subclass to manipulate the request or metadata @@ -340,8 +368,11 @@ def post_remove_peering(self, response: compute.Operation) -> compute.Operation: def pre_switch_to_custom_mode( self, request: compute.SwitchToCustomModeNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SwitchToCustomModeNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SwitchToCustomModeNetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for switch_to_custom_mode Override in a subclass to manipulate the request or metadata @@ -363,8 +394,10 @@ def post_switch_to_custom_mode( def pre_update_peering( self, request: compute.UpdatePeeringNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdatePeeringNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdatePeeringNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_peering Override in a subclass to manipulate the request or metadata @@ -505,7 +538,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]]] = (), ) -> compute.Operation: r"""Call the add peering method over HTTP. @@ -517,8 +550,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: ~.compute.Operation: @@ -545,6 +580,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseAddPeering._get_http_options() ) + request, metadata = self._interceptor.pre_add_peering(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseAddPeering._get_transcoded_request( @@ -563,6 +599,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.compute_v1.NetworksClient.AddPeering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "AddPeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._AddPeering._get_response( self._host, @@ -584,7 +647,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.add_peering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "AddPeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseNetworksRestTransport._BaseDelete, NetworksRestStub): @@ -619,7 +704,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -631,8 +716,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: ~.compute.Operation: @@ -657,6 +744,7 @@ def __call__( """ http_options = _BaseNetworksRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseDelete._get_transcoded_request( @@ -671,6 +759,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.compute_v1.NetworksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._Delete._get_response( self._host, @@ -691,7 +806,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseNetworksRestTransport._BaseGet, NetworksRestStub): @@ -726,7 +863,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]]] = (), ) -> compute.Network: r"""Call the get method over HTTP. @@ -737,8 +874,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: ~.compute.Network: @@ -751,6 +890,7 @@ def __call__( """ http_options = _BaseNetworksRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseGet._get_transcoded_request( @@ -763,6 +903,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 = 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.compute_v1.NetworksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._Get._get_response( self._host, @@ -783,7 +950,29 @@ def __call__( pb_resp = compute.Network.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Network.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.compute_v1.NetworksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveFirewalls( @@ -820,7 +1009,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]]] = (), ) -> compute.NetworksGetEffectiveFirewallsResponse: r"""Call the get effective firewalls method over HTTP. @@ -832,8 +1021,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: ~.compute.NetworksGetEffectiveFirewallsResponse: @@ -843,6 +1034,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseGetEffectiveFirewalls._get_http_options() ) + request, metadata = self._interceptor.pre_get_effective_firewalls( request, metadata ) @@ -855,6 +1047,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 = 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.compute_v1.NetworksClient.GetEffectiveFirewalls", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "GetEffectiveFirewalls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._GetEffectiveFirewalls._get_response( self._host, @@ -875,7 +1094,31 @@ def __call__( pb_resp = compute.NetworksGetEffectiveFirewallsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_firewalls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworksGetEffectiveFirewallsResponse.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.compute_v1.NetworksClient.get_effective_firewalls", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "GetEffectiveFirewalls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseNetworksRestTransport._BaseInsert, NetworksRestStub): @@ -911,7 +1154,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -923,8 +1166,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: ~.compute.Operation: @@ -949,6 +1194,7 @@ def __call__( """ http_options = _BaseNetworksRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseInsert._get_transcoded_request( @@ -967,6 +1213,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.compute_v1.NetworksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._Insert._get_response( self._host, @@ -988,7 +1261,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseNetworksRestTransport._BaseList, NetworksRestStub): @@ -1023,7 +1318,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]]] = (), ) -> compute.NetworkList: r"""Call the list method over HTTP. @@ -1034,8 +1329,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: ~.compute.NetworkList: @@ -1043,6 +1340,7 @@ def __call__( """ http_options = _BaseNetworksRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseList._get_transcoded_request( @@ -1055,6 +1353,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 = 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.compute_v1.NetworksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._List._get_response( self._host, @@ -1075,7 +1400,29 @@ def __call__( pb_resp = compute.NetworkList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkList.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.compute_v1.NetworksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPeeringRoutes( @@ -1112,7 +1459,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]]] = (), ) -> compute.ExchangedPeeringRoutesList: r"""Call the list peering routes method over HTTP. @@ -1124,8 +1471,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: ~.compute.ExchangedPeeringRoutesList: @@ -1135,6 +1484,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseListPeeringRoutes._get_http_options() ) + request, metadata = self._interceptor.pre_list_peering_routes( request, metadata ) @@ -1147,6 +1497,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 = 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.compute_v1.NetworksClient.ListPeeringRoutes", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "ListPeeringRoutes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._ListPeeringRoutes._get_response( self._host, @@ -1167,7 +1544,31 @@ def __call__( pb_resp = compute.ExchangedPeeringRoutesList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_peering_routes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ExchangedPeeringRoutesList.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.compute_v1.NetworksClient.list_peering_routes", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "ListPeeringRoutes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseNetworksRestTransport._BasePatch, NetworksRestStub): @@ -1203,7 +1604,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1214,8 +1615,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: ~.compute.Operation: @@ -1240,6 +1643,7 @@ def __call__( """ http_options = _BaseNetworksRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BasePatch._get_transcoded_request( @@ -1256,6 +1660,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 = 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.compute_v1.NetworksClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._Patch._get_response( self._host, @@ -1277,7 +1708,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemovePeering( @@ -1315,7 +1768,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]]] = (), ) -> compute.Operation: r"""Call the remove peering method over HTTP. @@ -1327,8 +1780,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: ~.compute.Operation: @@ -1355,6 +1810,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseRemovePeering._get_http_options() ) + request, metadata = self._interceptor.pre_remove_peering(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseRemovePeering._get_transcoded_request( @@ -1373,6 +1829,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.compute_v1.NetworksClient.RemovePeering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "RemovePeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._RemovePeering._get_response( self._host, @@ -1394,7 +1877,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.remove_peering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "RemovePeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SwitchToCustomMode( @@ -1431,7 +1936,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]]] = (), ) -> compute.Operation: r"""Call the switch to custom mode method over HTTP. @@ -1443,8 +1948,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: ~.compute.Operation: @@ -1471,6 +1978,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseSwitchToCustomMode._get_http_options() ) + request, metadata = self._interceptor.pre_switch_to_custom_mode( request, metadata ) @@ -1483,6 +1991,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 = 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.compute_v1.NetworksClient.SwitchToCustomMode", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "SwitchToCustomMode", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._SwitchToCustomMode._get_response( self._host, @@ -1503,7 +2038,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_switch_to_custom_mode(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.switch_to_custom_mode", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "SwitchToCustomMode", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePeering( @@ -1541,7 +2098,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]]] = (), ) -> compute.Operation: r"""Call the update peering method over HTTP. @@ -1553,8 +2110,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: ~.compute.Operation: @@ -1581,6 +2140,7 @@ def __call__( http_options = ( _BaseNetworksRestTransport._BaseUpdatePeering._get_http_options() ) + request, metadata = self._interceptor.pre_update_peering(request, metadata) transcoded_request = ( _BaseNetworksRestTransport._BaseUpdatePeering._get_transcoded_request( @@ -1599,6 +2159,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.compute_v1.NetworksClient.UpdatePeering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "UpdatePeering", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworksRestTransport._UpdatePeering._get_response( self._host, @@ -1620,7 +2207,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_peering(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NetworksClient.update_peering", + extra={ + "serviceName": "google.cloud.compute.v1.Networks", + "rpcName": "UpdatePeering", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/client.py index 482ea133127e..6e92e2cec2b2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.node_groups import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.NodeGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "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.compute.v1.NodeGroups", + "credentialsType": None, + }, + ) + def add_nodes_unary( self, request: Optional[Union[compute.AddNodesNodeGroupRequest, dict]] = None, @@ -630,7 +667,7 @@ def add_nodes_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds specified number of nodes to the node group. @@ -692,8 +729,10 @@ def sample_add_nodes(): 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.api_core.extended_operation.ExtendedOperation: @@ -772,7 +811,7 @@ def add_nodes( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds specified number of nodes to the node group. @@ -834,8 +873,10 @@ def sample_add_nodes(): 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.api_core.extended_operation.ExtendedOperation: @@ -934,7 +975,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group. To @@ -981,8 +1022,10 @@ def sample_aggregated_list(): 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.compute_v1.services.node_groups.pagers.AggregatedListPager: @@ -1054,7 +1097,7 @@ def delete_unary( node_group: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified NodeGroup resource. @@ -1113,8 +1156,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1184,7 +1229,7 @@ def delete( node_group: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified NodeGroup resource. @@ -1243,8 +1288,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1342,7 +1389,7 @@ def delete_nodes_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Deletes specified nodes from the node group. @@ -1406,8 +1453,10 @@ def sample_delete_nodes(): 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.api_core.extended_operation.ExtendedOperation: @@ -1486,7 +1535,7 @@ def delete_nodes( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes specified nodes from the node group. @@ -1550,8 +1599,10 @@ def sample_delete_nodes(): 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.api_core.extended_operation.ExtendedOperation: @@ -1652,7 +1703,7 @@ def get( node_group: 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]]] = (), ) -> compute.NodeGroup: r"""Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: @@ -1711,8 +1762,10 @@ def sample_get(): 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.compute_v1.types.NodeGroup: @@ -1791,7 +1844,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1851,8 +1904,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.cloud.compute_v1.types.Policy: @@ -1943,7 +1998,7 @@ def insert_unary( node_group_resource: Optional[compute.NodeGroup] = 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]]] = (), ) -> compute.Operation: r"""Creates a NodeGroup resource in the specified project using the data included in the request. @@ -2008,8 +2063,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2083,7 +2140,7 @@ def insert( node_group_resource: Optional[compute.NodeGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a NodeGroup resource in the specified project using the data included in the request. @@ -2148,8 +2205,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2246,7 +2305,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for @@ -2300,8 +2359,10 @@ def sample_list(): 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.compute_v1.services.node_groups.pagers.ListPager: @@ -2382,7 +2443,7 @@ def list_nodes( node_group: 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.ListNodesPager: r"""Lists nodes in the node group. @@ -2442,8 +2503,10 @@ def sample_list_nodes(): 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.compute_v1.services.node_groups.pagers.ListNodesPager: @@ -2526,7 +2589,7 @@ def patch_unary( node_group_resource: Optional[compute.NodeGroup] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified node group. @@ -2590,8 +2653,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2664,7 +2729,7 @@ def patch( node_group_resource: Optional[compute.NodeGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified node group. @@ -2728,8 +2793,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2831,7 +2898,7 @@ def perform_maintenance_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Perform maintenance on a subset of nodes in the node group. @@ -2896,8 +2963,10 @@ def sample_perform_maintenance(): 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.api_core.extended_operation.ExtendedOperation: @@ -2983,7 +3052,7 @@ def perform_maintenance( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Perform maintenance on a subset of nodes in the node group. @@ -3048,8 +3117,10 @@ def sample_perform_maintenance(): 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.api_core.extended_operation.ExtendedOperation: @@ -3156,7 +3227,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3221,8 +3292,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.cloud.compute_v1.types.Policy: @@ -3321,7 +3394,7 @@ def set_node_template_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Updates the node template of the node group. @@ -3385,8 +3458,10 @@ def sample_set_node_template(): 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.api_core.extended_operation.ExtendedOperation: @@ -3465,7 +3540,7 @@ def set_node_template( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the node template of the node group. @@ -3529,8 +3604,10 @@ def sample_set_node_template(): 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.api_core.extended_operation.ExtendedOperation: @@ -3636,7 +3713,7 @@ def simulate_maintenance_event_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Simulates maintenance event on specified nodes from the node group. @@ -3702,8 +3779,10 @@ def sample_simulate_maintenance_event(): 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.api_core.extended_operation.ExtendedOperation: @@ -3791,7 +3870,7 @@ def simulate_maintenance_event( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Simulates maintenance event on specified nodes from the node group. @@ -3857,8 +3936,10 @@ def sample_simulate_maintenance_event(): 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.api_core.extended_operation.ExtendedOperation: @@ -3971,7 +4052,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -4036,8 +4117,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/pagers.py index 5c70507ce588..0202a3eeec92 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/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 = compute.AggregatedListNodeGroupsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListNodeGroupsRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListNodesNodeGroupsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/transports/rest.py index 576a183d1522..39570a632dcc 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_groups/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 @@ -37,6 +37,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, @@ -189,8 +197,10 @@ def post_test_iam_permissions(self, response): def pre_add_nodes( self, request: compute.AddNodesNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddNodesNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddNodesNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_nodes Override in a subclass to manipulate the request or metadata @@ -210,8 +220,10 @@ def post_add_nodes(self, response: compute.Operation) -> compute.Operation: def pre_aggregated_list( self, request: compute.AggregatedListNodeGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListNodeGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListNodeGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -233,8 +245,8 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -254,8 +266,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_nodes( self, request: compute.DeleteNodesNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNodesNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteNodesNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_nodes Override in a subclass to manipulate the request or metadata @@ -273,8 +287,10 @@ def post_delete_nodes(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetNodeGroupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetNodeGroupRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetNodeGroupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -294,8 +310,10 @@ def post_get(self, response: compute.NodeGroup) -> compute.NodeGroup: def pre_get_iam_policy( self, request: compute.GetIamPolicyNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -315,8 +333,8 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -336,8 +354,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListNodeGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNodeGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListNodeGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -357,8 +375,10 @@ def post_list(self, response: compute.NodeGroupList) -> compute.NodeGroupList: def pre_list_nodes( self, request: compute.ListNodesNodeGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNodesNodeGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNodesNodeGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_nodes Override in a subclass to manipulate the request or metadata @@ -380,8 +400,8 @@ def post_list_nodes( def pre_patch( self, request: compute.PatchNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -401,8 +421,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_perform_maintenance( self, request: compute.PerformMaintenanceNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PerformMaintenanceNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PerformMaintenanceNodeGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for perform_maintenance Override in a subclass to manipulate the request or metadata @@ -424,8 +447,10 @@ def post_perform_maintenance( def pre_set_iam_policy( self, request: compute.SetIamPolicyNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -445,8 +470,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_node_template( self, request: compute.SetNodeTemplateNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetNodeTemplateNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetNodeTemplateNodeGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_node_template Override in a subclass to manipulate the request or metadata @@ -466,9 +493,10 @@ def post_set_node_template(self, response: compute.Operation) -> compute.Operati def pre_simulate_maintenance_event( self, request: compute.SimulateMaintenanceEventNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SimulateMaintenanceEventNodeGroupRequest, Sequence[Tuple[str, str]] + compute.SimulateMaintenanceEventNodeGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for simulate_maintenance_event @@ -491,8 +519,11 @@ def post_simulate_maintenance_event( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsNodeGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsNodeGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsNodeGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -635,7 +666,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]]] = (), ) -> compute.Operation: r"""Call the add nodes method over HTTP. @@ -647,8 +678,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: ~.compute.Operation: @@ -675,6 +708,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseAddNodes._get_http_options() ) + request, metadata = self._interceptor.pre_add_nodes(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseAddNodes._get_transcoded_request( @@ -693,6 +727,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.compute_v1.NodeGroupsClient.AddNodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "AddNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._AddNodes._get_response( self._host, @@ -714,7 +775,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.add_nodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "AddNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -751,7 +834,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]]] = (), ) -> compute.NodeGroupAggregatedList: r"""Call the aggregated list method over HTTP. @@ -763,8 +846,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: ~.compute.NodeGroupAggregatedList: @@ -774,6 +859,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseNodeGroupsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -786,6 +872,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.compute_v1.NodeGroupsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._AggregatedList._get_response( self._host, @@ -806,7 +919,29 @@ def __call__( pb_resp = compute.NodeGroupAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeGroupAggregatedList.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.compute_v1.NodeGroupsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseNodeGroupsRestTransport._BaseDelete, NodeGroupsRestStub): @@ -841,7 +976,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -853,8 +988,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: ~.compute.Operation: @@ -879,6 +1016,7 @@ def __call__( """ http_options = _BaseNodeGroupsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseDelete._get_transcoded_request( @@ -893,6 +1031,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.compute_v1.NodeGroupsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._Delete._get_response( self._host, @@ -913,7 +1078,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNodes( @@ -951,7 +1138,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]]] = (), ) -> compute.Operation: r"""Call the delete nodes method over HTTP. @@ -963,8 +1150,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: ~.compute.Operation: @@ -991,6 +1180,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseDeleteNodes._get_http_options() ) + request, metadata = self._interceptor.pre_delete_nodes(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseDeleteNodes._get_transcoded_request( @@ -1009,6 +1199,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.compute_v1.NodeGroupsClient.DeleteNodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "DeleteNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._DeleteNodes._get_response( self._host, @@ -1030,7 +1247,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.delete_nodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "DeleteNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseNodeGroupsRestTransport._BaseGet, NodeGroupsRestStub): @@ -1065,7 +1304,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]]] = (), ) -> compute.NodeGroup: r"""Call the get method over HTTP. @@ -1076,8 +1315,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: ~.compute.NodeGroup: @@ -1096,6 +1337,7 @@ def __call__( """ http_options = _BaseNodeGroupsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseGet._get_transcoded_request( @@ -1108,6 +1350,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 = 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.compute_v1.NodeGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._Get._get_response( self._host, @@ -1128,7 +1397,29 @@ def __call__( pb_resp = compute.NodeGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeGroup.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.compute_v1.NodeGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1165,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1177,8 +1468,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: ~.compute.Policy: @@ -1211,6 +1504,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1225,6 +1519,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.compute_v1.NodeGroupsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._GetIamPolicy._get_response( self._host, @@ -1245,7 +1566,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NodeGroupsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseNodeGroupsRestTransport._BaseInsert, NodeGroupsRestStub): @@ -1281,7 +1624,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1293,8 +1636,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: ~.compute.Operation: @@ -1319,6 +1664,7 @@ def __call__( """ http_options = _BaseNodeGroupsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseInsert._get_transcoded_request( @@ -1337,6 +1683,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.compute_v1.NodeGroupsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._Insert._get_response( self._host, @@ -1358,7 +1731,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseNodeGroupsRestTransport._BaseList, NodeGroupsRestStub): @@ -1393,7 +1788,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]]] = (), ) -> compute.NodeGroupList: r"""Call the list method over HTTP. @@ -1405,8 +1800,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: ~.compute.NodeGroupList: @@ -1414,6 +1811,7 @@ def __call__( """ http_options = _BaseNodeGroupsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseList._get_transcoded_request( @@ -1428,6 +1826,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.compute_v1.NodeGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._List._get_response( self._host, @@ -1448,7 +1873,29 @@ def __call__( pb_resp = compute.NodeGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeGroupList.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.compute_v1.NodeGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNodes(_BaseNodeGroupsRestTransport._BaseListNodes, NodeGroupsRestStub): @@ -1483,7 +1930,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]]] = (), ) -> compute.NodeGroupsListNodes: r"""Call the list nodes method over HTTP. @@ -1495,8 +1942,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: ~.compute.NodeGroupsListNodes: @@ -1506,6 +1955,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseListNodes._get_http_options() ) + request, metadata = self._interceptor.pre_list_nodes(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseListNodes._get_transcoded_request( @@ -1520,6 +1970,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.compute_v1.NodeGroupsClient.ListNodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "ListNodes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._ListNodes._get_response( self._host, @@ -1540,7 +2017,29 @@ def __call__( pb_resp = compute.NodeGroupsListNodes.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_nodes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeGroupsListNodes.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.compute_v1.NodeGroupsClient.list_nodes", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "ListNodes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseNodeGroupsRestTransport._BasePatch, NodeGroupsRestStub): @@ -1576,7 +2075,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1588,8 +2087,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: ~.compute.Operation: @@ -1614,6 +2115,7 @@ def __call__( """ http_options = _BaseNodeGroupsRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BasePatch._get_transcoded_request( @@ -1632,6 +2134,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.compute_v1.NodeGroupsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._Patch._get_response( self._host, @@ -1653,7 +2182,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PerformMaintenance( @@ -1691,7 +2242,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]]] = (), ) -> compute.Operation: r"""Call the perform maintenance method over HTTP. @@ -1703,8 +2254,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: ~.compute.Operation: @@ -1731,6 +2284,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BasePerformMaintenance._get_http_options() ) + request, metadata = self._interceptor.pre_perform_maintenance( request, metadata ) @@ -1747,6 +2301,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 = 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.compute_v1.NodeGroupsClient.PerformMaintenance", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "PerformMaintenance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._PerformMaintenance._get_response( self._host, @@ -1768,7 +2349,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_perform_maintenance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.perform_maintenance", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "PerformMaintenance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1806,7 +2409,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1818,8 +2421,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: ~.compute.Policy: @@ -1852,6 +2457,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseNodeGroupsRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1872,6 +2478,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.compute_v1.NodeGroupsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._SetIamPolicy._get_response( self._host, @@ -1893,7 +2526,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NodeGroupsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetNodeTemplate( @@ -1931,7 +2586,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]]] = (), ) -> compute.Operation: r"""Call the set node template method over HTTP. @@ -1943,8 +2598,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: ~.compute.Operation: @@ -1971,6 +2628,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseSetNodeTemplate._get_http_options() ) + request, metadata = self._interceptor.pre_set_node_template( request, metadata ) @@ -1987,6 +2645,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 = 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.compute_v1.NodeGroupsClient.SetNodeTemplate", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SetNodeTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._SetNodeTemplate._get_response( self._host, @@ -2008,7 +2693,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_node_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.set_node_template", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SetNodeTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SimulateMaintenanceEvent( @@ -2046,7 +2753,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]]] = (), ) -> compute.Operation: r"""Call the simulate maintenance event method over HTTP. @@ -2059,8 +2766,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: ~.compute.Operation: @@ -2087,6 +2796,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseSimulateMaintenanceEvent._get_http_options() ) + request, metadata = self._interceptor.pre_simulate_maintenance_event( request, metadata ) @@ -2103,6 +2813,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 = 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.compute_v1.NodeGroupsClient.SimulateMaintenanceEvent", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SimulateMaintenanceEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._SimulateMaintenanceEvent._get_response( self._host, @@ -2124,7 +2861,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_simulate_maintenance_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeGroupsClient.simulate_maintenance_event", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "SimulateMaintenanceEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2162,7 +2921,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2174,8 +2933,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: ~.compute.TestPermissionsResponse: @@ -2185,6 +2946,7 @@ def __call__( http_options = ( _BaseNodeGroupsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2201,6 +2963,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 = 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.compute_v1.NodeGroupsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeGroupsRestTransport._TestIamPermissions._get_response( self._host, @@ -2222,7 +3011,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.NodeGroupsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.NodeGroups", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/client.py index 57c083a84003..cc827787a1af 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.node_templates import pagers @@ -556,6 +566,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( @@ -621,6 +635,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.compute_v1.NodeTemplatesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "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.compute.v1.NodeTemplates", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -630,7 +667,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of node templates. To prevent failure, Google recommends that you set the @@ -676,8 +713,10 @@ def sample_aggregated_list(): 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.compute_v1.services.node_templates.pagers.AggregatedListPager: @@ -749,7 +788,7 @@ def delete_unary( node_template: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified NodeTemplate resource. @@ -808,8 +847,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -879,7 +920,7 @@ def delete( node_template: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified NodeTemplate resource. @@ -938,8 +979,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1034,7 +1077,7 @@ def get( node_template: 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]]] = (), ) -> compute.NodeTemplate: r"""Returns the specified node template. @@ -1091,8 +1134,10 @@ def sample_get(): 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.compute_v1.types.NodeTemplate: @@ -1165,7 +1210,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1225,8 +1270,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.cloud.compute_v1.types.Policy: @@ -1316,7 +1363,7 @@ def insert_unary( node_template_resource: Optional[compute.NodeTemplate] = 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]]] = (), ) -> compute.Operation: r"""Creates a NodeTemplate resource in the specified project using the data included in the request. @@ -1373,8 +1420,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1443,7 +1492,7 @@ def insert( node_template_resource: Optional[compute.NodeTemplate] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a NodeTemplate resource in the specified project using the data included in the request. @@ -1500,8 +1549,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1594,7 +1645,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of node templates available to the specified project. @@ -1647,8 +1698,10 @@ def sample_list(): 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.compute_v1.services.node_templates.pagers.ListPager: @@ -1732,7 +1785,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1797,8 +1850,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.cloud.compute_v1.types.Policy: @@ -1899,7 +1954,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -1964,8 +2019,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/pagers.py index 06f02198bfef..14644245b36d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/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 = compute.AggregatedListNodeTemplatesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListNodeTemplatesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/transports/rest.py index 50b34ccc8361..dc3693828142 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_templates/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 @@ -37,6 +37,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, @@ -133,8 +141,11 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListNodeTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListNodeTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListNodeTemplatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -156,8 +167,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteNodeTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteNodeTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -177,8 +190,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNodeTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetNodeTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -198,8 +211,10 @@ def post_get(self, response: compute.NodeTemplate) -> compute.NodeTemplate: def pre_get_iam_policy( self, request: compute.GetIamPolicyNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyNodeTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyNodeTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -219,8 +234,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertNodeTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertNodeTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -240,8 +257,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListNodeTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListNodeTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListNodeTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -261,8 +280,10 @@ def post_list(self, response: compute.NodeTemplateList) -> compute.NodeTemplateL def pre_set_iam_policy( self, request: compute.SetIamPolicyNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyNodeTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyNodeTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -282,9 +303,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsNodeTemplateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsNodeTemplateRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsNodeTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -429,7 +451,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]]] = (), ) -> compute.NodeTemplateAggregatedList: r"""Call the aggregated list method over HTTP. @@ -441,8 +463,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: ~.compute.NodeTemplateAggregatedList: @@ -452,6 +476,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseNodeTemplatesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -462,6 +487,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 = 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.compute_v1.NodeTemplatesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._AggregatedList._get_response( self._host, @@ -482,7 +534,31 @@ def __call__( pb_resp = compute.NodeTemplateAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeTemplateAggregatedList.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.compute_v1.NodeTemplatesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseNodeTemplatesRestTransport._BaseDelete, NodeTemplatesRestStub): @@ -517,7 +593,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -529,8 +605,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: ~.compute.Operation: @@ -557,6 +635,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseNodeTemplatesRestTransport._BaseDelete._get_transcoded_request( @@ -571,6 +650,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.compute_v1.NodeTemplatesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._Delete._get_response( self._host, @@ -591,7 +697,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeTemplatesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseNodeTemplatesRestTransport._BaseGet, NodeTemplatesRestStub): @@ -626,7 +754,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]]] = (), ) -> compute.NodeTemplate: r"""Call the get method over HTTP. @@ -638,8 +766,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: ~.compute.NodeTemplate: @@ -652,6 +782,7 @@ def __call__( """ http_options = _BaseNodeTemplatesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseNodeTemplatesRestTransport._BaseGet._get_transcoded_request( @@ -666,6 +797,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.compute_v1.NodeTemplatesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._Get._get_response( self._host, @@ -686,7 +844,29 @@ def __call__( pb_resp = compute.NodeTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeTemplate.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.compute_v1.NodeTemplatesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -723,7 +903,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -735,8 +915,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: ~.compute.Policy: @@ -769,6 +951,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseNodeTemplatesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -779,6 +962,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 = 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.compute_v1.NodeTemplatesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._GetIamPolicy._get_response( self._host, @@ -799,7 +1009,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NodeTemplatesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseNodeTemplatesRestTransport._BaseInsert, NodeTemplatesRestStub): @@ -835,7 +1067,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -847,8 +1079,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: ~.compute.Operation: @@ -875,6 +1109,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseNodeTemplatesRestTransport._BaseInsert._get_transcoded_request( @@ -893,6 +1128,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.compute_v1.NodeTemplatesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._Insert._get_response( self._host, @@ -914,7 +1176,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.NodeTemplatesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseNodeTemplatesRestTransport._BaseList, NodeTemplatesRestStub): @@ -949,7 +1233,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]]] = (), ) -> compute.NodeTemplateList: r"""Call the list method over HTTP. @@ -961,8 +1245,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: ~.compute.NodeTemplateList: @@ -970,6 +1256,7 @@ def __call__( """ http_options = _BaseNodeTemplatesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseNodeTemplatesRestTransport._BaseList._get_transcoded_request( @@ -984,6 +1271,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.compute_v1.NodeTemplatesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._List._get_response( self._host, @@ -1004,7 +1318,29 @@ def __call__( pb_resp = compute.NodeTemplateList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeTemplateList.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.compute_v1.NodeTemplatesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1042,7 +1378,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1054,8 +1390,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: ~.compute.Policy: @@ -1088,6 +1426,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseNodeTemplatesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1102,6 +1441,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 = 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.compute_v1.NodeTemplatesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._SetIamPolicy._get_response( self._host, @@ -1123,7 +1489,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.NodeTemplatesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1161,7 +1549,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1173,8 +1561,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: ~.compute.TestPermissionsResponse: @@ -1184,6 +1574,7 @@ def __call__( http_options = ( _BaseNodeTemplatesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1200,6 +1591,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 = 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.compute_v1.NodeTemplatesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTemplatesRestTransport._TestIamPermissions._get_response( self._host, @@ -1221,7 +1639,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.NodeTemplatesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTemplates", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/client.py index e7314ae950fd..9b793fe99729 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/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.compute_v1.services.node_types import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.NodeTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "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.compute.v1.NodeTypes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListNodeTypesRequest, dict]] = None, @@ -622,7 +659,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of node types. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -668,8 +705,10 @@ def sample_aggregated_list(): 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.compute_v1.services.node_types.pagers.AggregatedListPager: @@ -741,7 +780,7 @@ def get( node_type: 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]]] = (), ) -> compute.NodeType: r"""Returns the specified node type. @@ -797,8 +836,10 @@ def sample_get(): 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.compute_v1.types.NodeType: @@ -875,7 +916,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of node types available to the specified project. @@ -927,8 +968,10 @@ def sample_list(): 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.compute_v1.services.node_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/pagers.py index 29406e35430c..c81acbd38f53 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/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 = compute.AggregatedListNodeTypesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListNodeTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/transports/rest.py index b770d197bdbe..823084a79601 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/node_types/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 @@ -37,6 +37,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, @@ -93,8 +101,10 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListNodeTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListNodeTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListNodeTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -114,8 +124,10 @@ def post_aggregated_list( return response def pre_get( - self, request: compute.GetNodeTypeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetNodeTypeRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetNodeTypeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetNodeTypeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -133,8 +145,10 @@ def post_get(self, response: compute.NodeType) -> compute.NodeType: return response def pre_list( - self, request: compute.ListNodeTypesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListNodeTypesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListNodeTypesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListNodeTypesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -276,7 +290,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]]] = (), ) -> compute.NodeTypeAggregatedList: r"""Call the aggregated list method over HTTP. @@ -288,8 +302,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: ~.compute.NodeTypeAggregatedList: @@ -299,6 +315,7 @@ def __call__( http_options = ( _BaseNodeTypesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseNodeTypesRestTransport._BaseAggregatedList._get_transcoded_request( @@ -313,6 +330,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.compute_v1.NodeTypesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTypesRestTransport._AggregatedList._get_response( self._host, @@ -333,7 +377,29 @@ def __call__( pb_resp = compute.NodeTypeAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeTypeAggregatedList.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.compute_v1.NodeTypesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseNodeTypesRestTransport._BaseGet, NodeTypesRestStub): @@ -368,7 +434,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]]] = (), ) -> compute.NodeType: r"""Call the get method over HTTP. @@ -379,8 +445,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: ~.compute.NodeType: @@ -398,6 +466,7 @@ def __call__( """ http_options = _BaseNodeTypesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseNodeTypesRestTransport._BaseGet._get_transcoded_request( @@ -410,6 +479,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 = 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.compute_v1.NodeTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTypesRestTransport._Get._get_response( self._host, @@ -430,7 +526,29 @@ def __call__( pb_resp = compute.NodeType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeType.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.compute_v1.NodeTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseNodeTypesRestTransport._BaseList, NodeTypesRestStub): @@ -465,7 +583,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]]] = (), ) -> compute.NodeTypeList: r"""Call the list method over HTTP. @@ -476,8 +594,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: ~.compute.NodeTypeList: @@ -485,6 +605,7 @@ def __call__( """ http_options = _BaseNodeTypesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseNodeTypesRestTransport._BaseList._get_transcoded_request( @@ -497,6 +618,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 = 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.compute_v1.NodeTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NodeTypesRestTransport._List._get_response( self._host, @@ -517,7 +665,29 @@ def __call__( pb_resp = compute.NodeTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NodeTypeList.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.compute_v1.NodeTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.NodeTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/client.py index 718b854586da..da159c1bedb7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.packet_mirrorings import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.PacketMirroringsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "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.compute.v1.PacketMirrorings", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -635,7 +672,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of packetMirrorings. To prevent failure, Google recommends that you set the @@ -681,8 +718,10 @@ def sample_aggregated_list(): 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.compute_v1.services.packet_mirrorings.pagers.AggregatedListPager: @@ -756,7 +795,7 @@ def delete_unary( packet_mirroring: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified PacketMirroring resource. @@ -813,8 +852,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -884,7 +925,7 @@ def delete( packet_mirroring: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified PacketMirroring resource. @@ -941,8 +982,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1037,7 +1080,7 @@ def get( packet_mirroring: 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]]] = (), ) -> compute.PacketMirroring: r"""Returns the specified PacketMirroring resource. @@ -1094,8 +1137,10 @@ def sample_get(): 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.compute_v1.types.PacketMirroring: @@ -1173,7 +1218,7 @@ def insert_unary( packet_mirroring_resource: Optional[compute.PacketMirroring] = 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]]] = (), ) -> compute.Operation: r"""Creates a PacketMirroring resource in the specified project and region using the data included in the @@ -1229,8 +1274,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1299,7 +1346,7 @@ def insert( packet_mirroring_resource: Optional[compute.PacketMirroring] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a PacketMirroring resource in the specified project and region using the data included in the @@ -1355,8 +1402,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1449,7 +1498,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of PacketMirroring resources available to the specified project and region. @@ -1500,8 +1549,10 @@ def sample_list(): 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.compute_v1.services.packet_mirrorings.pagers.ListPager: @@ -1583,7 +1634,7 @@ def patch_unary( packet_mirroring_resource: Optional[compute.PacketMirroring] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified PacketMirroring resource with the data included in the request. This method supports @@ -1648,8 +1699,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1724,7 +1777,7 @@ def patch( packet_mirroring_resource: Optional[compute.PacketMirroring] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified PacketMirroring resource with the data included in the request. This method supports @@ -1789,8 +1842,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1894,7 +1949,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -1959,8 +2014,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/pagers.py index bebfdcf72d4e..2f47e79148b5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/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 = compute.AggregatedListPacketMirroringsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListPacketMirroringsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/transports/rest.py index f0e2a1f6a425..82ba73f64e3c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/packet_mirrorings/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 @@ -37,6 +37,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, @@ -125,9 +133,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListPacketMirroringsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListPacketMirroringsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListPacketMirroringsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -150,8 +159,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeletePacketMirroringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeletePacketMirroringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeletePacketMirroringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -171,8 +182,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetPacketMirroringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetPacketMirroringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetPacketMirroringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -192,8 +205,10 @@ def post_get(self, response: compute.PacketMirroring) -> compute.PacketMirroring def pre_insert( self, request: compute.InsertPacketMirroringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertPacketMirroringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertPacketMirroringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -213,8 +228,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListPacketMirroringsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListPacketMirroringsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListPacketMirroringsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -236,8 +253,10 @@ def post_list( def pre_patch( self, request: compute.PatchPacketMirroringRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchPacketMirroringRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchPacketMirroringRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -257,9 +276,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsPacketMirroringRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsPacketMirroringRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsPacketMirroringRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -404,7 +424,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]]] = (), ) -> compute.PacketMirroringAggregatedList: r"""Call the aggregated list method over HTTP. @@ -416,8 +436,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: ~.compute.PacketMirroringAggregatedList: @@ -427,6 +449,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BasePacketMirroringsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -437,6 +460,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 = 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.compute_v1.PacketMirroringsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._AggregatedList._get_response( self._host, @@ -457,7 +507,31 @@ def __call__( pb_resp = compute.PacketMirroringAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PacketMirroringAggregatedList.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.compute_v1.PacketMirroringsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -494,7 +568,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -506,8 +580,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: ~.compute.Operation: @@ -534,6 +610,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BasePacketMirroringsRestTransport._BaseDelete._get_transcoded_request( @@ -548,6 +625,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.compute_v1.PacketMirroringsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._Delete._get_response( self._host, @@ -568,7 +672,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PacketMirroringsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BasePacketMirroringsRestTransport._BaseGet, PacketMirroringsRestStub): @@ -603,7 +729,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]]] = (), ) -> compute.PacketMirroring: r"""Call the get method over HTTP. @@ -615,8 +741,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: ~.compute.PacketMirroring: @@ -636,6 +764,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BasePacketMirroringsRestTransport._BaseGet._get_transcoded_request( @@ -650,6 +779,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.compute_v1.PacketMirroringsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._Get._get_response( self._host, @@ -670,7 +826,29 @@ def __call__( pb_resp = compute.PacketMirroring.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PacketMirroring.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.compute_v1.PacketMirroringsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -708,7 +886,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -720,8 +898,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: ~.compute.Operation: @@ -748,6 +928,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BasePacketMirroringsRestTransport._BaseInsert._get_transcoded_request( @@ -768,6 +949,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.compute_v1.PacketMirroringsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._Insert._get_response( self._host, @@ -789,7 +997,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PacketMirroringsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BasePacketMirroringsRestTransport._BaseList, PacketMirroringsRestStub): @@ -824,7 +1054,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]]] = (), ) -> compute.PacketMirroringList: r"""Call the list method over HTTP. @@ -836,8 +1066,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: ~.compute.PacketMirroringList: @@ -849,6 +1081,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BasePacketMirroringsRestTransport._BaseList._get_transcoded_request( @@ -863,6 +1096,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.compute_v1.PacketMirroringsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._List._get_response( self._host, @@ -883,7 +1143,29 @@ def __call__( pb_resp = compute.PacketMirroringList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PacketMirroringList.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.compute_v1.PacketMirroringsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -921,7 +1203,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -933,8 +1215,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: ~.compute.Operation: @@ -961,6 +1245,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BasePacketMirroringsRestTransport._BasePatch._get_transcoded_request( @@ -979,6 +1264,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.compute_v1.PacketMirroringsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._Patch._get_response( self._host, @@ -1000,7 +1312,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PacketMirroringsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1039,7 +1373,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1051,8 +1385,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: ~.compute.TestPermissionsResponse: @@ -1062,6 +1398,7 @@ def __call__( http_options = ( _BasePacketMirroringsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1078,6 +1415,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 = 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.compute_v1.PacketMirroringsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PacketMirroringsRestTransport._TestIamPermissions._get_response( self._host, @@ -1099,7 +1463,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.PacketMirroringsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.PacketMirrorings", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/client.py index 68f359e65666..be5a0c35b7ce 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.projects import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.ProjectsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "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.compute.v1.Projects", + "credentialsType": None, + }, + ) + def disable_xpn_host_unary( self, request: Optional[Union[compute.DisableXpnHostProjectRequest, dict]] = None, @@ -625,7 +662,7 @@ def disable_xpn_host_unary( project: 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]]] = (), ) -> compute.Operation: r"""Disable this project as a shared VPC host project. @@ -668,8 +705,10 @@ def sample_disable_xpn_host(): 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.api_core.extended_operation.ExtendedOperation: @@ -727,7 +766,7 @@ def disable_xpn_host( project: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Disable this project as a shared VPC host project. @@ -770,8 +809,10 @@ def sample_disable_xpn_host(): 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.api_core.extended_operation.ExtendedOperation: @@ -856,7 +897,7 @@ def disable_xpn_resource_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Disable a service resource (also known as service project) associated with this host project. @@ -905,8 +946,10 @@ def sample_disable_xpn_resource(): 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.api_core.extended_operation.ExtendedOperation: @@ -973,7 +1016,7 @@ def disable_xpn_resource( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Disable a service resource (also known as service project) associated with this host project. @@ -1022,8 +1065,10 @@ def sample_disable_xpn_resource(): 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.api_core.extended_operation.ExtendedOperation: @@ -1111,7 +1156,7 @@ def enable_xpn_host_unary( project: 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]]] = (), ) -> compute.Operation: r"""Enable this project as a shared VPC host project. @@ -1154,8 +1199,10 @@ def sample_enable_xpn_host(): 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.api_core.extended_operation.ExtendedOperation: @@ -1213,7 +1260,7 @@ def enable_xpn_host( project: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Enable this project as a shared VPC host project. @@ -1256,8 +1303,10 @@ def sample_enable_xpn_host(): 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.api_core.extended_operation.ExtendedOperation: @@ -1342,7 +1391,7 @@ def enable_xpn_resource_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be @@ -1392,8 +1441,10 @@ def sample_enable_xpn_resource(): 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.api_core.extended_operation.ExtendedOperation: @@ -1460,7 +1511,7 @@ def enable_xpn_resource( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be @@ -1510,8 +1561,10 @@ def sample_enable_xpn_resource(): 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.api_core.extended_operation.ExtendedOperation: @@ -1599,7 +1652,7 @@ def get( project: 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]]] = (), ) -> compute.Project: r"""Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information @@ -1649,8 +1702,10 @@ def sample_get(): 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.compute_v1.types.Project: @@ -1711,7 +1766,7 @@ def get_xpn_host( project: 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]]] = (), ) -> compute.Project: r"""Gets the shared VPC host project that this project links to. May be empty if no link exists. @@ -1755,8 +1810,10 @@ def sample_get_xpn_host(): 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.compute_v1.types.Project: @@ -1817,7 +1874,7 @@ def get_xpn_resources( project: 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.GetXpnResourcesPager: r"""Gets service resources (a.k.a service project) associated with this host project. @@ -1862,8 +1919,10 @@ def sample_get_xpn_resources(): 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.compute_v1.services.projects.pagers.GetXpnResourcesPager: @@ -1936,7 +1995,7 @@ def list_xpn_hosts( ] = 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.ListXpnHostsPager: r"""Lists all shared VPC host projects visible to the user in an organization. @@ -1986,8 +2045,10 @@ def sample_list_xpn_hosts(): 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.compute_v1.services.projects.pagers.ListXpnHostsPager: @@ -2062,7 +2123,7 @@ def move_disk_unary( disk_move_request_resource: Optional[compute.DiskMoveRequest] = 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]]] = (), ) -> compute.Operation: r"""Moves a persistent disk from one zone to another. @@ -2110,8 +2171,10 @@ def sample_move_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -2172,7 +2235,7 @@ def move_disk( disk_move_request_resource: Optional[compute.DiskMoveRequest] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Moves a persistent disk from one zone to another. @@ -2220,8 +2283,10 @@ def sample_move_disk(): 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.api_core.extended_operation.ExtendedOperation: @@ -2306,7 +2371,7 @@ def move_instance_unary( instance_move_request_resource: Optional[compute.InstanceMoveRequest] = 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]]] = (), ) -> compute.Operation: r"""Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this @@ -2362,8 +2427,10 @@ def sample_move_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -2424,7 +2491,7 @@ def move_instance( instance_move_request_resource: Optional[compute.InstanceMoveRequest] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this @@ -2480,8 +2547,10 @@ def sample_move_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -2568,7 +2637,7 @@ def set_cloud_armor_tier_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Cloud Armor tier of the project. To set ENTERPRISE or above the billing account of the project @@ -2620,8 +2689,10 @@ def sample_set_cloud_armor_tier(): 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.api_core.extended_operation.ExtendedOperation: @@ -2688,7 +2759,7 @@ def set_cloud_armor_tier( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Cloud Armor tier of the project. To set ENTERPRISE or above the billing account of the project @@ -2740,8 +2811,10 @@ def sample_set_cloud_armor_tier(): 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.api_core.extended_operation.ExtendedOperation: @@ -2832,7 +2905,7 @@ def set_common_instance_metadata_unary( metadata_resource: Optional[compute.Metadata] = 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]]] = (), ) -> compute.Operation: r"""Sets metadata common to all instances within the specified project using the data included in the @@ -2882,8 +2955,10 @@ def sample_set_common_instance_metadata(): 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.api_core.extended_operation.ExtendedOperation: @@ -2948,7 +3023,7 @@ def set_common_instance_metadata( metadata_resource: Optional[compute.Metadata] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets metadata common to all instances within the specified project using the data included in the @@ -2998,8 +3073,10 @@ def sample_set_common_instance_metadata(): 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.api_core.extended_operation.ExtendedOperation: @@ -3090,7 +3167,7 @@ def set_default_network_tier_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the default network tier of the project. The default network tier is used when an @@ -3141,8 +3218,10 @@ def sample_set_default_network_tier(): 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.api_core.extended_operation.ExtendedOperation: @@ -3211,7 +3290,7 @@ def set_default_network_tier( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the default network tier of the project. The default network tier is used when an @@ -3262,8 +3341,10 @@ def sample_set_default_network_tier(): 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.api_core.extended_operation.ExtendedOperation: @@ -3354,7 +3435,7 @@ def set_usage_export_bucket_unary( usage_export_location_resource: Optional[compute.UsageExportLocation] = 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]]] = (), ) -> compute.Operation: r"""Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide @@ -3405,8 +3486,10 @@ def sample_set_usage_export_bucket(): 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.api_core.extended_operation.ExtendedOperation: @@ -3469,7 +3552,7 @@ def set_usage_export_bucket( usage_export_location_resource: Optional[compute.UsageExportLocation] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide @@ -3520,8 +3603,10 @@ def sample_set_usage_export_bucket(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/pagers.py index 29a8adec7077..3d42eaccbb6d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/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 = compute.GetXpnResourcesProjectsRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListXpnHostsProjectsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/transports/rest.py index bf0cd1ff4a14..fb2d094618c1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/projects/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 @@ -37,6 +37,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, @@ -181,8 +189,10 @@ def post_set_usage_export_bucket(self, response): def pre_disable_xpn_host( self, request: compute.DisableXpnHostProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DisableXpnHostProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DisableXpnHostProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_xpn_host Override in a subclass to manipulate the request or metadata @@ -202,8 +212,11 @@ def post_disable_xpn_host(self, response: compute.Operation) -> compute.Operatio def pre_disable_xpn_resource( self, request: compute.DisableXpnResourceProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DisableXpnResourceProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DisableXpnResourceProjectRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for disable_xpn_resource Override in a subclass to manipulate the request or metadata @@ -225,8 +238,10 @@ def post_disable_xpn_resource( def pre_enable_xpn_host( self, request: compute.EnableXpnHostProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.EnableXpnHostProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.EnableXpnHostProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_xpn_host Override in a subclass to manipulate the request or metadata @@ -246,8 +261,10 @@ def post_enable_xpn_host(self, response: compute.Operation) -> compute.Operation def pre_enable_xpn_resource( self, request: compute.EnableXpnResourceProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.EnableXpnResourceProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.EnableXpnResourceProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_xpn_resource Override in a subclass to manipulate the request or metadata @@ -267,8 +284,10 @@ def post_enable_xpn_resource( return response def pre_get( - self, request: compute.GetProjectRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetProjectRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetProjectRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -288,8 +307,10 @@ def post_get(self, response: compute.Project) -> compute.Project: def pre_get_xpn_host( self, request: compute.GetXpnHostProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetXpnHostProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetXpnHostProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_xpn_host Override in a subclass to manipulate the request or metadata @@ -309,8 +330,10 @@ def post_get_xpn_host(self, response: compute.Project) -> compute.Project: def pre_get_xpn_resources( self, request: compute.GetXpnResourcesProjectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetXpnResourcesProjectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetXpnResourcesProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_xpn_resources Override in a subclass to manipulate the request or metadata @@ -332,8 +355,10 @@ def post_get_xpn_resources( def pre_list_xpn_hosts( self, request: compute.ListXpnHostsProjectsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListXpnHostsProjectsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListXpnHostsProjectsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_xpn_hosts Override in a subclass to manipulate the request or metadata @@ -353,8 +378,8 @@ def post_list_xpn_hosts(self, response: compute.XpnHostList) -> compute.XpnHostL def pre_move_disk( self, request: compute.MoveDiskProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.MoveDiskProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.MoveDiskProjectRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for move_disk Override in a subclass to manipulate the request or metadata @@ -374,8 +399,10 @@ def post_move_disk(self, response: compute.Operation) -> compute.Operation: def pre_move_instance( self, request: compute.MoveInstanceProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.MoveInstanceProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.MoveInstanceProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for move_instance Override in a subclass to manipulate the request or metadata @@ -395,8 +422,10 @@ def post_move_instance(self, response: compute.Operation) -> compute.Operation: def pre_set_cloud_armor_tier( self, request: compute.SetCloudArmorTierProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetCloudArmorTierProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetCloudArmorTierProjectRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_cloud_armor_tier Override in a subclass to manipulate the request or metadata @@ -418,9 +447,10 @@ def post_set_cloud_armor_tier( def pre_set_common_instance_metadata( self, request: compute.SetCommonInstanceMetadataProjectRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetCommonInstanceMetadataProjectRequest, Sequence[Tuple[str, str]] + compute.SetCommonInstanceMetadataProjectRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_common_instance_metadata @@ -443,8 +473,11 @@ def post_set_common_instance_metadata( def pre_set_default_network_tier( self, request: compute.SetDefaultNetworkTierProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetDefaultNetworkTierProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetDefaultNetworkTierProjectRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_default_network_tier Override in a subclass to manipulate the request or metadata @@ -466,8 +499,11 @@ def post_set_default_network_tier( def pre_set_usage_export_bucket( self, request: compute.SetUsageExportBucketProjectRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetUsageExportBucketProjectRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetUsageExportBucketProjectRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_usage_export_bucket Override in a subclass to manipulate the request or metadata @@ -611,7 +647,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]]] = (), ) -> compute.Operation: r"""Call the disable xpn host method over HTTP. @@ -623,8 +659,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: ~.compute.Operation: @@ -651,6 +689,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseDisableXpnHost._get_http_options() ) + request, metadata = self._interceptor.pre_disable_xpn_host( request, metadata ) @@ -667,6 +706,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.compute_v1.ProjectsClient.DisableXpnHost", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "DisableXpnHost", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._DisableXpnHost._get_response( self._host, @@ -687,7 +753,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_xpn_host(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.disable_xpn_host", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "DisableXpnHost", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableXpnResource( @@ -725,7 +813,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]]] = (), ) -> compute.Operation: r"""Call the disable xpn resource method over HTTP. @@ -737,8 +825,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: ~.compute.Operation: @@ -765,6 +855,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseDisableXpnResource._get_http_options() ) + request, metadata = self._interceptor.pre_disable_xpn_resource( request, metadata ) @@ -781,6 +872,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 = 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.compute_v1.ProjectsClient.DisableXpnResource", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "DisableXpnResource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._DisableXpnResource._get_response( self._host, @@ -802,7 +920,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_xpn_resource(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.disable_xpn_resource", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "DisableXpnResource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableXpnHost( @@ -839,7 +979,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]]] = (), ) -> compute.Operation: r"""Call the enable xpn host method over HTTP. @@ -851,8 +991,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: ~.compute.Operation: @@ -879,6 +1021,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseEnableXpnHost._get_http_options() ) + request, metadata = self._interceptor.pre_enable_xpn_host(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseEnableXpnHost._get_transcoded_request( @@ -893,6 +1036,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.compute_v1.ProjectsClient.EnableXpnHost", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "EnableXpnHost", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._EnableXpnHost._get_response( self._host, @@ -913,7 +1083,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_xpn_host(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.enable_xpn_host", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "EnableXpnHost", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableXpnResource( @@ -951,7 +1143,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]]] = (), ) -> compute.Operation: r"""Call the enable xpn resource method over HTTP. @@ -963,8 +1155,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: ~.compute.Operation: @@ -991,6 +1185,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseEnableXpnResource._get_http_options() ) + request, metadata = self._interceptor.pre_enable_xpn_resource( request, metadata ) @@ -1007,6 +1202,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 = 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.compute_v1.ProjectsClient.EnableXpnResource", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "EnableXpnResource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._EnableXpnResource._get_response( self._host, @@ -1028,7 +1250,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_xpn_resource(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.enable_xpn_resource", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "EnableXpnResource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseProjectsRestTransport._BaseGet, ProjectsRestStub): @@ -1063,7 +1307,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]]] = (), ) -> compute.Project: r"""Call the get method over HTTP. @@ -1074,8 +1318,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: ~.compute.Project: @@ -1088,6 +1334,7 @@ def __call__( """ http_options = _BaseProjectsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseGet._get_transcoded_request( @@ -1100,6 +1347,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 = 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.compute_v1.ProjectsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._Get._get_response( self._host, @@ -1120,7 +1394,29 @@ def __call__( pb_resp = compute.Project.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Project.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.compute_v1.ProjectsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetXpnHost(_BaseProjectsRestTransport._BaseGetXpnHost, ProjectsRestStub): @@ -1155,7 +1451,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]]] = (), ) -> compute.Project: r"""Call the get xpn host method over HTTP. @@ -1167,8 +1463,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: ~.compute.Project: @@ -1183,6 +1481,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseGetXpnHost._get_http_options() ) + request, metadata = self._interceptor.pre_get_xpn_host(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseGetXpnHost._get_transcoded_request( @@ -1197,6 +1496,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.compute_v1.ProjectsClient.GetXpnHost", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "GetXpnHost", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._GetXpnHost._get_response( self._host, @@ -1217,7 +1543,29 @@ def __call__( pb_resp = compute.Project.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_xpn_host(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Project.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.compute_v1.ProjectsClient.get_xpn_host", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "GetXpnHost", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetXpnResources( @@ -1254,7 +1602,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]]] = (), ) -> compute.ProjectsGetXpnResources: r"""Call the get xpn resources method over HTTP. @@ -1266,8 +1614,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: ~.compute.ProjectsGetXpnResources: @@ -1277,6 +1627,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseGetXpnResources._get_http_options() ) + request, metadata = self._interceptor.pre_get_xpn_resources( request, metadata ) @@ -1293,6 +1644,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.compute_v1.ProjectsClient.GetXpnResources", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "GetXpnResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._GetXpnResources._get_response( self._host, @@ -1313,7 +1691,29 @@ def __call__( pb_resp = compute.ProjectsGetXpnResources.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_xpn_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ProjectsGetXpnResources.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.compute_v1.ProjectsClient.get_xpn_resources", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "GetXpnResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListXpnHosts(_BaseProjectsRestTransport._BaseListXpnHosts, ProjectsRestStub): @@ -1349,7 +1749,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]]] = (), ) -> compute.XpnHostList: r"""Call the list xpn hosts method over HTTP. @@ -1361,8 +1761,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: ~.compute.XpnHostList: @@ -1372,6 +1774,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseListXpnHosts._get_http_options() ) + request, metadata = self._interceptor.pre_list_xpn_hosts(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseListXpnHosts._get_transcoded_request( @@ -1390,6 +1793,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.compute_v1.ProjectsClient.ListXpnHosts", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "ListXpnHosts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._ListXpnHosts._get_response( self._host, @@ -1411,7 +1841,29 @@ def __call__( pb_resp = compute.XpnHostList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_xpn_hosts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.XpnHostList.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.compute_v1.ProjectsClient.list_xpn_hosts", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "ListXpnHosts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveDisk(_BaseProjectsRestTransport._BaseMoveDisk, ProjectsRestStub): @@ -1447,7 +1899,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]]] = (), ) -> compute.Operation: r"""Call the move disk method over HTTP. @@ -1459,8 +1911,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: ~.compute.Operation: @@ -1485,6 +1939,7 @@ def __call__( """ http_options = _BaseProjectsRestTransport._BaseMoveDisk._get_http_options() + request, metadata = self._interceptor.pre_move_disk(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseMoveDisk._get_transcoded_request( @@ -1503,6 +1958,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.compute_v1.ProjectsClient.MoveDisk", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "MoveDisk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._MoveDisk._get_response( self._host, @@ -1524,7 +2006,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_disk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.move_disk", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "MoveDisk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveInstance(_BaseProjectsRestTransport._BaseMoveInstance, ProjectsRestStub): @@ -1560,7 +2064,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]]] = (), ) -> compute.Operation: r"""Call the move instance method over HTTP. @@ -1572,8 +2076,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: ~.compute.Operation: @@ -1600,6 +2106,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseMoveInstance._get_http_options() ) + request, metadata = self._interceptor.pre_move_instance(request, metadata) transcoded_request = ( _BaseProjectsRestTransport._BaseMoveInstance._get_transcoded_request( @@ -1618,6 +2125,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.compute_v1.ProjectsClient.MoveInstance", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "MoveInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._MoveInstance._get_response( self._host, @@ -1639,7 +2173,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.move_instance", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "MoveInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetCloudArmorTier( @@ -1677,7 +2233,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]]] = (), ) -> compute.Operation: r"""Call the set cloud armor tier method over HTTP. @@ -1689,8 +2245,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: ~.compute.Operation: @@ -1717,6 +2275,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSetCloudArmorTier._get_http_options() ) + request, metadata = self._interceptor.pre_set_cloud_armor_tier( request, metadata ) @@ -1733,6 +2292,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 = 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.compute_v1.ProjectsClient.SetCloudArmorTier", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetCloudArmorTier", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SetCloudArmorTier._get_response( self._host, @@ -1754,7 +2340,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_cloud_armor_tier(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.set_cloud_armor_tier", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetCloudArmorTier", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetCommonInstanceMetadata( @@ -1792,7 +2400,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]]] = (), ) -> compute.Operation: r"""Call the set common instance metadata method over HTTP. @@ -1805,8 +2413,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: ~.compute.Operation: @@ -1833,6 +2443,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSetCommonInstanceMetadata._get_http_options() ) + request, metadata = self._interceptor.pre_set_common_instance_metadata( request, metadata ) @@ -1849,6 +2460,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 = 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.compute_v1.ProjectsClient.SetCommonInstanceMetadata", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetCommonInstanceMetadata", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SetCommonInstanceMetadata._get_response( self._host, @@ -1870,7 +2508,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_common_instance_metadata(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.set_common_instance_metadata", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetCommonInstanceMetadata", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetDefaultNetworkTier( @@ -1908,7 +2568,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]]] = (), ) -> compute.Operation: r"""Call the set default network tier method over HTTP. @@ -1920,8 +2580,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: ~.compute.Operation: @@ -1948,6 +2610,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSetDefaultNetworkTier._get_http_options() ) + request, metadata = self._interceptor.pre_set_default_network_tier( request, metadata ) @@ -1964,6 +2627,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 = 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.compute_v1.ProjectsClient.SetDefaultNetworkTier", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetDefaultNetworkTier", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SetDefaultNetworkTier._get_response( self._host, @@ -1985,7 +2675,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_default_network_tier(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.set_default_network_tier", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetDefaultNetworkTier", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUsageExportBucket( @@ -2023,7 +2735,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]]] = (), ) -> compute.Operation: r"""Call the set usage export bucket method over HTTP. @@ -2035,8 +2747,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: ~.compute.Operation: @@ -2063,6 +2777,7 @@ def __call__( http_options = ( _BaseProjectsRestTransport._BaseSetUsageExportBucket._get_http_options() ) + request, metadata = self._interceptor.pre_set_usage_export_bucket( request, metadata ) @@ -2079,6 +2794,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 = 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.compute_v1.ProjectsClient.SetUsageExportBucket", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetUsageExportBucket", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProjectsRestTransport._SetUsageExportBucket._get_response( self._host, @@ -2100,7 +2842,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_usage_export_bucket(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ProjectsClient.set_usage_export_bucket", + extra={ + "serviceName": "google.cloud.compute.v1.Projects", + "rpcName": "SetUsageExportBucket", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/client.py index d48e695443a8..e9ee9d2de359 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.public_advertised_prefixes import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.PublicAdvertisedPrefixesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "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.compute.v1.PublicAdvertisedPrefixes", + "credentialsType": None, + }, + ) + def announce_unary( self, request: Optional[ @@ -642,7 +679,7 @@ def announce_unary( public_advertised_prefix: 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]]] = (), ) -> compute.Operation: r"""Announces the specified PublicAdvertisedPrefix @@ -693,8 +730,10 @@ def sample_announce(): 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.api_core.extended_operation.ExtendedOperation: @@ -762,7 +801,7 @@ def announce( public_advertised_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Announces the specified PublicAdvertisedPrefix @@ -813,8 +852,10 @@ def sample_announce(): 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.api_core.extended_operation.ExtendedOperation: @@ -906,7 +947,7 @@ def delete_unary( public_advertised_prefix: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified PublicAdvertisedPrefix @@ -957,8 +998,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1026,7 +1069,7 @@ def delete( public_advertised_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified PublicAdvertisedPrefix @@ -1077,8 +1120,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1170,7 +1215,7 @@ def get( public_advertised_prefix: 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]]] = (), ) -> compute.PublicAdvertisedPrefix: r"""Returns the specified PublicAdvertisedPrefix resource. @@ -1222,8 +1267,10 @@ def sample_get(): 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.compute_v1.types.PublicAdvertisedPrefix: @@ -1297,7 +1344,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the @@ -1347,8 +1394,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1415,7 +1464,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the @@ -1465,8 +1514,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1554,7 +1605,7 @@ def list( project: 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.ListPager: r"""Lists the PublicAdvertisedPrefixes for a project. @@ -1598,8 +1649,10 @@ def sample_list(): 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.compute_v1.services.public_advertised_prefixes.pagers.ListPager: @@ -1675,7 +1728,7 @@ def patch_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified Router resource with the data included in the request. This method supports PATCH @@ -1734,8 +1787,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1812,7 +1867,7 @@ def patch( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified Router resource with the data included in the request. This method supports PATCH @@ -1871,8 +1926,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1970,7 +2027,7 @@ def withdraw_unary( public_advertised_prefix: 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]]] = (), ) -> compute.Operation: r"""Withdraws the specified PublicAdvertisedPrefix @@ -2021,8 +2078,10 @@ def sample_withdraw(): 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.api_core.extended_operation.ExtendedOperation: @@ -2090,7 +2149,7 @@ def withdraw( public_advertised_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Withdraws the specified PublicAdvertisedPrefix @@ -2141,8 +2200,10 @@ def sample_withdraw(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/pagers.py index b04fe73bfcb0..435ffb6988c4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/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 = compute.ListPublicAdvertisedPrefixesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/transports/rest.py index d9340d226150..e056f1431a12 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_advertised_prefixes/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 @@ -37,6 +37,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, @@ -125,9 +133,10 @@ def post_withdraw(self, response): def pre_announce( self, request: compute.AnnouncePublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AnnouncePublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]] + compute.AnnouncePublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for announce @@ -148,8 +157,11 @@ def post_announce(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeletePublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeletePublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeletePublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -169,8 +181,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetPublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetPublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetPublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -192,8 +207,11 @@ def post_get( def pre_insert( self, request: compute.InsertPublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertPublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertPublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -213,8 +231,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListPublicAdvertisedPrefixesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListPublicAdvertisedPrefixesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListPublicAdvertisedPrefixesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -236,8 +257,11 @@ def post_list( def pre_patch( self, request: compute.PatchPublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchPublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchPublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -257,9 +281,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_withdraw( self, request: compute.WithdrawPublicAdvertisedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.WithdrawPublicAdvertisedPrefixeRequest, Sequence[Tuple[str, str]] + compute.WithdrawPublicAdvertisedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for withdraw @@ -403,7 +428,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]]] = (), ) -> compute.Operation: r"""Call the announce method over HTTP. @@ -415,8 +440,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: ~.compute.Operation: @@ -443,6 +470,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseAnnounce._get_http_options() ) + request, metadata = self._interceptor.pre_announce(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseAnnounce._get_transcoded_request( http_options, request @@ -453,6 +481,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Announce", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Announce", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Announce._get_response( self._host, @@ -473,7 +528,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_announce(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicAdvertisedPrefixesClient.announce", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Announce", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -511,7 +588,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -523,8 +600,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: ~.compute.Operation: @@ -551,6 +630,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -561,6 +641,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Delete._get_response( self._host, @@ -581,7 +688,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicAdvertisedPrefixesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -619,7 +748,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]]] = (), ) -> compute.PublicAdvertisedPrefix: r"""Call the get method over HTTP. @@ -631,8 +760,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: ~.compute.PublicAdvertisedPrefix: @@ -648,6 +779,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -658,6 +790,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Get._get_response( self._host, @@ -678,7 +837,29 @@ def __call__( pb_resp = compute.PublicAdvertisedPrefix.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicAdvertisedPrefix.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.compute_v1.PublicAdvertisedPrefixesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -717,7 +898,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -729,8 +910,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: ~.compute.Operation: @@ -757,6 +940,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -771,6 +955,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Insert._get_response( self._host, @@ -792,7 +1003,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicAdvertisedPrefixesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -830,7 +1063,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]]] = (), ) -> compute.PublicAdvertisedPrefixList: r"""Call the list method over HTTP. @@ -842,8 +1075,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: ~.compute.PublicAdvertisedPrefixList: @@ -853,6 +1088,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -863,6 +1099,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._List._get_response( self._host, @@ -883,7 +1146,31 @@ def __call__( pb_resp = compute.PublicAdvertisedPrefixList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicAdvertisedPrefixList.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.compute_v1.PublicAdvertisedPrefixesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -922,7 +1209,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -934,8 +1221,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: ~.compute.Operation: @@ -962,6 +1251,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -976,6 +1266,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Patch._get_response( self._host, @@ -997,7 +1314,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicAdvertisedPrefixesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Withdraw( @@ -1035,7 +1374,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]]] = (), ) -> compute.Operation: r"""Call the withdraw method over HTTP. @@ -1047,8 +1386,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: ~.compute.Operation: @@ -1075,6 +1416,7 @@ def __call__( http_options = ( _BasePublicAdvertisedPrefixesRestTransport._BaseWithdraw._get_http_options() ) + request, metadata = self._interceptor.pre_withdraw(request, metadata) transcoded_request = _BasePublicAdvertisedPrefixesRestTransport._BaseWithdraw._get_transcoded_request( http_options, request @@ -1085,6 +1427,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 = 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.compute_v1.PublicAdvertisedPrefixesClient.Withdraw", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Withdraw", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicAdvertisedPrefixesRestTransport._Withdraw._get_response( self._host, @@ -1105,7 +1474,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_withdraw(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicAdvertisedPrefixesClient.withdraw", + extra={ + "serviceName": "google.cloud.compute.v1.PublicAdvertisedPrefixes", + "rpcName": "Withdraw", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/client.py index 74e71da43c37..1a5913c2719c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.public_delegated_prefixes import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.PublicDelegatedPrefixesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "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.compute.v1.PublicDelegatedPrefixes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -641,7 +678,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes. To prevent failure, Google recommends @@ -689,8 +726,10 @@ def sample_aggregated_list(): 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.compute_v1.services.public_delegated_prefixes.pagers.AggregatedListPager: @@ -766,7 +805,7 @@ def announce_unary( public_delegated_prefix: 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]]] = (), ) -> compute.Operation: r"""Announces the specified PublicDelegatedPrefix in the given region. @@ -827,8 +866,10 @@ def sample_announce(): 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.api_core.extended_operation.ExtendedOperation: @@ -900,7 +941,7 @@ def announce( public_delegated_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Announces the specified PublicDelegatedPrefix in the given region. @@ -961,8 +1002,10 @@ def sample_announce(): 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.api_core.extended_operation.ExtendedOperation: @@ -1059,7 +1102,7 @@ def delete_unary( public_delegated_prefix: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified PublicDelegatedPrefix in the given region. @@ -1117,8 +1160,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1190,7 +1235,7 @@ def delete( public_delegated_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified PublicDelegatedPrefix in the given region. @@ -1248,8 +1293,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1344,7 +1391,7 @@ def get( public_delegated_prefix: 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]]] = (), ) -> compute.PublicDelegatedPrefix: r"""Returns the specified PublicDelegatedPrefix resource in the given region. @@ -1402,8 +1449,10 @@ def sample_get(): 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.compute_v1.types.PublicDelegatedPrefix: @@ -1484,7 +1533,7 @@ def insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that @@ -1540,8 +1589,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1616,7 +1667,7 @@ def insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that @@ -1672,8 +1723,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1770,7 +1823,7 @@ def list( region: 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.ListPager: r"""Lists the PublicDelegatedPrefixes for a project in the given region. @@ -1821,8 +1874,10 @@ def sample_list(): 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.compute_v1.services.public_delegated_prefixes.pagers.ListPager: @@ -1906,7 +1961,7 @@ def patch_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method @@ -1971,8 +2026,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2053,7 +2110,7 @@ def patch( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method @@ -2118,8 +2175,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2222,7 +2281,7 @@ def withdraw_unary( public_delegated_prefix: 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]]] = (), ) -> compute.Operation: r"""Withdraws the specified PublicDelegatedPrefix in the given region. @@ -2283,8 +2342,10 @@ def sample_withdraw(): 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.api_core.extended_operation.ExtendedOperation: @@ -2356,7 +2417,7 @@ def withdraw( public_delegated_prefix: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Withdraws the specified PublicDelegatedPrefix in the given region. @@ -2417,8 +2478,10 @@ def sample_withdraw(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/pagers.py index 89b7cede0b8d..d06a454434e2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/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 = compute.AggregatedListPublicDelegatedPrefixesRequest(request) @@ -146,7 +148,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. @@ -160,8 +162,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 = compute.ListPublicDelegatedPrefixesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/transports/rest.py index b262a4269a40..03d6adfe820d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/public_delegated_prefixes/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 @@ -37,6 +37,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, @@ -133,9 +141,10 @@ def post_withdraw(self, response): def pre_aggregated_list( self, request: compute.AggregatedListPublicDelegatedPrefixesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListPublicDelegatedPrefixesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListPublicDelegatedPrefixesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -158,9 +167,10 @@ def post_aggregated_list( def pre_announce( self, request: compute.AnnouncePublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AnnouncePublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.AnnouncePublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for announce @@ -181,8 +191,11 @@ def post_announce(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeletePublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeletePublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeletePublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -202,8 +215,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -225,8 +241,11 @@ def post_get( def pre_insert( self, request: compute.InsertPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -246,8 +265,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListPublicDelegatedPrefixesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListPublicDelegatedPrefixesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListPublicDelegatedPrefixesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -269,8 +291,11 @@ def post_list( def pre_patch( self, request: compute.PatchPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -290,9 +315,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_withdraw( self, request: compute.WithdrawPublicDelegatedPrefixeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.WithdrawPublicDelegatedPrefixeRequest, Sequence[Tuple[str, str]] + compute.WithdrawPublicDelegatedPrefixeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for withdraw @@ -436,7 +462,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]]] = (), ) -> compute.PublicDelegatedPrefixAggregatedList: r"""Call the aggregated list method over HTTP. @@ -448,8 +474,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: ~.compute.PublicDelegatedPrefixAggregatedList: @@ -459,6 +487,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -469,6 +498,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 = 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.compute_v1.PublicDelegatedPrefixesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( PublicDelegatedPrefixesRestTransport._AggregatedList._get_response( @@ -491,7 +547,31 @@ def __call__( pb_resp = compute.PublicDelegatedPrefixAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.PublicDelegatedPrefixAggregatedList.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.compute_v1.PublicDelegatedPrefixesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Announce( @@ -529,7 +609,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]]] = (), ) -> compute.Operation: r"""Call the announce method over HTTP. @@ -541,8 +621,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: ~.compute.Operation: @@ -569,6 +651,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseAnnounce._get_http_options() ) + request, metadata = self._interceptor.pre_announce(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseAnnounce._get_transcoded_request( http_options, request @@ -579,6 +662,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Announce", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Announce", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Announce._get_response( self._host, @@ -599,7 +709,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_announce(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicDelegatedPrefixesClient.announce", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Announce", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -637,7 +769,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -649,8 +781,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: ~.compute.Operation: @@ -677,6 +811,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -687,6 +822,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Delete._get_response( self._host, @@ -707,7 +869,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicDelegatedPrefixesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -745,7 +929,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]]] = (), ) -> compute.PublicDelegatedPrefix: r"""Call the get method over HTTP. @@ -757,8 +941,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: ~.compute.PublicDelegatedPrefix: @@ -777,6 +963,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -787,6 +974,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Get._get_response( self._host, @@ -807,7 +1021,29 @@ def __call__( pb_resp = compute.PublicDelegatedPrefix.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicDelegatedPrefix.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.compute_v1.PublicDelegatedPrefixesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -846,7 +1082,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -858,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: ~.compute.Operation: @@ -886,6 +1124,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -900,6 +1139,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Insert._get_response( self._host, @@ -921,7 +1187,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicDelegatedPrefixesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -959,7 +1247,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]]] = (), ) -> compute.PublicDelegatedPrefixList: r"""Call the list method over HTTP. @@ -971,8 +1259,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: ~.compute.PublicDelegatedPrefixList: @@ -982,6 +1272,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -992,6 +1283,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 = 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.compute_v1.PublicDelegatedPrefixesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._List._get_response( self._host, @@ -1012,7 +1330,31 @@ def __call__( pb_resp = compute.PublicDelegatedPrefixList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.PublicDelegatedPrefixList.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.compute_v1.PublicDelegatedPrefixesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1051,7 +1393,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1063,8 +1405,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: ~.compute.Operation: @@ -1091,6 +1435,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -1105,6 +1450,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Patch._get_response( self._host, @@ -1126,7 +1498,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicDelegatedPrefixesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Withdraw( @@ -1164,7 +1558,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]]] = (), ) -> compute.Operation: r"""Call the withdraw method over HTTP. @@ -1176,8 +1570,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: ~.compute.Operation: @@ -1204,6 +1600,7 @@ def __call__( http_options = ( _BasePublicDelegatedPrefixesRestTransport._BaseWithdraw._get_http_options() ) + request, metadata = self._interceptor.pre_withdraw(request, metadata) transcoded_request = _BasePublicDelegatedPrefixesRestTransport._BaseWithdraw._get_transcoded_request( http_options, request @@ -1214,6 +1611,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 = 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.compute_v1.PublicDelegatedPrefixesClient.Withdraw", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Withdraw", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PublicDelegatedPrefixesRestTransport._Withdraw._get_response( self._host, @@ -1234,7 +1658,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_withdraw(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.PublicDelegatedPrefixesClient.withdraw", + extra={ + "serviceName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "rpcName": "Withdraw", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/client.py index 0ce4a252df1c..cb07e86ba4b4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_autoscalers import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.RegionAutoscalersClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "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.compute.v1.RegionAutoscalers", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteRegionAutoscalerRequest, dict]] = None, @@ -637,7 +674,7 @@ def delete_unary( autoscaler: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified autoscaler. @@ -694,8 +731,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -765,7 +804,7 @@ def delete( autoscaler: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified autoscaler. @@ -822,8 +861,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -918,7 +959,7 @@ def get( autoscaler: 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]]] = (), ) -> compute.Autoscaler: r"""Returns the specified autoscaler. @@ -975,8 +1016,10 @@ def sample_get(): 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.compute_v1.types.Autoscaler: @@ -1055,7 +1098,7 @@ def insert_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Creates an autoscaler in the specified project using the data included in the request. @@ -1112,8 +1155,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1182,7 +1227,7 @@ def insert( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an autoscaler in the specified project using the data included in the request. @@ -1239,8 +1284,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1333,7 +1380,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of autoscalers contained within the specified region. @@ -1386,8 +1433,10 @@ def sample_list(): 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.compute_v1.services.region_autoscalers.pagers.ListPager: @@ -1468,7 +1517,7 @@ def patch_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Updates an autoscaler in the specified project using the data included in the request. This method supports @@ -1527,8 +1576,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1597,7 +1648,7 @@ def patch( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an autoscaler in the specified project using the data included in the request. This method supports @@ -1656,8 +1707,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1751,7 +1804,7 @@ def update_unary( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> compute.Operation: r"""Updates an autoscaler in the specified project using the data included in the request. @@ -1808,8 +1861,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1878,7 +1933,7 @@ def update( autoscaler_resource: Optional[compute.Autoscaler] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates an autoscaler in the specified project using the data included in the request. @@ -1935,8 +1990,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/pagers.py index ef9d600b1024..0e48d91ca117 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/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 = compute.ListRegionAutoscalersRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/transports/rest.py index d6d39111f6a3..f385074fb135 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_autoscalers/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_update(self, response): def pre_delete( self, request: compute.DeleteRegionAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -138,8 +148,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -159,8 +171,10 @@ def post_get(self, response: compute.Autoscaler) -> compute.Autoscaler: def pre_insert( self, request: compute.InsertRegionAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -180,8 +194,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionAutoscalersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionAutoscalersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionAutoscalersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -203,8 +219,10 @@ def post_list( def pre_patch( self, request: compute.PatchRegionAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -224,8 +242,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateRegionAutoscalerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionAutoscalerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionAutoscalerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -367,7 +387,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -379,8 +399,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: ~.compute.Operation: @@ -407,6 +429,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BaseDelete._get_transcoded_request( @@ -421,6 +444,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.compute_v1.RegionAutoscalersClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._Delete._get_response( self._host, @@ -441,7 +491,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionAutoscalersClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionAutoscalersRestTransport._BaseGet, RegionAutoscalersRestStub): @@ -476,7 +548,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]]] = (), ) -> compute.Autoscaler: r"""Call the get method over HTTP. @@ -488,8 +560,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: ~.compute.Autoscaler: @@ -511,6 +585,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BaseGet._get_transcoded_request( @@ -525,6 +600,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.compute_v1.RegionAutoscalersClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._Get._get_response( self._host, @@ -545,7 +647,29 @@ def __call__( pb_resp = compute.Autoscaler.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Autoscaler.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.compute_v1.RegionAutoscalersClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -583,7 +707,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -595,8 +719,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: ~.compute.Operation: @@ -623,6 +749,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BaseInsert._get_transcoded_request( @@ -643,6 +770,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.compute_v1.RegionAutoscalersClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._Insert._get_response( self._host, @@ -664,7 +818,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionAutoscalersClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -701,7 +877,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]]] = (), ) -> compute.RegionAutoscalerList: r"""Call the list method over HTTP. @@ -713,8 +889,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: ~.compute.RegionAutoscalerList: @@ -724,6 +902,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BaseList._get_transcoded_request( @@ -738,6 +917,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.compute_v1.RegionAutoscalersClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._List._get_response( self._host, @@ -758,7 +964,29 @@ def __call__( pb_resp = compute.RegionAutoscalerList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionAutoscalerList.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.compute_v1.RegionAutoscalersClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -796,7 +1024,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -808,8 +1036,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: ~.compute.Operation: @@ -836,6 +1066,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BasePatch._get_transcoded_request( @@ -856,6 +1087,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.compute_v1.RegionAutoscalersClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._Patch._get_response( self._host, @@ -877,7 +1135,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionAutoscalersClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update( @@ -915,7 +1195,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -927,8 +1207,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: ~.compute.Operation: @@ -955,6 +1237,7 @@ def __call__( http_options = ( _BaseRegionAutoscalersRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseRegionAutoscalersRestTransport._BaseUpdate._get_transcoded_request( @@ -975,6 +1258,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.compute_v1.RegionAutoscalersClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionAutoscalersRestTransport._Update._get_response( self._host, @@ -996,7 +1306,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionAutoscalersClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionAutoscalers", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/client.py index 05b1361aced9..8df5d123fc61 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_backend_services import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.RegionBackendServicesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "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.compute.v1.RegionBackendServices", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -641,7 +678,7 @@ def delete_unary( backend_service: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified regional BackendService resource. @@ -701,8 +738,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -774,7 +813,7 @@ def delete( backend_service: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified regional BackendService resource. @@ -834,8 +873,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -930,7 +971,7 @@ def get( backend_service: 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]]] = (), ) -> compute.BackendService: r"""Returns the specified regional BackendService resource. @@ -990,8 +1031,10 @@ def sample_get(): 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.compute_v1.types.BackendService: @@ -1079,7 +1122,7 @@ def get_health( ] = 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]]] = (), ) -> compute.BackendServiceGroupHealth: r"""Gets the most recent health check results for this regional BackendService. @@ -1144,8 +1187,10 @@ def sample_get_health(): 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.compute_v1.types.BackendServiceGroupHealth: @@ -1221,7 +1266,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1281,8 +1326,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.cloud.compute_v1.types.Policy: @@ -1374,7 +1421,7 @@ def insert_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Creates a regional BackendService resource in the specified project using the data included in the @@ -1433,8 +1480,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1505,7 +1554,7 @@ def insert( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a regional BackendService resource in the specified project using the data included in the @@ -1564,8 +1613,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1658,7 +1709,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of regional BackendService resources available to the specified project in the @@ -1712,8 +1763,10 @@ def sample_list(): 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.compute_v1.services.region_backend_services.pagers.ListPager: @@ -1795,7 +1848,7 @@ def list_usable( region: 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.ListUsablePager: r"""Retrieves a list of all usable backend services in the specified project in the given region. @@ -1849,8 +1902,10 @@ def sample_list_usable(): 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.compute_v1.services.region_backend_services.pagers.ListUsablePager: @@ -1932,7 +1987,7 @@ def patch_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified regional BackendService resource with the data included in the request. For more @@ -2000,8 +2055,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2076,7 +2133,7 @@ def patch( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified regional BackendService resource with the data included in the request. For more @@ -2144,8 +2201,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2249,7 +2308,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2314,8 +2373,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.cloud.compute_v1.types.Policy: @@ -2416,7 +2477,7 @@ def set_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Google Cloud Armor security policy for the specified backend service. For more information, see @@ -2483,8 +2544,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -2567,7 +2630,7 @@ def set_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Google Cloud Armor security policy for the specified backend service. For more information, see @@ -2634,8 +2697,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -2743,7 +2808,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2808,8 +2873,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -2888,7 +2955,7 @@ def update_unary( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified regional BackendService resource with the data included in the request. For more @@ -2954,8 +3021,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -3032,7 +3101,7 @@ def update( backend_service_resource: Optional[compute.BackendService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified regional BackendService resource with the data included in the request. For more @@ -3098,8 +3167,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/pagers.py index 1c80b27652a3..2fac8ff6d47c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/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 = compute.ListRegionBackendServicesRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListUsableRegionBackendServicesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/transports/rest.py index 04be13822ece..4ad5008ff3a5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_backend_services/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 @@ -37,6 +37,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, @@ -165,8 +173,11 @@ def post_update(self, response): def pre_delete( self, request: compute.DeleteRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -186,8 +197,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionBackendServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -207,8 +220,11 @@ def post_get(self, response: compute.BackendService) -> compute.BackendService: def pre_get_health( self, request: compute.GetHealthRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetHealthRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetHealthRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_health Override in a subclass to manipulate the request or metadata @@ -230,9 +246,10 @@ def post_get_health( def pre_get_iam_policy( self, request: compute.GetIamPolicyRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetIamPolicyRegionBackendServiceRequest, Sequence[Tuple[str, str]] + compute.GetIamPolicyRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_iam_policy @@ -253,8 +270,11 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -274,8 +294,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionBackendServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionBackendServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionBackendServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -297,9 +320,10 @@ def post_list( def pre_list_usable( self, request: compute.ListUsableRegionBackendServicesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListUsableRegionBackendServicesRequest, Sequence[Tuple[str, str]] + compute.ListUsableRegionBackendServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_usable @@ -322,8 +346,11 @@ def post_list_usable( def pre_patch( self, request: compute.PatchRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -343,9 +370,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetIamPolicyRegionBackendServiceRequest, Sequence[Tuple[str, str]] + compute.SetIamPolicyRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_iam_policy @@ -366,9 +394,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_security_policy( self, request: compute.SetSecurityPolicyRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetSecurityPolicyRegionBackendServiceRequest, Sequence[Tuple[str, str]] + compute.SetSecurityPolicyRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_security_policy @@ -391,9 +420,10 @@ def post_set_security_policy( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsRegionBackendServiceRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -416,8 +446,11 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateRegionBackendServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionBackendServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionBackendServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -560,7 +593,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -572,8 +605,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: ~.compute.Operation: @@ -600,6 +635,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -610,6 +646,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 = 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.compute_v1.RegionBackendServicesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._Delete._get_response( self._host, @@ -630,7 +693,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionBackendServicesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -667,7 +752,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]]] = (), ) -> compute.BackendService: r"""Call the get method over HTTP. @@ -679,8 +764,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: ~.compute.BackendService: @@ -705,6 +792,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -717,6 +805,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.compute_v1.RegionBackendServicesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._Get._get_response( self._host, @@ -737,7 +852,29 @@ def __call__( pb_resp = compute.BackendService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendService.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.compute_v1.RegionBackendServicesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHealth( @@ -776,7 +913,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]]] = (), ) -> compute.BackendServiceGroupHealth: r"""Call the get health method over HTTP. @@ -788,8 +925,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: ~.compute.BackendServiceGroupHealth: @@ -799,6 +938,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseGetHealth._get_http_options() ) + request, metadata = self._interceptor.pre_get_health(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseGetHealth._get_transcoded_request( http_options, request @@ -813,6 +953,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 = 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.compute_v1.RegionBackendServicesClient.GetHealth", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "GetHealth", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._GetHealth._get_response( self._host, @@ -834,7 +1001,31 @@ def __call__( pb_resp = compute.BackendServiceGroupHealth.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_health(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceGroupHealth.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.compute_v1.RegionBackendServicesClient.get_health", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "GetHealth", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -872,7 +1063,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -884,8 +1075,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: ~.compute.Policy: @@ -918,6 +1111,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -928,6 +1122,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 = 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.compute_v1.RegionBackendServicesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._GetIamPolicy._get_response( self._host, @@ -948,7 +1169,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionBackendServicesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -987,7 +1230,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -999,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: ~.compute.Operation: @@ -1027,6 +1272,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1041,6 +1287,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 = 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.compute_v1.RegionBackendServicesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._Insert._get_response( self._host, @@ -1062,7 +1335,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionBackendServicesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1099,7 +1394,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]]] = (), ) -> compute.BackendServiceList: r"""Call the list method over HTTP. @@ -1111,8 +1406,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: ~.compute.BackendServiceList: @@ -1124,6 +1421,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1134,6 +1432,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 = 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.compute_v1.RegionBackendServicesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._List._get_response( self._host, @@ -1154,7 +1479,29 @@ def __call__( pb_resp = compute.BackendServiceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceList.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.compute_v1.RegionBackendServicesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsable( @@ -1192,7 +1539,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]]] = (), ) -> compute.BackendServiceListUsable: r"""Call the list usable method over HTTP. @@ -1204,8 +1551,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: ~.compute.BackendServiceListUsable: @@ -1217,6 +1566,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseListUsable._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseListUsable._get_transcoded_request( http_options, request @@ -1227,6 +1577,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 = 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.compute_v1.RegionBackendServicesClient.ListUsable", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "ListUsable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._ListUsable._get_response( self._host, @@ -1247,7 +1624,31 @@ def __call__( pb_resp = compute.BackendServiceListUsable.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.BackendServiceListUsable.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.compute_v1.RegionBackendServicesClient.list_usable", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "ListUsable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1286,7 +1687,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1298,8 +1699,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: ~.compute.Operation: @@ -1326,6 +1729,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -1340,6 +1744,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 = 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.compute_v1.RegionBackendServicesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._Patch._get_response( self._host, @@ -1361,7 +1792,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionBackendServicesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1400,7 +1853,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1412,8 +1865,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: ~.compute.Policy: @@ -1446,6 +1901,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1460,6 +1916,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 = 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.compute_v1.RegionBackendServicesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._SetIamPolicy._get_response( self._host, @@ -1481,7 +1964,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionBackendServicesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSecurityPolicy( @@ -1520,7 +2025,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]]] = (), ) -> compute.Operation: r"""Call the set security policy method over HTTP. @@ -1532,8 +2037,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: ~.compute.Operation: @@ -1560,6 +2067,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseSetSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_security_policy( request, metadata ) @@ -1576,6 +2084,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 = 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.compute_v1.RegionBackendServicesClient.SetSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "SetSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionBackendServicesRestTransport._SetSecurityPolicy._get_response( @@ -1599,7 +2134,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionBackendServicesClient.set_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "SetSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1638,7 +2195,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1650,8 +2207,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: ~.compute.TestPermissionsResponse: @@ -1661,6 +2220,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1677,6 +2237,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 = 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.compute_v1.RegionBackendServicesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionBackendServicesRestTransport._TestIamPermissions._get_response( @@ -1700,7 +2287,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.RegionBackendServicesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update( @@ -1739,7 +2348,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1751,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: ~.compute.Operation: @@ -1779,6 +2390,7 @@ def __call__( http_options = ( _BaseRegionBackendServicesRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = _BaseRegionBackendServicesRestTransport._BaseUpdate._get_transcoded_request( http_options, request @@ -1793,6 +2405,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 = 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.compute_v1.RegionBackendServicesClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionBackendServicesRestTransport._Update._get_response( self._host, @@ -1814,7 +2453,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionBackendServicesClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionBackendServices", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/client.py index fbe87ac20479..f7426af18183 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_commitments import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.RegionCommitmentsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "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.compute.v1.RegionCommitments", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of commitments by region. To prevent failure, Google recommends that you set the @@ -683,8 +720,10 @@ def sample_aggregated_list(): 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.compute_v1.services.region_commitments.pagers.AggregatedListPager: @@ -756,7 +795,7 @@ def get( commitment: 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]]] = (), ) -> compute.Commitment: r"""Returns the specified commitment resource. @@ -811,8 +850,10 @@ def sample_get(): 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.compute_v1.types.Commitment: @@ -889,7 +930,7 @@ def insert_unary( commitment_resource: Optional[compute.Commitment] = 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]]] = (), ) -> compute.Operation: r"""Creates a commitment in the specified project using the data included in the request. @@ -944,8 +985,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1014,7 +1057,7 @@ def insert( commitment_resource: Optional[compute.Commitment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a commitment in the specified project using the data included in the request. @@ -1069,8 +1112,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1163,7 +1208,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of commitments contained within the specified region. @@ -1214,8 +1259,10 @@ def sample_list(): 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.compute_v1.services.region_commitments.pagers.ListPager: @@ -1297,7 +1344,7 @@ def update_unary( commitment_resource: Optional[compute.Commitment] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as @@ -1362,8 +1409,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1436,7 +1485,7 @@ def update( commitment_resource: Optional[compute.Commitment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as @@ -1501,8 +1550,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/pagers.py index bee57db575f3..d056e702a973 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/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 = compute.AggregatedListRegionCommitmentsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListRegionCommitmentsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/transports/rest.py index 6f997fff320c..b207f0dda3e0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_commitments/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 @@ -37,6 +37,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, @@ -109,9 +117,10 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListRegionCommitmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListRegionCommitmentsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListRegionCommitmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -134,8 +143,10 @@ def post_aggregated_list( def pre_get( self, request: compute.GetRegionCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionCommitmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -155,8 +166,10 @@ def post_get(self, response: compute.Commitment) -> compute.Commitment: def pre_insert( self, request: compute.InsertRegionCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionCommitmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -176,8 +189,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionCommitmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionCommitmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionCommitmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -197,8 +212,10 @@ def post_list(self, response: compute.CommitmentList) -> compute.CommitmentList: def pre_update( self, request: compute.UpdateRegionCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionCommitmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -341,7 +358,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]]] = (), ) -> compute.CommitmentAggregatedList: r"""Call the aggregated list method over HTTP. @@ -353,8 +370,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: ~.compute.CommitmentAggregatedList: @@ -364,6 +383,7 @@ def __call__( http_options = ( _BaseRegionCommitmentsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseRegionCommitmentsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -374,6 +394,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 = 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.compute_v1.RegionCommitmentsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionCommitmentsRestTransport._AggregatedList._get_response( self._host, @@ -394,7 +441,31 @@ def __call__( pb_resp = compute.CommitmentAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.CommitmentAggregatedList.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.compute_v1.RegionCommitmentsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionCommitmentsRestTransport._BaseGet, RegionCommitmentsRestStub): @@ -429,7 +500,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]]] = (), ) -> compute.Commitment: r"""Call the get method over HTTP. @@ -441,8 +512,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: ~.compute.Commitment: @@ -461,6 +534,7 @@ def __call__( http_options = ( _BaseRegionCommitmentsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionCommitmentsRestTransport._BaseGet._get_transcoded_request( @@ -475,6 +549,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.compute_v1.RegionCommitmentsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionCommitmentsRestTransport._Get._get_response( self._host, @@ -495,7 +596,29 @@ def __call__( pb_resp = compute.Commitment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Commitment.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.compute_v1.RegionCommitmentsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -533,7 +656,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -545,8 +668,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: ~.compute.Operation: @@ -573,6 +698,7 @@ def __call__( http_options = ( _BaseRegionCommitmentsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRegionCommitmentsRestTransport._BaseInsert._get_transcoded_request( @@ -593,6 +719,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.compute_v1.RegionCommitmentsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionCommitmentsRestTransport._Insert._get_response( self._host, @@ -614,7 +767,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionCommitmentsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -651,7 +826,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]]] = (), ) -> compute.CommitmentList: r"""Call the list method over HTTP. @@ -663,8 +838,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: ~.compute.CommitmentList: @@ -676,6 +853,7 @@ def __call__( http_options = ( _BaseRegionCommitmentsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionCommitmentsRestTransport._BaseList._get_transcoded_request( @@ -690,6 +868,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.compute_v1.RegionCommitmentsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionCommitmentsRestTransport._List._get_response( self._host, @@ -710,7 +915,29 @@ def __call__( pb_resp = compute.CommitmentList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.CommitmentList.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.compute_v1.RegionCommitmentsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update( @@ -748,7 +975,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -760,8 +987,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: ~.compute.Operation: @@ -788,6 +1017,7 @@ def __call__( http_options = ( _BaseRegionCommitmentsRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseRegionCommitmentsRestTransport._BaseUpdate._get_transcoded_request( @@ -808,6 +1038,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.compute_v1.RegionCommitmentsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionCommitmentsRestTransport._Update._get_response( self._host, @@ -829,7 +1086,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionCommitmentsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionCommitments", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/client.py index af05f4178fd6..a0b4bd78b6c2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/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.compute_v1.services.region_disk_types import pagers from google.cloud.compute_v1.types import compute @@ -557,6 +567,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( @@ -622,6 +636,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.compute_v1.RegionDiskTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDiskTypes", + "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.compute.v1.RegionDiskTypes", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetRegionDiskTypeRequest, dict]] = None, @@ -631,7 +668,7 @@ def get( disk_type: 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]]] = (), ) -> compute.DiskType: r"""Returns the specified regional disk type. @@ -688,8 +725,10 @@ def sample_get(): 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.compute_v1.types.DiskType: @@ -767,7 +806,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of regional disk types available to the specified project. @@ -820,8 +859,10 @@ def sample_list(): 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.compute_v1.services.region_disk_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/pagers.py index 0b6388facaa9..a9fb30efbaed 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/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 = compute.ListRegionDiskTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/transports/rest.py index ecf3882292b2..5cf89c9f26de 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disk_types/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 @@ -37,6 +37,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, @@ -85,8 +93,10 @@ def post_list(self, response): def pre_get( self, request: compute.GetRegionDiskTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionDiskTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionDiskTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -106,8 +116,10 @@ def post_get(self, response: compute.DiskType) -> compute.DiskType: def pre_list( self, request: compute.ListRegionDiskTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionDiskTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionDiskTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -249,7 +261,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]]] = (), ) -> compute.DiskType: r"""Call the get method over HTTP. @@ -261,8 +273,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: ~.compute.DiskType: @@ -283,6 +297,7 @@ def __call__( http_options = ( _BaseRegionDiskTypesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionDiskTypesRestTransport._BaseGet._get_transcoded_request( @@ -297,6 +312,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.compute_v1.RegionDiskTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDiskTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDiskTypesRestTransport._Get._get_response( self._host, @@ -317,7 +359,29 @@ def __call__( pb_resp = compute.DiskType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskType.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.compute_v1.RegionDiskTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDiskTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRegionDiskTypesRestTransport._BaseList, RegionDiskTypesRestStub): @@ -352,7 +416,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]]] = (), ) -> compute.RegionDiskTypeList: r"""Call the list method over HTTP. @@ -364,8 +428,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: ~.compute.RegionDiskTypeList: @@ -375,6 +441,7 @@ def __call__( http_options = ( _BaseRegionDiskTypesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionDiskTypesRestTransport._BaseList._get_transcoded_request( @@ -389,6 +456,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.compute_v1.RegionDiskTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDiskTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDiskTypesRestTransport._List._get_response( self._host, @@ -409,7 +503,29 @@ def __call__( pb_resp = compute.RegionDiskTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionDiskTypeList.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.compute_v1.RegionDiskTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDiskTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/client.py index 68a0779f4ab3..1e4c08bc612e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_disks import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.RegionDisksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "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.compute.v1.RegionDisks", + "credentialsType": None, + }, + ) + def add_resource_policies_unary( self, request: Optional[ @@ -632,7 +669,7 @@ def add_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds existing resource policies to a regional disk. You can only add one policy which will be applied to @@ -696,8 +733,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -778,7 +817,7 @@ def add_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds existing resource policies to a regional disk. You can only add one policy which will be applied to @@ -842,8 +881,10 @@ def sample_add_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -946,7 +987,7 @@ def bulk_insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Bulk create a set of disks. @@ -1002,8 +1043,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1078,7 +1121,7 @@ def bulk_insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Bulk create a set of disks. @@ -1134,8 +1177,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1234,7 +1279,7 @@ def create_snapshot_unary( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> compute.Operation: r"""Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using @@ -1300,8 +1345,10 @@ def sample_create_snapshot(): 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.api_core.extended_operation.ExtendedOperation: @@ -1374,7 +1421,7 @@ def create_snapshot( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using @@ -1440,8 +1487,10 @@ def sample_create_snapshot(): 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.api_core.extended_operation.ExtendedOperation: @@ -1538,7 +1587,7 @@ def delete_unary( disk: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its @@ -1599,8 +1648,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1670,7 +1721,7 @@ def delete( disk: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its @@ -1731,8 +1782,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1827,7 +1880,7 @@ def get( disk: 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]]] = (), ) -> compute.Disk: r"""Returns a specified regional persistent disk. @@ -1884,8 +1937,10 @@ def sample_get(): 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.compute_v1.types.Disk: @@ -1965,7 +2020,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -2025,8 +2080,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.cloud.compute_v1.types.Policy: @@ -2116,7 +2173,7 @@ def insert_unary( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> compute.Operation: r"""Creates a persistent regional disk in the specified project using the data included in the request. @@ -2171,8 +2228,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2241,7 +2300,7 @@ def insert( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a persistent regional disk in the specified project using the data included in the request. @@ -2296,8 +2355,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2390,7 +2451,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of persistent disks contained within the specified region. @@ -2441,8 +2502,10 @@ def sample_list(): 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.compute_v1.services.region_disks.pagers.ListPager: @@ -2528,7 +2591,7 @@ def remove_resource_policies_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes resource policies from a regional disk. @@ -2590,8 +2653,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -2677,7 +2742,7 @@ def remove_resource_policies( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes resource policies from a regional disk. @@ -2739,8 +2804,10 @@ def sample_remove_resource_policies(): 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.api_core.extended_operation.ExtendedOperation: @@ -2849,7 +2916,7 @@ def resize_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Resizes the specified regional persistent disk. @@ -2909,8 +2976,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -2989,7 +3058,7 @@ def resize( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Resizes the specified regional persistent disk. @@ -3049,8 +3118,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -3154,7 +3225,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -3219,8 +3290,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.cloud.compute_v1.types.Policy: @@ -3319,7 +3392,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on the target regional disk. @@ -3381,8 +3454,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -3461,7 +3536,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on the target regional disk. @@ -3523,8 +3598,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -3630,7 +3707,7 @@ def start_async_replication_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Starts asynchronous replication. Must be invoked on the primary disk. @@ -3693,8 +3770,10 @@ def sample_start_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -3780,7 +3859,7 @@ def start_async_replication( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Starts asynchronous replication. Must be invoked on the primary disk. @@ -3843,8 +3922,10 @@ def sample_start_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -3952,7 +4033,7 @@ def stop_async_replication_unary( disk: 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]]] = (), ) -> compute.Operation: r"""Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. @@ -4010,8 +4091,10 @@ def sample_stop_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4083,7 +4166,7 @@ def stop_async_replication( disk: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. @@ -4141,8 +4224,10 @@ def sample_stop_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4241,7 +4326,7 @@ def stop_group_async_replication_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or @@ -4301,8 +4386,10 @@ def sample_stop_group_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4381,7 +4468,7 @@ def stop_group_async_replication( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or @@ -4441,8 +4528,10 @@ def sample_stop_group_async_replication(): 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.api_core.extended_operation.ExtendedOperation: @@ -4547,7 +4636,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -4612,8 +4701,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -4688,7 +4779,7 @@ def update_unary( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> compute.Operation: r"""Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of @@ -4753,8 +4844,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -4827,7 +4920,7 @@ def update( disk_resource: Optional[compute.Disk] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of @@ -4892,8 +4985,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/pagers.py index c5510fa9acef..5bbce7052f5b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/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 = compute.ListRegionDisksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/transports/rest.py index 8ce4c1000a06..8b2876377397 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_disks/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 @@ -37,6 +37,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, @@ -205,8 +213,11 @@ def post_update(self, response): def pre_add_resource_policies( self, request: compute.AddResourcePoliciesRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddResourcePoliciesRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddResourcePoliciesRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_resource_policies Override in a subclass to manipulate the request or metadata @@ -228,8 +239,10 @@ def post_add_resource_policies( def pre_bulk_insert( self, request: compute.BulkInsertRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.BulkInsertRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.BulkInsertRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for bulk_insert Override in a subclass to manipulate the request or metadata @@ -249,8 +262,10 @@ def post_bulk_insert(self, response: compute.Operation) -> compute.Operation: def pre_create_snapshot( self, request: compute.CreateSnapshotRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.CreateSnapshotRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.CreateSnapshotRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_snapshot Override in a subclass to manipulate the request or metadata @@ -270,8 +285,10 @@ def post_create_snapshot(self, response: compute.Operation) -> compute.Operation def pre_delete( self, request: compute.DeleteRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -289,8 +306,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetRegionDiskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetRegionDiskRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetRegionDiskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -310,8 +329,10 @@ def post_get(self, response: compute.Disk) -> compute.Disk: def pre_get_iam_policy( self, request: compute.GetIamPolicyRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -331,8 +352,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -352,8 +375,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionDisksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionDisksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListRegionDisksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -373,9 +396,10 @@ def post_list(self, response: compute.DiskList) -> compute.DiskList: def pre_remove_resource_policies( self, request: compute.RemoveResourcePoliciesRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveResourcePoliciesRegionDiskRequest, Sequence[Tuple[str, str]] + compute.RemoveResourcePoliciesRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_resource_policies @@ -398,8 +422,10 @@ def post_remove_resource_policies( def pre_resize( self, request: compute.ResizeRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ResizeRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ResizeRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resize Override in a subclass to manipulate the request or metadata @@ -419,8 +445,10 @@ def post_resize(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -440,8 +468,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -461,9 +491,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_start_async_replication( self, request: compute.StartAsyncReplicationRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.StartAsyncReplicationRegionDiskRequest, Sequence[Tuple[str, str]] + compute.StartAsyncReplicationRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for start_async_replication @@ -486,9 +517,10 @@ def post_start_async_replication( def pre_stop_async_replication( self, request: compute.StopAsyncReplicationRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.StopAsyncReplicationRegionDiskRequest, Sequence[Tuple[str, str]] + compute.StopAsyncReplicationRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for stop_async_replication @@ -511,9 +543,10 @@ def post_stop_async_replication( def pre_stop_group_async_replication( self, request: compute.StopGroupAsyncReplicationRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.StopGroupAsyncReplicationRegionDiskRequest, Sequence[Tuple[str, str]] + compute.StopGroupAsyncReplicationRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for stop_group_async_replication @@ -536,8 +569,11 @@ def post_stop_group_async_replication( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsRegionDiskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -559,8 +595,10 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateRegionDiskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionDiskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionDiskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -703,7 +741,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]]] = (), ) -> compute.Operation: r"""Call the add resource policies method over HTTP. @@ -715,8 +753,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: ~.compute.Operation: @@ -743,6 +783,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseAddResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_add_resource_policies( request, metadata ) @@ -759,6 +800,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 = 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.compute_v1.RegionDisksClient.AddResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "AddResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._AddResourcePolicies._get_response( self._host, @@ -780,7 +848,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.add_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "AddResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BulkInsert( @@ -818,7 +908,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]]] = (), ) -> compute.Operation: r"""Call the bulk insert method over HTTP. @@ -830,8 +920,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: ~.compute.Operation: @@ -858,6 +950,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseBulkInsert._get_http_options() ) + request, metadata = self._interceptor.pre_bulk_insert(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseBulkInsert._get_transcoded_request( @@ -876,6 +969,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.compute_v1.RegionDisksClient.BulkInsert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "BulkInsert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._BulkInsert._get_response( self._host, @@ -897,7 +1017,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.bulk_insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "BulkInsert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSnapshot( @@ -935,7 +1077,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]]] = (), ) -> compute.Operation: r"""Call the create snapshot method over HTTP. @@ -947,8 +1089,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: ~.compute.Operation: @@ -975,6 +1119,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseCreateSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_create_snapshot(request, metadata) transcoded_request = _BaseRegionDisksRestTransport._BaseCreateSnapshot._get_transcoded_request( http_options, request @@ -989,6 +1134,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 = 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.compute_v1.RegionDisksClient.CreateSnapshot", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "CreateSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._CreateSnapshot._get_response( self._host, @@ -1010,7 +1182,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.create_snapshot", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "CreateSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseRegionDisksRestTransport._BaseDelete, RegionDisksRestStub): @@ -1045,7 +1239,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1057,8 +1251,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: ~.compute.Operation: @@ -1083,6 +1279,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseDelete._get_transcoded_request( @@ -1097,6 +1294,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.compute_v1.RegionDisksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._Delete._get_response( self._host, @@ -1117,7 +1341,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionDisksRestTransport._BaseGet, RegionDisksRestStub): @@ -1152,7 +1398,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]]] = (), ) -> compute.Disk: r"""Call the get method over HTTP. @@ -1164,8 +1410,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: ~.compute.Disk: @@ -1185,6 +1433,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseGet._get_transcoded_request( @@ -1199,6 +1448,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.compute_v1.RegionDisksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._Get._get_response( self._host, @@ -1219,7 +1495,29 @@ def __call__( pb_resp = compute.Disk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Disk.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.compute_v1.RegionDisksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1256,7 +1554,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1268,8 +1566,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: ~.compute.Policy: @@ -1302,6 +1602,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1316,6 +1617,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.compute_v1.RegionDisksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._GetIamPolicy._get_response( self._host, @@ -1336,7 +1664,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionDisksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseRegionDisksRestTransport._BaseInsert, RegionDisksRestStub): @@ -1372,7 +1722,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1384,8 +1734,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: ~.compute.Operation: @@ -1410,6 +1762,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseInsert._get_transcoded_request( @@ -1428,6 +1781,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.compute_v1.RegionDisksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._Insert._get_response( self._host, @@ -1449,7 +1829,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRegionDisksRestTransport._BaseList, RegionDisksRestStub): @@ -1484,7 +1886,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]]] = (), ) -> compute.DiskList: r"""Call the list method over HTTP. @@ -1496,8 +1898,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: ~.compute.DiskList: @@ -1505,6 +1909,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseList._get_transcoded_request( @@ -1519,6 +1924,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.compute_v1.RegionDisksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._List._get_response( self._host, @@ -1539,7 +1971,29 @@ def __call__( pb_resp = compute.DiskList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DiskList.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.compute_v1.RegionDisksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveResourcePolicies( @@ -1577,7 +2031,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]]] = (), ) -> compute.Operation: r"""Call the remove resource policies method over HTTP. @@ -1589,8 +2043,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: ~.compute.Operation: @@ -1617,6 +2073,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseRemoveResourcePolicies._get_http_options() ) + request, metadata = self._interceptor.pre_remove_resource_policies( request, metadata ) @@ -1633,6 +2090,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 = 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.compute_v1.RegionDisksClient.RemoveResourcePolicies", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "RemoveResourcePolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._RemoveResourcePolicies._get_response( self._host, @@ -1654,7 +2138,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_resource_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.remove_resource_policies", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "RemoveResourcePolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resize(_BaseRegionDisksRestTransport._BaseResize, RegionDisksRestStub): @@ -1690,7 +2196,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]]] = (), ) -> compute.Operation: r"""Call the resize method over HTTP. @@ -1702,8 +2208,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: ~.compute.Operation: @@ -1728,6 +2236,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseResize._get_http_options() + request, metadata = self._interceptor.pre_resize(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseResize._get_transcoded_request( @@ -1746,6 +2255,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.compute_v1.RegionDisksClient.Resize", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Resize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._Resize._get_response( self._host, @@ -1767,7 +2303,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.resize", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Resize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1805,7 +2363,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1817,8 +2375,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: ~.compute.Policy: @@ -1851,6 +2411,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1871,6 +2432,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.compute_v1.RegionDisksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._SetIamPolicy._get_response( self._host, @@ -1892,7 +2480,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionDisksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseRegionDisksRestTransport._BaseSetLabels, RegionDisksRestStub): @@ -1928,7 +2538,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1940,8 +2550,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: ~.compute.Operation: @@ -1968,6 +2580,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseSetLabels._get_transcoded_request( @@ -1986,6 +2599,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.compute_v1.RegionDisksClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._SetLabels._get_response( self._host, @@ -2007,7 +2647,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartAsyncReplication( @@ -2045,7 +2707,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]]] = (), ) -> compute.Operation: r"""Call the start async replication method over HTTP. @@ -2057,8 +2719,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: ~.compute.Operation: @@ -2085,6 +2749,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseStartAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_start_async_replication( request, metadata ) @@ -2101,6 +2766,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 = 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.compute_v1.RegionDisksClient.StartAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StartAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._StartAsyncReplication._get_response( self._host, @@ -2122,7 +2814,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.start_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StartAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopAsyncReplication( @@ -2159,7 +2873,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]]] = (), ) -> compute.Operation: r"""Call the stop async replication method over HTTP. @@ -2171,8 +2885,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: ~.compute.Operation: @@ -2199,6 +2915,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseStopAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_stop_async_replication( request, metadata ) @@ -2211,6 +2928,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 = 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.compute_v1.RegionDisksClient.StopAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StopAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._StopAsyncReplication._get_response( self._host, @@ -2231,7 +2975,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.stop_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StopAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopGroupAsyncReplication( @@ -2270,7 +3036,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]]] = (), ) -> compute.Operation: r"""Call the stop group async replication method over HTTP. @@ -2283,8 +3049,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: ~.compute.Operation: @@ -2311,6 +3079,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseStopGroupAsyncReplication._get_http_options() ) + request, metadata = self._interceptor.pre_stop_group_async_replication( request, metadata ) @@ -2327,6 +3096,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 = 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.compute_v1.RegionDisksClient.StopGroupAsyncReplication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StopGroupAsyncReplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionDisksRestTransport._StopGroupAsyncReplication._get_response( @@ -2350,7 +3146,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_group_async_replication(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.stop_group_async_replication", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "StopGroupAsyncReplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2388,7 +3206,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2400,8 +3218,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: ~.compute.TestPermissionsResponse: @@ -2411,6 +3231,7 @@ def __call__( http_options = ( _BaseRegionDisksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2427,6 +3248,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 = 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.compute_v1.RegionDisksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._TestIamPermissions._get_response( self._host, @@ -2448,7 +3296,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.RegionDisksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseRegionDisksRestTransport._BaseUpdate, RegionDisksRestStub): @@ -2484,7 +3354,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -2496,8 +3366,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: ~.compute.Operation: @@ -2522,6 +3394,7 @@ def __call__( """ http_options = _BaseRegionDisksRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseRegionDisksRestTransport._BaseUpdate._get_transcoded_request( @@ -2540,6 +3413,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.compute_v1.RegionDisksClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionDisksRestTransport._Update._get_response( self._host, @@ -2561,7 +3461,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionDisksClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionDisks", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/client.py index fb3642bd35c0..a394a0334801 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_health_check_services import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.RegionHealthCheckServicesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "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.compute.v1.RegionHealthCheckServices", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -643,7 +680,7 @@ def delete_unary( health_check_service: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified regional HealthCheckService. @@ -703,8 +740,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -776,7 +815,7 @@ def delete( health_check_service: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified regional HealthCheckService. @@ -836,8 +875,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -934,7 +975,7 @@ def get( health_check_service: 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]]] = (), ) -> compute.HealthCheckService: r"""Returns the specified regional HealthCheckService resource. @@ -995,8 +1036,10 @@ def sample_get(): 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.compute_v1.types.HealthCheckService: @@ -1068,7 +1111,7 @@ def insert_unary( health_check_service_resource: Optional[compute.HealthCheckService] = 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]]] = (), ) -> compute.Operation: r"""Creates a regional HealthCheckService resource in the specified project and region using the data included in @@ -1126,8 +1169,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1198,7 +1243,7 @@ def insert( health_check_service_resource: Optional[compute.HealthCheckService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a regional HealthCheckService resource in the specified project and region using the data included in @@ -1256,8 +1301,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1352,7 +1399,7 @@ def list( region: 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.ListPager: r"""Lists all the HealthCheckService resources that have been configured for the specified project in the given @@ -1406,8 +1453,10 @@ def sample_list(): 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.compute_v1.services.region_health_check_services.pagers.ListPager: @@ -1489,7 +1538,7 @@ def patch_unary( health_check_service_resource: Optional[compute.HealthCheckService] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified regional HealthCheckService resource with the data included in the request. This @@ -1557,8 +1606,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1635,7 +1686,7 @@ def patch( health_check_service_resource: Optional[compute.HealthCheckService] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified regional HealthCheckService resource with the data included in the request. This @@ -1703,8 +1754,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/pagers.py index 02f620a9507d..a5ba7ec0b6d7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/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 = compute.ListRegionHealthCheckServicesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/transports/rest.py index 87f845e6c4ee..bd0ea4061c20 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_check_services/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 @@ -37,6 +37,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, @@ -109,9 +117,10 @@ def post_patch(self, response): def pre_delete( self, request: compute.DeleteRegionHealthCheckServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteRegionHealthCheckServiceRequest, Sequence[Tuple[str, str]] + compute.DeleteRegionHealthCheckServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -132,8 +141,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionHealthCheckServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionHealthCheckServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionHealthCheckServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -155,9 +167,10 @@ def post_get( def pre_insert( self, request: compute.InsertRegionHealthCheckServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertRegionHealthCheckServiceRequest, Sequence[Tuple[str, str]] + compute.InsertRegionHealthCheckServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -178,8 +191,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionHealthCheckServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionHealthCheckServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionHealthCheckServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -201,8 +217,11 @@ def post_list( def pre_patch( self, request: compute.PatchRegionHealthCheckServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionHealthCheckServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionHealthCheckServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -347,7 +366,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -359,8 +378,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: ~.compute.Operation: @@ -387,6 +408,7 @@ def __call__( http_options = ( _BaseRegionHealthCheckServicesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionHealthCheckServicesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -397,6 +419,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 = 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.compute_v1.RegionHealthCheckServicesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthCheckServicesRestTransport._Delete._get_response( self._host, @@ -417,7 +466,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthCheckServicesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -455,7 +526,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]]] = (), ) -> compute.HealthCheckService: r"""Call the get method over HTTP. @@ -467,8 +538,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: ~.compute.HealthCheckService: @@ -480,6 +553,7 @@ def __call__( http_options = ( _BaseRegionHealthCheckServicesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionHealthCheckServicesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -490,6 +564,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 = 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.compute_v1.RegionHealthCheckServicesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthCheckServicesRestTransport._Get._get_response( self._host, @@ -510,7 +611,29 @@ def __call__( pb_resp = compute.HealthCheckService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheckService.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.compute_v1.RegionHealthCheckServicesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -549,7 +672,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -561,8 +684,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: ~.compute.Operation: @@ -589,6 +714,7 @@ def __call__( http_options = ( _BaseRegionHealthCheckServicesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionHealthCheckServicesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -603,6 +729,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 = 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.compute_v1.RegionHealthCheckServicesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthCheckServicesRestTransport._Insert._get_response( self._host, @@ -624,7 +777,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthCheckServicesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -662,7 +837,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]]] = (), ) -> compute.HealthCheckServicesList: r"""Call the list method over HTTP. @@ -674,8 +849,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: ~.compute.HealthCheckServicesList: @@ -685,6 +862,7 @@ def __call__( http_options = ( _BaseRegionHealthCheckServicesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionHealthCheckServicesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -695,6 +873,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 = 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.compute_v1.RegionHealthCheckServicesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthCheckServicesRestTransport._List._get_response( self._host, @@ -715,7 +920,29 @@ def __call__( pb_resp = compute.HealthCheckServicesList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheckServicesList.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.compute_v1.RegionHealthCheckServicesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -754,7 +981,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -766,8 +993,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: ~.compute.Operation: @@ -794,6 +1023,7 @@ def __call__( http_options = ( _BaseRegionHealthCheckServicesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionHealthCheckServicesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -808,6 +1038,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 = 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.compute_v1.RegionHealthCheckServicesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthCheckServicesRestTransport._Patch._get_response( self._host, @@ -829,7 +1086,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthCheckServicesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthCheckServices", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/client.py index 6a4f3b38feae..b806419b537f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_health_checks import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.RegionHealthChecksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "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.compute.v1.RegionHealthChecks", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteRegionHealthCheckRequest, dict]] = None, @@ -637,7 +674,7 @@ def delete_unary( health_check: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified HealthCheck resource. @@ -696,8 +733,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -767,7 +806,7 @@ def delete( health_check: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified HealthCheck resource. @@ -826,8 +865,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -922,7 +963,7 @@ def get( health_check: 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]]] = (), ) -> compute.HealthCheck: r"""Returns the specified HealthCheck resource. @@ -981,8 +1022,10 @@ def sample_get(): 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.compute_v1.types.HealthCheck: @@ -1067,7 +1110,7 @@ def insert_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Creates a HealthCheck resource in the specified project using the data included in the request. @@ -1124,8 +1167,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1194,7 +1239,7 @@ def insert( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a HealthCheck resource in the specified project using the data included in the request. @@ -1251,8 +1296,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1345,7 +1392,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of HealthCheck resources available to the specified project. @@ -1398,8 +1445,10 @@ def sample_list(): 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.compute_v1.services.region_health_checks.pagers.ListPager: @@ -1481,7 +1530,7 @@ def patch_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. This @@ -1548,8 +1597,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1624,7 +1675,7 @@ def patch( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. This @@ -1691,8 +1742,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1792,7 +1845,7 @@ def update_unary( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> compute.Operation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. @@ -1857,8 +1910,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1933,7 +1988,7 @@ def update( health_check_resource: Optional[compute.HealthCheck] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a HealthCheck resource in the specified project using the data included in the request. @@ -1998,8 +2053,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/pagers.py index c1e67a9f05f8..b8c8e9e67da4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/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 = compute.ListRegionHealthChecksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/transports/rest.py index 431e3f71e0e0..c5258e0645f8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_health_checks/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_update(self, response): def pre_delete( self, request: compute.DeleteRegionHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -138,8 +148,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -159,8 +171,10 @@ def post_get(self, response: compute.HealthCheck) -> compute.HealthCheck: def pre_insert( self, request: compute.InsertRegionHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -180,8 +194,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionHealthChecksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionHealthChecksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionHealthChecksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -201,8 +217,10 @@ def post_list(self, response: compute.HealthCheckList) -> compute.HealthCheckLis def pre_patch( self, request: compute.PatchRegionHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -222,8 +240,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateRegionHealthCheckRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionHealthCheckRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionHealthCheckRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -365,7 +385,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -377,8 +397,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: ~.compute.Operation: @@ -405,6 +427,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionHealthChecksRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -417,6 +440,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.compute_v1.RegionHealthChecksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._Delete._get_response( self._host, @@ -437,7 +487,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthChecksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -474,7 +546,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]]] = (), ) -> compute.HealthCheck: r"""Call the get method over HTTP. @@ -486,8 +558,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: ~.compute.HealthCheck: @@ -514,6 +588,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionHealthChecksRestTransport._BaseGet._get_transcoded_request( @@ -528,6 +603,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.compute_v1.RegionHealthChecksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._Get._get_response( self._host, @@ -548,7 +650,29 @@ def __call__( pb_resp = compute.HealthCheck.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheck.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.compute_v1.RegionHealthChecksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -586,7 +710,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -598,8 +722,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: ~.compute.Operation: @@ -626,6 +752,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionHealthChecksRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -644,6 +771,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.compute_v1.RegionHealthChecksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._Insert._get_response( self._host, @@ -665,7 +819,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthChecksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -702,7 +878,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]]] = (), ) -> compute.HealthCheckList: r"""Call the list method over HTTP. @@ -714,8 +890,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: ~.compute.HealthCheckList: @@ -727,6 +905,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionHealthChecksRestTransport._BaseList._get_transcoded_request( @@ -741,6 +920,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.compute_v1.RegionHealthChecksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._List._get_response( self._host, @@ -761,7 +967,29 @@ def __call__( pb_resp = compute.HealthCheckList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.HealthCheckList.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.compute_v1.RegionHealthChecksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -799,7 +1027,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -811,8 +1039,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: ~.compute.Operation: @@ -839,6 +1069,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseRegionHealthChecksRestTransport._BasePatch._get_transcoded_request( @@ -859,6 +1090,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.compute_v1.RegionHealthChecksClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._Patch._get_response( self._host, @@ -880,7 +1138,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthChecksClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update( @@ -918,7 +1198,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -930,8 +1210,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: ~.compute.Operation: @@ -958,6 +1240,7 @@ def __call__( http_options = ( _BaseRegionHealthChecksRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = _BaseRegionHealthChecksRestTransport._BaseUpdate._get_transcoded_request( http_options, request @@ -976,6 +1259,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.compute_v1.RegionHealthChecksClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionHealthChecksRestTransport._Update._get_response( self._host, @@ -997,7 +1307,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionHealthChecksClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionHealthChecks", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/client.py index ca845e244c9e..4d9d72a5ed15 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_instance_group_managers import pagers @@ -568,6 +578,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( @@ -636,6 +650,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.compute_v1.RegionInstanceGroupManagersClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "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.compute.v1.RegionInstanceGroupManagers", + "credentialsType": None, + }, + ) + def abandon_instances_unary( self, request: Optional[ @@ -650,7 +687,7 @@ def abandon_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified instances to be immediately removed from the managed instance group. Abandoning an @@ -727,8 +764,10 @@ def sample_abandon_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -819,7 +858,7 @@ def abandon_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified instances to be immediately removed from the managed instance group. Abandoning an @@ -896,8 +935,10 @@ def sample_abandon_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1015,7 +1056,7 @@ def apply_updates_to_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Apply updates to selected instances the managed instance group. @@ -1080,8 +1121,10 @@ def sample_apply_updates_to_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1178,7 +1221,7 @@ def apply_updates_to_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Apply updates to selected instances the managed instance group. @@ -1243,8 +1286,10 @@ def sample_apply_updates_to_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1364,7 +1409,7 @@ def create_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates instances with per-instance configurations in this regional managed instance group. Instances are @@ -1436,8 +1481,10 @@ def sample_create_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1528,7 +1575,7 @@ def create_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates instances with per-instance configurations in this regional managed instance group. Instances are @@ -1600,8 +1647,10 @@ def sample_create_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -1714,7 +1763,7 @@ def delete_unary( instance_group_manager: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified managed instance group and all of the instances in that group. @@ -1774,8 +1823,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1847,7 +1898,7 @@ def delete( instance_group_manager: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified managed instance group and all of the instances in that group. @@ -1907,8 +1958,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -2008,7 +2061,7 @@ def delete_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified instances in the managed instance group to be immediately deleted. The instances are also @@ -2084,8 +2137,10 @@ def sample_delete_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2176,7 +2231,7 @@ def delete_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified instances in the managed instance group to be immediately deleted. The instances are also @@ -2252,8 +2307,10 @@ def sample_delete_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -2371,7 +2428,7 @@ def delete_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Deletes selected per-instance configurations for the managed instance group. @@ -2436,8 +2493,10 @@ def sample_delete_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -2534,7 +2593,7 @@ def delete_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes selected per-instance configurations for the managed instance group. @@ -2599,8 +2658,10 @@ def sample_delete_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -2717,7 +2778,7 @@ def get( instance_group_manager: 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]]] = (), ) -> compute.InstanceGroupManager: r"""Returns all of the details about the specified managed instance group. @@ -2777,8 +2838,10 @@ def sample_get(): 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.compute_v1.types.InstanceGroupManager: @@ -2857,7 +2920,7 @@ def insert_unary( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> compute.Operation: r"""Creates a managed instance group using the information that you specify in the request. After the @@ -2922,8 +2985,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2996,7 +3061,7 @@ def insert( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a managed instance group using the information that you specify in the request. After the @@ -3061,8 +3126,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -3159,7 +3226,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of managed instance groups that are contained within the specified region. @@ -3212,8 +3279,10 @@ def sample_list(): 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.compute_v1.services.region_instance_group_managers.pagers.ListPager: @@ -3296,7 +3365,7 @@ def list_errors( instance_group_manager: 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.ListErrorsPager: r"""Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and @@ -3360,8 +3429,10 @@ def sample_list_errors(): 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.compute_v1.services.region_instance_group_managers.pagers.ListErrorsPager: @@ -3447,7 +3518,7 @@ def list_managed_instances( instance_group_manager: 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.ListManagedInstancesPager: r"""Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current @@ -3512,8 +3583,10 @@ def sample_list_managed_instances(): 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.compute_v1.services.region_instance_group_managers.pagers.ListManagedInstancesPager: @@ -3603,7 +3676,7 @@ def list_per_instance_configs( instance_group_manager: 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.ListPerInstanceConfigsPager: r"""Lists all of the per-instance configurations defined for the managed instance group. The orderBy query @@ -3665,8 +3738,10 @@ def sample_list_per_instance_configs(): 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.compute_v1.services.region_instance_group_managers.pagers.ListPerInstanceConfigsPager: @@ -3757,7 +3832,7 @@ def patch_unary( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> compute.Operation: r"""Updates a managed instance group using the information that you specify in the request. This @@ -3834,8 +3909,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -3914,7 +3991,7 @@ def patch( instance_group_manager_resource: Optional[compute.InstanceGroupManager] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates a managed instance group using the information that you specify in the request. This @@ -3991,8 +4068,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -4100,7 +4179,7 @@ def patch_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name @@ -4167,8 +4246,10 @@ def sample_patch_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -4265,7 +4346,7 @@ def patch_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name @@ -4332,8 +4413,10 @@ def sample_patch_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -4453,7 +4536,7 @@ def recreate_instances_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Flags the specified VM instances in the managed instance group to be immediately recreated. Each @@ -4528,8 +4611,10 @@ def sample_recreate_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -4619,7 +4704,7 @@ def recreate_instances( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Flags the specified VM instances in the managed instance group to be immediately recreated. Each @@ -4694,8 +4779,10 @@ def sample_recreate_instances(): 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.api_core.extended_operation.ExtendedOperation: @@ -4808,7 +4895,7 @@ def resize_unary( size: Optional[int] = 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]]] = (), ) -> compute.Operation: r"""Changes the intended size of the managed instance group. If you increase the size, the group creates new @@ -4885,8 +4972,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -4961,7 +5050,7 @@ def resize( size: Optional[int] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the intended size of the managed instance group. If you increase the size, the group creates new @@ -5038,8 +5127,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -5127,25 +5218,39 @@ def error_code(self): # Done; return the response. return response - def set_instance_template_unary( + def resume_instances_unary( self, request: Optional[ - Union[compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict] + Union[compute.ResumeInstancesRegionInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, region: Optional[str] = None, instance_group_manager: Optional[str] = None, - region_instance_group_managers_set_template_request_resource: Optional[ - compute.RegionInstanceGroupManagersSetTemplateRequest + region_instance_group_managers_resume_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersResumeInstancesRequest ] = 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]]] = (), ) -> compute.Operation: - r"""Sets the instance template to use when creating new - instances or recreating instances in this group. - Existing instances are not affected. + r"""Flags the specified instances in the managed instance + group to be resumed. This method increases the + targetSize and decreases the targetSuspendedSize of the + managed instance group by the number of instances that + you resume. The resumeInstances operation is marked DONE + if the resumeInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the RESUMING action with + the listmanagedinstances method. In this request, you + can only specify instances that are suspended. For + example, if an instance was previously suspended using + the suspendInstances method, it can be resumed using the + resumeInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are resumed. You can + specify a maximum of 1000 instances with this method per + request. .. code-block:: python @@ -5158,27 +5263,27 @@ def set_instance_template_unary( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_instance_template(): + def sample_resume_instances(): # Create a client client = compute_v1.RegionInstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetInstanceTemplateRegionInstanceGroupManagerRequest( + request = compute_v1.ResumeInstancesRegionInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", region="region_value", ) # Make the request - response = client.set_instance_template(request=request) + response = client.resume_instances(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.ResumeInstancesRegionInstanceGroupManagerRequest, dict]): The request object. A request message for - RegionInstanceGroupManagers.SetInstanceTemplate. + RegionInstanceGroupManagers.ResumeInstances. See the method description for details. project (str): Project ID for this request. @@ -5193,22 +5298,22 @@ def sample_set_instance_template(): on the ``request`` instance; if ``request`` is provided, this should not be set. instance_group_manager (str): - The name of the managed instance - group. - + Name of the managed instance group. This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - region_instance_group_managers_set_template_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest): + region_instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersResumeInstancesRequest): The body resource for this request - This corresponds to the ``region_instance_group_managers_set_template_request_resource`` field + This corresponds to the ``region_instance_group_managers_resume_instances_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5224,7 +5329,7 @@ def sample_set_instance_template(): project, region, instance_group_manager, - region_instance_group_managers_set_template_request_resource, + region_instance_group_managers_resume_instances_request_resource, ] ) if request is not None and has_flattened_params: @@ -5236,11 +5341,9 @@ def sample_set_instance_template(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. if not isinstance( - request, compute.SetInstanceTemplateRegionInstanceGroupManagerRequest + request, compute.ResumeInstancesRegionInstanceGroupManagerRequest ): - request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest( - request - ) + request = compute.ResumeInstancesRegionInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5249,14 +5352,17 @@ def sample_set_instance_template(): request.region = region if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if region_instance_group_managers_set_template_request_resource is not None: - request.region_instance_group_managers_set_template_request_resource = ( - region_instance_group_managers_set_template_request_resource + if ( + region_instance_group_managers_resume_instances_request_resource + is not None + ): + request.region_instance_group_managers_resume_instances_request_resource = ( + region_instance_group_managers_resume_instances_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + rpc = self._transport._wrapped_methods[self._transport.resume_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5284,25 +5390,39 @@ def sample_set_instance_template(): # Done; return the response. return response - def set_instance_template( + def resume_instances( self, request: Optional[ - Union[compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict] + Union[compute.ResumeInstancesRegionInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, region: Optional[str] = None, instance_group_manager: Optional[str] = None, - region_instance_group_managers_set_template_request_resource: Optional[ - compute.RegionInstanceGroupManagersSetTemplateRequest + region_instance_group_managers_resume_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersResumeInstancesRequest ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: - r"""Sets the instance template to use when creating new - instances or recreating instances in this group. - Existing instances are not affected. + r"""Flags the specified instances in the managed instance + group to be resumed. This method increases the + targetSize and decreases the targetSuspendedSize of the + managed instance group by the number of instances that + you resume. The resumeInstances operation is marked DONE + if the resumeInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the RESUMING action with + the listmanagedinstances method. In this request, you + can only specify instances that are suspended. For + example, if an instance was previously suspended using + the suspendInstances method, it can be resumed using the + resumeInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are resumed. You can + specify a maximum of 1000 instances with this method per + request. .. code-block:: python @@ -5315,27 +5435,27 @@ def set_instance_template( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_instance_template(): + def sample_resume_instances(): # Create a client client = compute_v1.RegionInstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetInstanceTemplateRegionInstanceGroupManagerRequest( + request = compute_v1.ResumeInstancesRegionInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", region="region_value", ) # Make the request - response = client.set_instance_template(request=request) + response = client.resume_instances(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.ResumeInstancesRegionInstanceGroupManagerRequest, dict]): The request object. A request message for - RegionInstanceGroupManagers.SetInstanceTemplate. + RegionInstanceGroupManagers.ResumeInstances. See the method description for details. project (str): Project ID for this request. @@ -5350,22 +5470,22 @@ def sample_set_instance_template(): on the ``request`` instance; if ``request`` is provided, this should not be set. instance_group_manager (str): - The name of the managed instance - group. - + Name of the managed instance group. This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - region_instance_group_managers_set_template_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest): + region_instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersResumeInstancesRequest): The body resource for this request - This corresponds to the ``region_instance_group_managers_set_template_request_resource`` field + This corresponds to the ``region_instance_group_managers_resume_instances_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5381,7 +5501,7 @@ def sample_set_instance_template(): project, region, instance_group_manager, - region_instance_group_managers_set_template_request_resource, + region_instance_group_managers_resume_instances_request_resource, ] ) if request is not None and has_flattened_params: @@ -5393,11 +5513,9 @@ def sample_set_instance_template(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. if not isinstance( - request, compute.SetInstanceTemplateRegionInstanceGroupManagerRequest + request, compute.ResumeInstancesRegionInstanceGroupManagerRequest ): - request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest( - request - ) + request = compute.ResumeInstancesRegionInstanceGroupManagerRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5406,14 +5524,17 @@ def sample_set_instance_template(): request.region = region if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if region_instance_group_managers_set_template_request_resource is not None: - request.region_instance_group_managers_set_template_request_resource = ( - region_instance_group_managers_set_template_request_resource + if ( + region_instance_group_managers_resume_instances_request_resource + is not None + ): + request.region_instance_group_managers_resume_instances_request_resource = ( + region_instance_group_managers_resume_instances_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + rpc = self._transport._wrapped_methods[self._transport.resume_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5466,25 +5587,25 @@ def error_code(self): # Done; return the response. return response - def set_target_pools_unary( + def set_instance_template_unary( self, request: Optional[ - Union[compute.SetTargetPoolsRegionInstanceGroupManagerRequest, dict] + Union[compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, region: Optional[str] = None, instance_group_manager: Optional[str] = None, - region_instance_group_managers_set_target_pools_request_resource: Optional[ - compute.RegionInstanceGroupManagersSetTargetPoolsRequest + region_instance_group_managers_set_template_request_resource: Optional[ + compute.RegionInstanceGroupManagersSetTemplateRequest ] = 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]]] = (), ) -> compute.Operation: - r"""Modifies the target pools to which all new instances - in this group are assigned. Existing instances in the - group are not affected. + r"""Sets the instance template to use when creating new + instances or recreating instances in this group. + Existing instances are not affected. .. code-block:: python @@ -5497,27 +5618,27 @@ def set_target_pools_unary( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_target_pools(): + def sample_set_instance_template(): # Create a client client = compute_v1.RegionInstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetTargetPoolsRegionInstanceGroupManagerRequest( + request = compute_v1.SetInstanceTemplateRegionInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", region="region_value", ) # Make the request - response = client.set_target_pools(request=request) + response = client.set_instance_template(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict]): The request object. A request message for - RegionInstanceGroupManagers.SetTargetPools. + RegionInstanceGroupManagers.SetInstanceTemplate. See the method description for details. project (str): Project ID for this request. @@ -5532,20 +5653,24 @@ def sample_set_target_pools(): on the ``request`` instance; if ``request`` is provided, this should not be set. instance_group_manager (str): - Name of the managed instance group. + The name of the managed instance + group. + This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - region_instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest): + region_instance_group_managers_set_template_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest): The body resource for this request - This corresponds to the ``region_instance_group_managers_set_target_pools_request_resource`` field + This corresponds to the ``region_instance_group_managers_set_template_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5561,7 +5686,7 @@ def sample_set_target_pools(): project, region, instance_group_manager, - region_instance_group_managers_set_target_pools_request_resource, + region_instance_group_managers_set_template_request_resource, ] ) if request is not None and has_flattened_params: @@ -5573,9 +5698,11 @@ def sample_set_target_pools(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. if not isinstance( - request, compute.SetTargetPoolsRegionInstanceGroupManagerRequest + request, compute.SetInstanceTemplateRegionInstanceGroupManagerRequest ): - request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest(request) + request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest( + request + ) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5584,17 +5711,14 @@ def sample_set_target_pools(): request.region = region if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if ( - region_instance_group_managers_set_target_pools_request_resource - is not None - ): - request.region_instance_group_managers_set_target_pools_request_resource = ( - region_instance_group_managers_set_target_pools_request_resource + if region_instance_group_managers_set_template_request_resource is not None: + request.region_instance_group_managers_set_template_request_resource = ( + region_instance_group_managers_set_template_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + rpc = self._transport._wrapped_methods[self._transport.set_instance_template] # Certain fields should be provided within the metadata header; # add these here. @@ -5622,25 +5746,25 @@ def sample_set_target_pools(): # Done; return the response. return response - def set_target_pools( + def set_instance_template( self, request: Optional[ - Union[compute.SetTargetPoolsRegionInstanceGroupManagerRequest, dict] + Union[compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict] ] = None, *, project: Optional[str] = None, region: Optional[str] = None, instance_group_manager: Optional[str] = None, - region_instance_group_managers_set_target_pools_request_resource: Optional[ - compute.RegionInstanceGroupManagersSetTargetPoolsRequest + region_instance_group_managers_set_template_request_resource: Optional[ + compute.RegionInstanceGroupManagersSetTemplateRequest ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: - r"""Modifies the target pools to which all new instances - in this group are assigned. Existing instances in the - group are not affected. + r"""Sets the instance template to use when creating new + instances or recreating instances in this group. + Existing instances are not affected. .. code-block:: python @@ -5653,27 +5777,27 @@ def set_target_pools( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import compute_v1 - def sample_set_target_pools(): + def sample_set_instance_template(): # Create a client client = compute_v1.RegionInstanceGroupManagersClient() # Initialize request argument(s) - request = compute_v1.SetTargetPoolsRegionInstanceGroupManagerRequest( + request = compute_v1.SetInstanceTemplateRegionInstanceGroupManagerRequest( instance_group_manager="instance_group_manager_value", project="project_value", region="region_value", ) # Make the request - response = client.set_target_pools(request=request) + response = client.set_instance_template(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest, dict]): + request (Union[google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict]): The request object. A request message for - RegionInstanceGroupManagers.SetTargetPools. + RegionInstanceGroupManagers.SetInstanceTemplate. See the method description for details. project (str): Project ID for this request. @@ -5688,20 +5812,24 @@ def sample_set_target_pools(): on the ``request`` instance; if ``request`` is provided, this should not be set. instance_group_manager (str): - Name of the managed instance group. + The name of the managed instance + group. + This corresponds to the ``instance_group_manager`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - region_instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest): + region_instance_group_managers_set_template_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest): The body resource for this request - This corresponds to the ``region_instance_group_managers_set_target_pools_request_resource`` field + This corresponds to the ``region_instance_group_managers_set_template_request_resource`` field on the ``request`` instance; if ``request`` is provided, this should not be set. 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.api_core.extended_operation.ExtendedOperation: @@ -5717,7 +5845,7 @@ def sample_set_target_pools(): project, region, instance_group_manager, - region_instance_group_managers_set_target_pools_request_resource, + region_instance_group_managers_set_template_request_resource, ] ) if request is not None and has_flattened_params: @@ -5729,9 +5857,11 @@ def sample_set_target_pools(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. if not isinstance( - request, compute.SetTargetPoolsRegionInstanceGroupManagerRequest + request, compute.SetInstanceTemplateRegionInstanceGroupManagerRequest ): - request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest(request) + request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest( + request + ) # If we have keyword arguments corresponding to fields on the # request, apply these. if project is not None: @@ -5740,17 +5870,1498 @@ def sample_set_target_pools(): request.region = region if instance_group_manager is not None: request.instance_group_manager = instance_group_manager - if ( - region_instance_group_managers_set_target_pools_request_resource - is not None - ): - request.region_instance_group_managers_set_target_pools_request_resource = ( - region_instance_group_managers_set_target_pools_request_resource + if region_instance_group_managers_set_template_request_resource is not None: + request.region_instance_group_managers_set_template_request_resource = ( + region_instance_group_managers_set_template_request_resource ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + rpc = self._transport._wrapped_methods[self._transport.set_instance_template] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._region_operations_client + operation_request = compute.GetRegionOperationRequest() + operation_request.project = request.project + operation_request.region = request.region + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def set_target_pools_unary( + self, + request: Optional[ + Union[compute.SetTargetPoolsRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_set_target_pools_request_resource: Optional[ + compute.RegionInstanceGroupManagersSetTargetPoolsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Modifies the target pools to which all new instances + in this group are assigned. Existing instances in the + group are not affected. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_target_pools(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SetTargetPoolsRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.set_target_pools(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.SetTargetPools. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_set_target_pools_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_set_target_pools_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.SetTargetPoolsRegionInstanceGroupManagerRequest + ): + request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_set_target_pools_request_resource + is not None + ): + request.region_instance_group_managers_set_target_pools_request_resource = ( + region_instance_group_managers_set_target_pools_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def set_target_pools( + self, + request: Optional[ + Union[compute.SetTargetPoolsRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_set_target_pools_request_resource: Optional[ + compute.RegionInstanceGroupManagersSetTargetPoolsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Modifies the target pools to which all new instances + in this group are assigned. Existing instances in the + group are not affected. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_target_pools(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SetTargetPoolsRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.set_target_pools(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.SetTargetPools. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_set_target_pools_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_set_target_pools_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_set_target_pools_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.SetTargetPoolsRegionInstanceGroupManagerRequest + ): + request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_set_target_pools_request_resource + is not None + ): + request.region_instance_group_managers_set_target_pools_request_resource = ( + region_instance_group_managers_set_target_pools_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_target_pools] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._region_operations_client + operation_request = compute.GetRegionOperationRequest() + operation_request.project = request.project + operation_request.region = request.region + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def start_instances_unary( + self, + request: Optional[ + Union[compute.StartInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_start_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersStartInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be started. This method increases the + targetSize and decreases the targetStoppedSize of the + managed instance group by the number of instances that + you start. The startInstances operation is marked DONE + if the startInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the STARTING action with + the listmanagedinstances method. In this request, you + can only specify instances that are stopped. For + example, if an instance was previously stopped using the + stopInstances method, it can be started using the + startInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are started. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_start_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StartInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.StartInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStartInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_start_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_start_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.StartInstancesRegionInstanceGroupManagerRequest + ): + request = compute.StartInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_start_instances_request_resource + is not None + ): + request.region_instance_group_managers_start_instances_request_resource = ( + region_instance_group_managers_start_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.start_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def start_instances( + self, + request: Optional[ + Union[compute.StartInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_start_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersStartInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be started. This method increases the + targetSize and decreases the targetStoppedSize of the + managed instance group by the number of instances that + you start. The startInstances operation is marked DONE + if the startInstances request is successful. The + underlying actions take additional time. You must + separately verify the status of the STARTING action with + the listmanagedinstances method. In this request, you + can only specify instances that are stopped. For + example, if an instance was previously stopped using the + stopInstances method, it can be started using the + startInstances method. If a health check is attached to + the managed instance group, the specified instances will + be verified as healthy after they are started. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_start_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StartInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.StartInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStartInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_start_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_start_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.StartInstancesRegionInstanceGroupManagerRequest + ): + request = compute.StartInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_start_instances_request_resource + is not None + ): + request.region_instance_group_managers_start_instances_request_resource = ( + region_instance_group_managers_start_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.start_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._region_operations_client + operation_request = compute.GetRegionOperationRequest() + operation_request.project = request.project + operation_request.region = request.region + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def stop_instances_unary( + self, + request: Optional[ + Union[compute.StopInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_stop_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersStopInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be immediately stopped. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetStoppedSize of the managed instance group by the + number of instances that you stop. The stopInstances + operation is marked DONE if the stopInstances request is + successful. The underlying actions take additional time. + You must separately verify the status of the STOPPING + action with the listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays stopping the instances until initialDelaySec have + passed from instance.creationTimestamp (that is, when + the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is stopped. Stopped instances can be started + using the startInstances method. You can specify a + maximum of 1000 instances with this method per request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_stop_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StopInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.StopInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStopInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_stop_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_stop_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.StopInstancesRegionInstanceGroupManagerRequest + ): + request = compute.StopInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_stop_instances_request_resource + is not None + ): + request.region_instance_group_managers_stop_instances_request_resource = ( + region_instance_group_managers_stop_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def stop_instances( + self, + request: Optional[ + Union[compute.StopInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_stop_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersStopInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be immediately stopped. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetStoppedSize of the managed instance group by the + number of instances that you stop. The stopInstances + operation is marked DONE if the stopInstances request is + successful. The underlying actions take additional time. + You must separately verify the status of the STOPPING + action with the listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays stopping the instances until initialDelaySec have + passed from instance.creationTimestamp (that is, when + the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is stopped. Stopped instances can be started + using the startInstances method. You can specify a + maximum of 1000 instances with this method per request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_stop_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.StopInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.StopInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + The name of the managed instance + group. + + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStopInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_stop_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_stop_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.StopInstancesRegionInstanceGroupManagerRequest + ): + request = compute.StopInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_stop_instances_request_resource + is not None + ): + request.region_instance_group_managers_stop_instances_request_resource = ( + region_instance_group_managers_stop_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._region_operations_client + operation_request = compute.GetRegionOperationRequest() + operation_request.project = request.project + operation_request.region = request.region + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + + def suspend_instances_unary( + self, + request: Optional[ + Union[compute.SuspendInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_suspend_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersSuspendInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Flags the specified instances in the managed instance + group to be immediately suspended. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetSuspendedSize of the managed instance group by the + number of instances that you suspend. The + suspendInstances operation is marked DONE if the + suspendInstances request is successful. The underlying + actions take additional time. You must separately verify + the status of the SUSPENDING action with the + listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays suspension of the instances until initialDelaySec + have passed from instance.creationTimestamp (that is, + when the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is suspended. Suspended instances can be + resumed using the resumeInstances method. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_suspend_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SuspendInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.SuspendInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_suspend_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_suspend_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.SuspendInstancesRegionInstanceGroupManagerRequest + ): + request = compute.SuspendInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_suspend_instances_request_resource + is not None + ): + request.region_instance_group_managers_suspend_instances_request_resource = ( + region_instance_group_managers_suspend_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suspend_instances] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("instance_group_manager", request.instance_group_manager), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def suspend_instances( + self, + request: Optional[ + Union[compute.SuspendInstancesRegionInstanceGroupManagerRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + instance_group_manager: Optional[str] = None, + region_instance_group_managers_suspend_instances_request_resource: Optional[ + compute.RegionInstanceGroupManagersSuspendInstancesRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Flags the specified instances in the managed instance + group to be immediately suspended. You can only specify + instances that are running in this request. This method + reduces the targetSize and increases the + targetSuspendedSize of the managed instance group by the + number of instances that you suspend. The + suspendInstances operation is marked DONE if the + suspendInstances request is successful. The underlying + actions take additional time. You must separately verify + the status of the SUSPENDING action with the + listmanagedinstances method. If the + standbyPolicy.initialDelaySec field is set, the group + delays suspension of the instances until initialDelaySec + have passed from instance.creationTimestamp (that is, + when the instance was created). This delay gives your + application time to set itself up and initialize on the + instance. If more than initialDelaySec seconds have + passed since instance.creationTimestamp when this method + is called, there will be zero delay. If the group is + part of a backend service that has enabled connection + draining, it can take up to 60 seconds after the + connection draining duration has elapsed before the VM + instance is suspended. Suspended instances can be + resumed using the resumeInstances method. You can + specify a maximum of 1000 instances with this method per + request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_suspend_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SuspendInstancesRegionInstanceGroupManagerRequest, dict]): + The request object. A request message for + RegionInstanceGroupManagers.SuspendInstances. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + Name of the region scoping this + request. + + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + instance_group_manager (str): + Name of the managed instance group. + This corresponds to the ``instance_group_manager`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + This corresponds to the ``region_instance_group_managers_suspend_instances_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [ + project, + region, + instance_group_manager, + region_instance_group_managers_suspend_instances_request_resource, + ] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.SuspendInstancesRegionInstanceGroupManagerRequest + ): + request = compute.SuspendInstancesRegionInstanceGroupManagerRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if instance_group_manager is not None: + request.instance_group_manager = instance_group_manager + if ( + region_instance_group_managers_suspend_instances_request_resource + is not None + ): + request.region_instance_group_managers_suspend_instances_request_resource = ( + region_instance_group_managers_suspend_instances_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suspend_instances] # Certain fields should be provided within the metadata header; # add these here. @@ -5819,7 +7430,7 @@ def update_per_instance_configs_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name @@ -5886,8 +7497,10 @@ def sample_update_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: @@ -5984,7 +7597,7 @@ def update_per_instance_configs( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name @@ -6051,8 +7664,10 @@ def sample_update_per_instance_configs(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/pagers.py index ba739c2274d1..0bc873bafdb3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/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 = compute.ListRegionInstanceGroupManagersRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListErrorsRegionInstanceGroupManagersRequest(request) @@ -215,7 +219,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. @@ -229,8 +233,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 = compute.ListManagedInstancesRegionInstanceGroupManagersRequest( @@ -295,7 +301,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. @@ -309,8 +315,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 = ( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/base.py index 1e89c42ce33a..1dec531a7ad1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/base.py @@ -213,6 +213,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.resume_instances: gapic_v1.method.wrap_method( + self.resume_instances, + default_timeout=None, + client_info=client_info, + ), self.set_instance_template: gapic_v1.method.wrap_method( self.set_instance_template, default_timeout=None, @@ -223,6 +228,21 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.start_instances: gapic_v1.method.wrap_method( + self.start_instances, + default_timeout=None, + client_info=client_info, + ), + self.stop_instances: gapic_v1.method.wrap_method( + self.stop_instances, + default_timeout=None, + client_info=client_info, + ), + self.suspend_instances: gapic_v1.method.wrap_method( + self.suspend_instances, + default_timeout=None, + client_info=client_info, + ), self.update_per_instance_configs: gapic_v1.method.wrap_method( self.update_per_instance_configs, default_timeout=None, @@ -395,6 +415,15 @@ def resize( ]: raise NotImplementedError() + @property + def resume_instances( + self, + ) -> Callable[ + [compute.ResumeInstancesRegionInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + @property def set_instance_template( self, @@ -413,6 +442,33 @@ def set_target_pools( ]: raise NotImplementedError() + @property + def start_instances( + self, + ) -> Callable[ + [compute.StartInstancesRegionInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + + @property + def stop_instances( + self, + ) -> Callable[ + [compute.StopInstancesRegionInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + + @property + def suspend_instances( + self, + ) -> Callable[ + [compute.SuspendInstancesRegionInstanceGroupManagerRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + @property def update_per_instance_configs( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest.py index 8b9859c987f8..e7fe3883fb5e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/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 @@ -37,6 +37,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, @@ -188,6 +196,14 @@ def post_resize(self, response): logging.log(f"Received response: {response}") return response + def pre_resume_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_resume_instances(self, response): + logging.log(f"Received response: {response}") + return response + def pre_set_instance_template(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -204,6 +220,30 @@ def post_set_target_pools(self, response): logging.log(f"Received response: {response}") return response + def pre_start_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_start_instances(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_stop_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_stop_instances(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_suspend_instances(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_suspend_instances(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_per_instance_configs(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -221,10 +261,10 @@ def post_update_per_instance_configs(self, response): def pre_abandon_instances( self, request: compute.AbandonInstancesRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AbandonInstancesRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for abandon_instances @@ -245,10 +285,10 @@ def post_abandon_instances(self, response: compute.Operation) -> compute.Operati def pre_apply_updates_to_instances( self, request: compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for apply_updates_to_instances @@ -271,10 +311,10 @@ def post_apply_updates_to_instances( def pre_create_instances( self, request: compute.CreateInstancesRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.CreateInstancesRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_instances @@ -295,9 +335,10 @@ def post_create_instances(self, response: compute.Operation) -> compute.Operatio def pre_delete( self, request: compute.DeleteRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteRegionInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.DeleteRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -318,10 +359,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_delete_instances( self, request: compute.DeleteInstancesRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DeleteInstancesRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_instances @@ -342,10 +383,10 @@ def post_delete_instances(self, response: compute.Operation) -> compute.Operatio def pre_delete_per_instance_configs( self, request: compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_per_instance_configs @@ -368,8 +409,11 @@ def post_delete_per_instance_configs( def pre_get( self, request: compute.GetRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionInstanceGroupManagerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -391,9 +435,10 @@ def post_get( def pre_insert( self, request: compute.InsertRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertRegionInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.InsertRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -414,9 +459,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListRegionInstanceGroupManagersRequest, Sequence[Tuple[str, str]] + compute.ListRegionInstanceGroupManagersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -439,9 +485,10 @@ def post_list( def pre_list_errors( self, request: compute.ListErrorsRegionInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListErrorsRegionInstanceGroupManagersRequest, Sequence[Tuple[str, str]] + compute.ListErrorsRegionInstanceGroupManagersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_errors @@ -464,10 +511,10 @@ def post_list_errors( def pre_list_managed_instances( self, request: compute.ListManagedInstancesRegionInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListManagedInstancesRegionInstanceGroupManagersRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_managed_instances @@ -490,10 +537,10 @@ def post_list_managed_instances( def pre_list_per_instance_configs( self, request: compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_per_instance_configs @@ -516,9 +563,10 @@ def post_list_per_instance_configs( def pre_patch( self, request: compute.PatchRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchRegionInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.PatchRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch @@ -539,10 +587,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_per_instance_configs( self, request: compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch_per_instance_configs @@ -565,10 +613,10 @@ def post_patch_per_instance_configs( def pre_recreate_instances( self, request: compute.RecreateInstancesRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.RecreateInstancesRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for recreate_instances @@ -589,9 +637,10 @@ def post_recreate_instances(self, response: compute.Operation) -> compute.Operat def pre_resize( self, request: compute.ResizeRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ResizeRegionInstanceGroupManagerRequest, Sequence[Tuple[str, str]] + compute.ResizeRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for resize @@ -609,13 +658,37 @@ def post_resize(self, response: compute.Operation) -> compute.Operation: """ return response + def pre_resume_instances( + self, + request: compute.ResumeInstancesRegionInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ResumeInstancesRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for resume_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the RegionInstanceGroupManagers server. + """ + return request, metadata + + def post_resume_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for resume_instances + + Override in a subclass to manipulate the response + after it is returned by the RegionInstanceGroupManagers server but before + it is returned to user code. + """ + return response + def pre_set_instance_template( self, request: compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_instance_template @@ -638,10 +711,10 @@ def post_set_instance_template( def pre_set_target_pools( self, request: compute.SetTargetPoolsRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetTargetPoolsRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_target_pools @@ -659,13 +732,85 @@ def post_set_target_pools(self, response: compute.Operation) -> compute.Operatio """ return response + def pre_start_instances( + self, + request: compute.StartInstancesRegionInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StartInstancesRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for start_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the RegionInstanceGroupManagers server. + """ + return request, metadata + + def post_start_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for start_instances + + Override in a subclass to manipulate the response + after it is returned by the RegionInstanceGroupManagers server but before + it is returned to user code. + """ + return response + + def pre_stop_instances( + self, + request: compute.StopInstancesRegionInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.StopInstancesRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for stop_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the RegionInstanceGroupManagers server. + """ + return request, metadata + + def post_stop_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for stop_instances + + Override in a subclass to manipulate the response + after it is returned by the RegionInstanceGroupManagers server but before + it is returned to user code. + """ + return response + + def pre_suspend_instances( + self, + request: compute.SuspendInstancesRegionInstanceGroupManagerRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SuspendInstancesRegionInstanceGroupManagerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for suspend_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the RegionInstanceGroupManagers server. + """ + return request, metadata + + def post_suspend_instances(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for suspend_instances + + Override in a subclass to manipulate the response + after it is returned by the RegionInstanceGroupManagers server but before + it is returned to user code. + """ + return response + def pre_update_per_instance_configs( self, request: compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_per_instance_configs @@ -814,7 +959,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]]] = (), ) -> compute.Operation: r"""Call the abandon instances method over HTTP. @@ -826,8 +971,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: ~.compute.Operation: @@ -854,6 +1001,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseAbandonInstances._get_http_options() ) + request, metadata = self._interceptor.pre_abandon_instances( request, metadata ) @@ -870,6 +1018,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 = 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.compute_v1.RegionInstanceGroupManagersClient.AbandonInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "AbandonInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._AbandonInstances._get_response( self._host, @@ -891,7 +1066,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_abandon_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.abandon_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "AbandonInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApplyUpdatesToInstances( @@ -932,7 +1129,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]]] = (), ) -> compute.Operation: r"""Call the apply updates to instances method over HTTP. @@ -945,8 +1142,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: ~.compute.Operation: @@ -973,6 +1172,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseApplyUpdatesToInstances._get_http_options() ) + request, metadata = self._interceptor.pre_apply_updates_to_instances( request, metadata ) @@ -989,6 +1189,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 = 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.compute_v1.RegionInstanceGroupManagersClient.ApplyUpdatesToInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ApplyUpdatesToInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._ApplyUpdatesToInstances._get_response( self._host, @@ -1010,7 +1237,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_apply_updates_to_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.apply_updates_to_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ApplyUpdatesToInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstances( @@ -1049,7 +1298,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]]] = (), ) -> compute.Operation: r"""Call the create instances method over HTTP. @@ -1061,8 +1310,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: ~.compute.Operation: @@ -1089,6 +1340,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseCreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_create_instances( request, metadata ) @@ -1105,6 +1357,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 = 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.compute_v1.RegionInstanceGroupManagersClient.CreateInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "CreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionInstanceGroupManagersRestTransport._CreateInstances._get_response( @@ -1128,7 +1407,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.create_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "CreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -1166,7 +1467,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1178,8 +1479,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: ~.compute.Operation: @@ -1206,6 +1509,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -1216,6 +1520,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 = 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.compute_v1.RegionInstanceGroupManagersClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._Delete._get_response( self._host, @@ -1236,7 +1567,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstances( @@ -1275,7 +1628,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]]] = (), ) -> compute.Operation: r"""Call the delete instances method over HTTP. @@ -1287,8 +1640,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: ~.compute.Operation: @@ -1315,6 +1670,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseDeleteInstances._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instances( request, metadata ) @@ -1331,6 +1687,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 = 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.compute_v1.RegionInstanceGroupManagersClient.DeleteInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "DeleteInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionInstanceGroupManagersRestTransport._DeleteInstances._get_response( @@ -1354,7 +1737,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.delete_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "DeleteInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePerInstanceConfigs( @@ -1395,7 +1800,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]]] = (), ) -> compute.Operation: r"""Call the delete per instance configs method over HTTP. @@ -1408,8 +1813,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: ~.compute.Operation: @@ -1436,6 +1843,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseDeletePerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_delete_per_instance_configs( request, metadata ) @@ -1452,6 +1860,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 = 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.compute_v1.RegionInstanceGroupManagersClient.DeletePerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "DeletePerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._DeletePerInstanceConfigs._get_response( self._host, @@ -1473,7 +1908,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.delete_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "DeletePerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -1511,7 +1968,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]]] = (), ) -> compute.InstanceGroupManager: r"""Call the get method over HTTP. @@ -1523,8 +1980,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: ~.compute.InstanceGroupManager: @@ -1543,6 +2002,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -1553,6 +2013,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 = 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.compute_v1.RegionInstanceGroupManagersClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._Get._get_response( self._host, @@ -1573,7 +2060,29 @@ def __call__( pb_resp = compute.InstanceGroupManager.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroupManager.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.compute_v1.RegionInstanceGroupManagersClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1612,7 +2121,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1624,8 +2133,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: ~.compute.Operation: @@ -1652,6 +2163,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1666,6 +2178,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 = 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.compute_v1.RegionInstanceGroupManagersClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._Insert._get_response( self._host, @@ -1687,7 +2226,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1725,7 +2286,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]]] = (), ) -> compute.RegionInstanceGroupManagerList: r"""Call the list method over HTTP. @@ -1737,8 +2298,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: ~.compute.RegionInstanceGroupManagerList: @@ -1750,6 +2313,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1760,6 +2324,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 = 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.compute_v1.RegionInstanceGroupManagersClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._List._get_response( self._host, @@ -1780,7 +2371,31 @@ def __call__( pb_resp = compute.RegionInstanceGroupManagerList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionInstanceGroupManagerList.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.compute_v1.RegionInstanceGroupManagersClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListErrors( @@ -1818,7 +2433,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]]] = (), ) -> compute.RegionInstanceGroupManagersListErrorsResponse: r"""Call the list errors method over HTTP. @@ -1830,8 +2445,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: ~.compute.RegionInstanceGroupManagersListErrorsResponse: @@ -1841,6 +2458,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseListErrors._get_http_options() ) + request, metadata = self._interceptor.pre_list_errors(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseListErrors._get_transcoded_request( http_options, request @@ -1851,6 +2469,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 = 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.compute_v1.RegionInstanceGroupManagersClient.ListErrors", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListErrors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionInstanceGroupManagersRestTransport._ListErrors._get_response( @@ -1873,7 +2518,33 @@ def __call__( pb_resp = compute.RegionInstanceGroupManagersListErrorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_errors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.RegionInstanceGroupManagersListErrorsResponse.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.compute_v1.RegionInstanceGroupManagersClient.list_errors", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListErrors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListManagedInstances( @@ -1911,7 +2582,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]]] = (), ) -> compute.RegionInstanceGroupManagersListInstancesResponse: r"""Call the list managed instances method over HTTP. @@ -1923,8 +2594,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: ~.compute.RegionInstanceGroupManagersListInstancesResponse: @@ -1934,6 +2607,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseListManagedInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_managed_instances( request, metadata ) @@ -1946,6 +2620,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 = 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.compute_v1.RegionInstanceGroupManagersClient.ListManagedInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListManagedInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._ListManagedInstances._get_response( self._host, @@ -1966,7 +2667,31 @@ def __call__( pb_resp = compute.RegionInstanceGroupManagersListInstancesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_managed_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionInstanceGroupManagersListInstancesResponse.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.compute_v1.RegionInstanceGroupManagersClient.list_managed_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListManagedInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPerInstanceConfigs( @@ -2006,7 +2731,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]]] = (), ) -> compute.RegionInstanceGroupManagersListInstanceConfigsResp: r"""Call the list per instance configs method over HTTP. @@ -2018,8 +2743,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: ~.compute.RegionInstanceGroupManagersListInstanceConfigsResp: @@ -2029,6 +2756,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseListPerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_per_instance_configs( request, metadata ) @@ -2041,6 +2769,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 = 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.compute_v1.RegionInstanceGroupManagersClient.ListPerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListPerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._ListPerInstanceConfigs._get_response( self._host, @@ -2063,7 +2818,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionInstanceGroupManagersListInstanceConfigsResp.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.compute_v1.RegionInstanceGroupManagersClient.list_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ListPerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -2102,7 +2881,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -2114,8 +2893,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: ~.compute.Operation: @@ -2142,6 +2923,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -2156,6 +2938,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 = 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.compute_v1.RegionInstanceGroupManagersClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._Patch._get_response( self._host, @@ -2177,7 +2986,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchPerInstanceConfigs( @@ -2218,7 +3049,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]]] = (), ) -> compute.Operation: r"""Call the patch per instance configs method over HTTP. @@ -2231,8 +3062,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: ~.compute.Operation: @@ -2259,6 +3092,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BasePatchPerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_patch_per_instance_configs( request, metadata ) @@ -2275,6 +3109,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 = 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.compute_v1.RegionInstanceGroupManagersClient.PatchPerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "PatchPerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._PatchPerInstanceConfigs._get_response( self._host, @@ -2296,7 +3157,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.patch_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "PatchPerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RecreateInstances( @@ -2335,7 +3218,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]]] = (), ) -> compute.Operation: r"""Call the recreate instances method over HTTP. @@ -2347,8 +3230,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: ~.compute.Operation: @@ -2375,6 +3260,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseRecreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_recreate_instances( request, metadata ) @@ -2391,6 +3277,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 = 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.compute_v1.RegionInstanceGroupManagersClient.RecreateInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "RecreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._RecreateInstances._get_response( self._host, @@ -2412,7 +3325,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_recreate_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.recreate_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "RecreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resize( @@ -2450,7 +3385,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]]] = (), ) -> compute.Operation: r"""Call the resize method over HTTP. @@ -2462,8 +3397,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: ~.compute.Operation: @@ -2490,6 +3427,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseResize._get_http_options() ) + request, metadata = self._interceptor.pre_resize(request, metadata) transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseResize._get_transcoded_request( http_options, request @@ -2500,6 +3438,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 = 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.compute_v1.RegionInstanceGroupManagersClient.Resize", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Resize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._Resize._get_response( self._host, @@ -2520,15 +3485,37 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.resize", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "Resize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _SetInstanceTemplate( - _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate, + class _ResumeInstances( + _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances, RegionInstanceGroupManagersRestStub, ): def __hash__(self): - return hash("RegionInstanceGroupManagersRestTransport.SetInstanceTemplate") + return hash("RegionInstanceGroupManagersRestTransport.ResumeInstances") @staticmethod def _get_response( @@ -2555,24 +3542,26 @@ def _get_response( def __call__( self, - request: compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, + request: compute.ResumeInstancesRegionInstanceGroupManagerRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> compute.Operation: - r"""Call the set instance template method over HTTP. + r"""Call the resume instances method over HTTP. Args: - request (~.compute.SetInstanceTemplateRegionInstanceGroupManagerRequest): + request (~.compute.ResumeInstancesRegionInstanceGroupManagerRequest): The request object. A request message for - RegionInstanceGroupManagers.SetInstanceTemplate. + RegionInstanceGroupManagers.ResumeInstances. See the method description for details. 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: ~.compute.Operation: @@ -2597,33 +3586,63 @@ def __call__( """ http_options = ( - _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_http_options() + _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances._get_http_options() ) - request, metadata = self._interceptor.pre_set_instance_template( + + request, metadata = self._interceptor.pre_resume_instances( request, metadata ) - transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_transcoded_request( + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances._get_transcoded_request( http_options, request ) - body = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_request_body_json( + body = _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_query_params_json( + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances._get_query_params_json( 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 = 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.compute_v1.RegionInstanceGroupManagersClient.ResumeInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ResumeInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request - response = RegionInstanceGroupManagersRestTransport._SetInstanceTemplate._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, + response = ( + RegionInstanceGroupManagersRestTransport._ResumeInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2636,15 +3655,37 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_instance_template(resp) + + resp = self._interceptor.post_resume_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.resume_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "ResumeInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _SetTargetPools( - _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools, + class _SetInstanceTemplate( + _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate, RegionInstanceGroupManagersRestStub, ): def __hash__(self): - return hash("RegionInstanceGroupManagersRestTransport.SetTargetPools") + return hash("RegionInstanceGroupManagersRestTransport.SetInstanceTemplate") @staticmethod def _get_response( @@ -2671,24 +3712,26 @@ def _get_response( def __call__( self, - request: compute.SetTargetPoolsRegionInstanceGroupManagerRequest, + request: compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> compute.Operation: - r"""Call the set target pools method over HTTP. + r"""Call the set instance template method over HTTP. Args: - request (~.compute.SetTargetPoolsRegionInstanceGroupManagerRequest): + request (~.compute.SetInstanceTemplateRegionInstanceGroupManagerRequest): The request object. A request message for - RegionInstanceGroupManagers.SetTargetPools. + RegionInstanceGroupManagers.SetInstanceTemplate. See the method description for details. 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: ~.compute.Operation: @@ -2713,27 +3756,223 @@ def __call__( """ http_options = ( - _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_http_options() + _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_http_options() ) - request, metadata = self._interceptor.pre_set_target_pools( + + request, metadata = self._interceptor.pre_set_instance_template( request, metadata ) - transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_transcoded_request( + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_transcoded_request( http_options, request ) - body = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_request_body_json( + body = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_query_params_json( + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseSetInstanceTemplate._get_query_params_json( 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 = 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.compute_v1.RegionInstanceGroupManagersClient.SetInstanceTemplate", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SetInstanceTemplate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request - response = ( - RegionInstanceGroupManagersRestTransport._SetTargetPools._get_response( + response = RegionInstanceGroupManagersRestTransport._SetInstanceTemplate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_set_instance_template(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.set_instance_template", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SetInstanceTemplate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SetTargetPools( + _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools, + RegionInstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("RegionInstanceGroupManagersRestTransport.SetTargetPools") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.SetTargetPoolsRegionInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the set target pools method over HTTP. + + Args: + request (~.compute.SetTargetPoolsRegionInstanceGroupManagerRequest): + The request object. A request message for + RegionInstanceGroupManagers.SetTargetPools. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_http_options() + ) + + request, metadata = self._interceptor.pre_set_target_pools( + request, metadata + ) + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_transcoded_request( + http_options, request + ) + + body = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseSetTargetPools._get_query_params_json( + 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 = 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.compute_v1.RegionInstanceGroupManagersClient.SetTargetPools", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SetTargetPools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + RegionInstanceGroupManagersRestTransport._SetTargetPools._get_response( self._host, metadata, query_params, @@ -2754,7 +3993,533 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_target_pools(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.set_target_pools", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SetTargetPools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _StartInstances( + _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances, + RegionInstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("RegionInstanceGroupManagersRestTransport.StartInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.StartInstancesRegionInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the start instances method over HTTP. + + Args: + request (~.compute.StartInstancesRegionInstanceGroupManagerRequest): + The request object. A request message for + RegionInstanceGroupManagers.StartInstances. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_start_instances(request, metadata) + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances._get_query_params_json( + 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 = 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.compute_v1.RegionInstanceGroupManagersClient.StartInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "StartInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + RegionInstanceGroupManagersRestTransport._StartInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_start_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.start_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "StartInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _StopInstances( + _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances, + RegionInstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("RegionInstanceGroupManagersRestTransport.StopInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.StopInstancesRegionInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the stop instances method over HTTP. + + Args: + request (~.compute.StopInstancesRegionInstanceGroupManagerRequest): + The request object. A request message for + RegionInstanceGroupManagers.StopInstances. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_stop_instances(request, metadata) + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances._get_query_params_json( + 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 = 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.compute_v1.RegionInstanceGroupManagersClient.StopInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "StopInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + RegionInstanceGroupManagersRestTransport._StopInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_stop_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.stop_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "StopInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SuspendInstances( + _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances, + RegionInstanceGroupManagersRestStub, + ): + def __hash__(self): + return hash("RegionInstanceGroupManagersRestTransport.SuspendInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.SuspendInstancesRegionInstanceGroupManagerRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the suspend instances method over HTTP. + + Args: + request (~.compute.SuspendInstancesRegionInstanceGroupManagerRequest): + The request object. A request message for + RegionInstanceGroupManagers.SuspendInstances. + See the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_suspend_instances( + request, metadata + ) + transcoded_request = _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances._get_transcoded_request( + http_options, request + ) + + body = _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances._get_query_params_json( + 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 = 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.compute_v1.RegionInstanceGroupManagersClient.SuspendInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SuspendInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = RegionInstanceGroupManagersRestTransport._SuspendInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_suspend_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.suspend_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "SuspendInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePerInstanceConfigs( @@ -2795,7 +4560,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]]] = (), ) -> compute.Operation: r"""Call the update per instance configs method over HTTP. @@ -2808,8 +4573,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: ~.compute.Operation: @@ -2836,6 +4603,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupManagersRestTransport._BaseUpdatePerInstanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_update_per_instance_configs( request, metadata ) @@ -2852,6 +4620,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 = 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.compute_v1.RegionInstanceGroupManagersClient.UpdatePerInstanceConfigs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "UpdatePerInstanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupManagersRestTransport._UpdatePerInstanceConfigs._get_response( self._host, @@ -2873,7 +4668,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_per_instance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupManagersClient.update_per_instance_configs", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "rpcName": "UpdatePerInstanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3035,6 +4852,16 @@ def resize( # In C++ this would require a dynamic_cast return self._Resize(self._session, self._host, self._interceptor) # type: ignore + @property + def resume_instances( + self, + ) -> Callable[ + [compute.ResumeInstancesRegionInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ResumeInstances(self._session, self._host, self._interceptor) # type: ignore + @property def set_instance_template( self, @@ -3056,6 +4883,36 @@ def set_target_pools( # In C++ this would require a dynamic_cast return self._SetTargetPools(self._session, self._host, self._interceptor) # type: ignore + @property + def start_instances( + self, + ) -> Callable[ + [compute.StartInstancesRegionInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._StartInstances(self._session, self._host, self._interceptor) # type: ignore + + @property + def stop_instances( + self, + ) -> Callable[ + [compute.StopInstancesRegionInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._StopInstances(self._session, self._host, self._interceptor) # type: ignore + + @property + def suspend_instances( + self, + ) -> Callable[ + [compute.SuspendInstancesRegionInstanceGroupManagerRequest], compute.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SuspendInstances(self._session, self._host, self._interceptor) # type: ignore + @property def update_per_instance_configs( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest_base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest_base.py index 09c8a79ed47b..a33a34639202 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest_base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_group_managers/transports/rest_base.py @@ -947,6 +947,64 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseResumeInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/resumeInstances", + "body": "region_instance_group_managers_resume_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.ResumeInstancesRegionInstanceGroupManagerRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseRegionInstanceGroupManagersRestTransport._BaseResumeInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + class _BaseSetInstanceTemplate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1063,6 +1121,180 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseStartInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/startInstances", + "body": "region_instance_group_managers_start_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.StartInstancesRegionInstanceGroupManagerRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseRegionInstanceGroupManagersRestTransport._BaseStartInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + + class _BaseStopInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/stopInstances", + "body": "region_instance_group_managers_stop_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.StopInstancesRegionInstanceGroupManagerRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseRegionInstanceGroupManagersRestTransport._BaseStopInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + + class _BaseSuspendInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/suspendInstances", + "body": "region_instance_group_managers_suspend_instances_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.SuspendInstancesRegionInstanceGroupManagerRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseRegionInstanceGroupManagersRestTransport._BaseSuspendInstances._get_unset_required_fields( + query_params + ) + ) + + return query_params + class _BaseUpdatePerInstanceConfigs: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/client.py index 950e78ff3d06..36fa9df7e915 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_instance_groups import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.RegionInstanceGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "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.compute.v1.RegionInstanceGroups", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetRegionInstanceGroupRequest, dict]] = None, @@ -637,7 +674,7 @@ def get( instance_group: 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]]] = (), ) -> compute.InstanceGroup: r"""Returns the specified instance group resource. @@ -696,8 +733,10 @@ def sample_get(): 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.compute_v1.types.InstanceGroup: @@ -778,7 +817,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of instance group resources contained within the specified region. @@ -831,8 +870,10 @@ def sample_list(): 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.compute_v1.services.region_instance_groups.pagers.ListPager: @@ -918,7 +959,7 @@ def list_instances( ] = 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.ListInstancesPager: r"""Lists the instances in the specified instance group and displays information about the named ports. @@ -987,8 +1028,10 @@ def sample_list_instances(): 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.compute_v1.services.region_instance_groups.pagers.ListInstancesPager: @@ -1086,7 +1129,7 @@ def set_named_ports_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the named ports for the specified regional instance group. @@ -1151,8 +1194,10 @@ def sample_set_named_ports(): 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.api_core.extended_operation.ExtendedOperation: @@ -1238,7 +1283,7 @@ def set_named_ports( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the named ports for the specified regional instance group. @@ -1303,8 +1348,10 @@ def sample_set_named_ports(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/pagers.py index ae3edc33425c..fcd31cd389f0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/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 = compute.ListRegionInstanceGroupsRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListInstancesRegionInstanceGroupsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/transports/rest.py index 7bcbe72c7249..f062136e4df4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_groups/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 @@ -37,6 +37,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, @@ -101,8 +109,10 @@ def post_set_named_ports(self, response): def pre_get( self, request: compute.GetRegionInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionInstanceGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionInstanceGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -122,8 +132,10 @@ def post_get(self, response: compute.InstanceGroup) -> compute.InstanceGroup: def pre_list( self, request: compute.ListRegionInstanceGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionInstanceGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionInstanceGroupsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -145,9 +157,10 @@ def post_list( def pre_list_instances( self, request: compute.ListInstancesRegionInstanceGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListInstancesRegionInstanceGroupsRequest, Sequence[Tuple[str, str]] + compute.ListInstancesRegionInstanceGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_instances @@ -170,9 +183,10 @@ def post_list_instances( def pre_set_named_ports( self, request: compute.SetNamedPortsRegionInstanceGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetNamedPortsRegionInstanceGroupRequest, Sequence[Tuple[str, str]] + compute.SetNamedPortsRegionInstanceGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_named_ports @@ -315,7 +329,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]]] = (), ) -> compute.InstanceGroup: r"""Call the get method over HTTP. @@ -327,8 +341,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: ~.compute.InstanceGroup: @@ -352,6 +368,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionInstanceGroupsRestTransport._BaseGet._get_transcoded_request( @@ -366,6 +383,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.compute_v1.RegionInstanceGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupsRestTransport._Get._get_response( self._host, @@ -386,7 +430,29 @@ def __call__( pb_resp = compute.InstanceGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceGroup.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.compute_v1.RegionInstanceGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -423,7 +489,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]]] = (), ) -> compute.RegionInstanceGroupList: r"""Call the list method over HTTP. @@ -435,8 +501,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: ~.compute.RegionInstanceGroupList: @@ -448,6 +516,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionInstanceGroupsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -460,6 +529,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.compute_v1.RegionInstanceGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupsRestTransport._List._get_response( self._host, @@ -480,7 +576,29 @@ def __call__( pb_resp = compute.RegionInstanceGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionInstanceGroupList.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.compute_v1.RegionInstanceGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -519,7 +637,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]]] = (), ) -> compute.RegionInstanceGroupsListInstances: r"""Call the list instances method over HTTP. @@ -531,8 +649,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: ~.compute.RegionInstanceGroupsListInstances: @@ -542,6 +662,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupsRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseRegionInstanceGroupsRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -556,6 +677,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 = 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.compute_v1.RegionInstanceGroupsClient.ListInstances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupsRestTransport._ListInstances._get_response( self._host, @@ -577,7 +725,31 @@ def __call__( pb_resp = compute.RegionInstanceGroupsListInstances.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_instances(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.RegionInstanceGroupsListInstances.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.compute_v1.RegionInstanceGroupsClient.list_instances", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetNamedPorts( @@ -616,7 +788,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]]] = (), ) -> compute.Operation: r"""Call the set named ports method over HTTP. @@ -628,8 +800,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: ~.compute.Operation: @@ -656,6 +830,7 @@ def __call__( http_options = ( _BaseRegionInstanceGroupsRestTransport._BaseSetNamedPorts._get_http_options() ) + request, metadata = self._interceptor.pre_set_named_ports(request, metadata) transcoded_request = _BaseRegionInstanceGroupsRestTransport._BaseSetNamedPorts._get_transcoded_request( http_options, request @@ -670,6 +845,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 = 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.compute_v1.RegionInstanceGroupsClient.SetNamedPorts", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "SetNamedPorts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceGroupsRestTransport._SetNamedPorts._get_response( self._host, @@ -691,7 +893,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_named_ports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceGroupsClient.set_named_ports", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceGroups", + "rpcName": "SetNamedPorts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/client.py index 0bf07cbc064a..1e08b1bda2d8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_instance_templates import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.RegionInstanceTemplatesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "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.compute.v1.RegionInstanceTemplates", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -643,7 +680,7 @@ def delete_unary( instance_template: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. @@ -703,8 +740,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -776,7 +815,7 @@ def delete( instance_template: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. @@ -836,8 +875,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -932,7 +973,7 @@ def get( instance_template: 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]]] = (), ) -> compute.InstanceTemplate: r"""Returns the specified instance template. @@ -989,8 +1030,10 @@ def sample_get(): 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.compute_v1.types.InstanceTemplate: @@ -1073,7 +1116,7 @@ def insert_unary( instance_template_resource: Optional[compute.InstanceTemplate] = 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]]] = (), ) -> compute.Operation: r"""Creates an instance template in the specified project and region using the global instance template whose URL @@ -1131,8 +1174,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1203,7 +1248,7 @@ def insert( instance_template_resource: Optional[compute.InstanceTemplate] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instance template in the specified project and region using the global instance template whose URL @@ -1261,8 +1306,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1357,7 +1404,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of instance templates that are contained within the specified project and region. @@ -1410,8 +1457,10 @@ def sample_list(): 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.compute_v1.services.region_instance_templates.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/pagers.py index 752463084743..86569b012192 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/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 = compute.ListRegionInstanceTemplatesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/transports/rest.py index 81471583e3b9..f7ddf7d8fe5a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instance_templates/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 @@ -37,6 +37,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, @@ -101,8 +109,11 @@ def post_list(self, response): def pre_delete( self, request: compute.DeleteRegionInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -122,8 +133,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -143,8 +157,11 @@ def post_get(self, response: compute.InstanceTemplate) -> compute.InstanceTempla def pre_insert( self, request: compute.InsertRegionInstanceTemplateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionInstanceTemplateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionInstanceTemplateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -164,8 +181,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionInstanceTemplatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionInstanceTemplatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionInstanceTemplatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -310,7 +330,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -322,8 +342,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: ~.compute.Operation: @@ -350,6 +372,7 @@ def __call__( http_options = ( _BaseRegionInstanceTemplatesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionInstanceTemplatesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -360,6 +383,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 = 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.compute_v1.RegionInstanceTemplatesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceTemplatesRestTransport._Delete._get_response( self._host, @@ -380,7 +430,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceTemplatesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -418,7 +490,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]]] = (), ) -> compute.InstanceTemplate: r"""Call the get method over HTTP. @@ -430,8 +502,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: ~.compute.InstanceTemplate: @@ -454,6 +528,7 @@ def __call__( http_options = ( _BaseRegionInstanceTemplatesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionInstanceTemplatesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -464,6 +539,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 = 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.compute_v1.RegionInstanceTemplatesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceTemplatesRestTransport._Get._get_response( self._host, @@ -484,7 +586,29 @@ def __call__( pb_resp = compute.InstanceTemplate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceTemplate.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.compute_v1.RegionInstanceTemplatesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -523,7 +647,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -535,8 +659,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: ~.compute.Operation: @@ -563,6 +689,7 @@ def __call__( http_options = ( _BaseRegionInstanceTemplatesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionInstanceTemplatesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -577,6 +704,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 = 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.compute_v1.RegionInstanceTemplatesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceTemplatesRestTransport._Insert._get_response( self._host, @@ -598,7 +752,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstanceTemplatesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -636,7 +812,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]]] = (), ) -> compute.InstanceTemplateList: r"""Call the list method over HTTP. @@ -648,8 +824,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: ~.compute.InstanceTemplateList: @@ -659,6 +837,7 @@ def __call__( http_options = ( _BaseRegionInstanceTemplatesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionInstanceTemplatesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -669,6 +848,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 = 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.compute_v1.RegionInstanceTemplatesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstanceTemplatesRestTransport._List._get_response( self._host, @@ -689,7 +895,29 @@ def __call__( pb_resp = compute.InstanceTemplateList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstanceTemplateList.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.compute_v1.RegionInstanceTemplatesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstanceTemplates", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/client.py index 4a6f14f42ab0..f039c6e48b98 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.types import compute @@ -559,6 +569,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( @@ -624,6 +638,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.compute_v1.RegionInstancesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstances", + "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.compute.v1.RegionInstances", + "credentialsType": None, + }, + ) + def bulk_insert_unary( self, request: Optional[Union[compute.BulkInsertRegionInstanceRequest, dict]] = None, @@ -635,7 +672,7 @@ def bulk_insert_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Creates multiple instances in a given region. Count specifies the number of instances to create. @@ -692,8 +729,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -768,7 +807,7 @@ def bulk_insert( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates multiple instances in a given region. Count specifies the number of instances to create. @@ -825,8 +864,10 @@ def sample_bulk_insert(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/transports/rest.py index a217c671759c..5500d15a738b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instances/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 @@ -37,6 +37,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, @@ -77,8 +85,10 @@ def post_bulk_insert(self, response): def pre_bulk_insert( self, request: compute.BulkInsertRegionInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.BulkInsertRegionInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.BulkInsertRegionInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for bulk_insert Override in a subclass to manipulate the request or metadata @@ -221,7 +231,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]]] = (), ) -> compute.Operation: r"""Call the bulk insert method over HTTP. @@ -233,8 +243,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: ~.compute.Operation: @@ -261,6 +273,7 @@ def __call__( http_options = ( _BaseRegionInstancesRestTransport._BaseBulkInsert._get_http_options() ) + request, metadata = self._interceptor.pre_bulk_insert(request, metadata) transcoded_request = _BaseRegionInstancesRestTransport._BaseBulkInsert._get_transcoded_request( http_options, request @@ -275,6 +288,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 = 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.compute_v1.RegionInstancesClient.BulkInsert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstances", + "rpcName": "BulkInsert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstancesRestTransport._BulkInsert._get_response( self._host, @@ -296,7 +336,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstancesClient.bulk_insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstances", + "rpcName": "BulkInsert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/client.py index 9e92d404c9b6..0fa5694874c2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_instant_snapshots import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.RegionInstantSnapshotsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "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.compute.v1.RegionInstantSnapshots", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -641,7 +678,7 @@ def delete_unary( instant_snapshot: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified InstantSnapshot resource. Keep in mind that deleting a single instantSnapshot might not @@ -707,8 +744,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -780,7 +819,7 @@ def delete( instant_snapshot: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified InstantSnapshot resource. Keep in mind that deleting a single instantSnapshot might not @@ -846,8 +885,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -942,7 +983,7 @@ def get( instant_snapshot: 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]]] = (), ) -> compute.InstantSnapshot: r"""Returns the specified InstantSnapshot resource in the specified region. @@ -1002,8 +1043,10 @@ def sample_get(): 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.compute_v1.types.InstantSnapshot: @@ -1076,7 +1119,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1136,8 +1179,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.cloud.compute_v1.types.Policy: @@ -1229,7 +1274,7 @@ def insert_unary( instant_snapshot_resource: Optional[compute.InstantSnapshot] = 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]]] = (), ) -> compute.Operation: r"""Creates an instant snapshot in the specified region. @@ -1283,8 +1328,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1355,7 +1402,7 @@ def insert( instant_snapshot_resource: Optional[compute.InstantSnapshot] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates an instant snapshot in the specified region. @@ -1409,8 +1456,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1505,7 +1554,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of InstantSnapshot resources contained within the specified region. @@ -1558,8 +1607,10 @@ def sample_list(): 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.compute_v1.services.region_instant_snapshots.pagers.ListPager: @@ -1645,7 +1696,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1710,8 +1761,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.cloud.compute_v1.types.Policy: @@ -1812,7 +1865,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a instantSnapshot in the given region. To learn more about labels, read the Labeling @@ -1876,8 +1929,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1958,7 +2013,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a instantSnapshot in the given region. To learn more about labels, read the Labeling @@ -2022,8 +2077,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2129,7 +2186,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2194,8 +2251,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/pagers.py index c8fbc9a378da..5112128b5fb3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/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 = compute.ListRegionInstantSnapshotsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/transports/rest.py index fac0aa6b5d90..ce8ab0084d53 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_instant_snapshots/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 @@ -37,6 +37,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, @@ -133,8 +141,11 @@ def post_test_iam_permissions(self, response): def pre_delete( self, request: compute.DeleteRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -154,8 +165,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionInstantSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -175,9 +188,10 @@ def post_get(self, response: compute.InstantSnapshot) -> compute.InstantSnapshot def pre_get_iam_policy( self, request: compute.GetIamPolicyRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetIamPolicyRegionInstantSnapshotRequest, Sequence[Tuple[str, str]] + compute.GetIamPolicyRegionInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_iam_policy @@ -198,8 +212,11 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionInstantSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -219,8 +236,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionInstantSnapshotsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionInstantSnapshotsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionInstantSnapshotsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -242,9 +262,10 @@ def post_list( def pre_set_iam_policy( self, request: compute.SetIamPolicyRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetIamPolicyRegionInstantSnapshotRequest, Sequence[Tuple[str, str]] + compute.SetIamPolicyRegionInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_iam_policy @@ -265,9 +286,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetLabelsRegionInstantSnapshotRequest, Sequence[Tuple[str, str]] + compute.SetLabelsRegionInstantSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_labels @@ -288,10 +310,10 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsRegionInstantSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.TestIamPermissionsRegionInstantSnapshotRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -437,7 +459,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -449,8 +471,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: ~.compute.Operation: @@ -477,6 +501,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -487,6 +512,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 = 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.compute_v1.RegionInstantSnapshotsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._Delete._get_response( self._host, @@ -507,7 +559,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstantSnapshotsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -545,7 +619,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]]] = (), ) -> compute.InstantSnapshot: r"""Call the get method over HTTP. @@ -557,8 +631,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: ~.compute.InstantSnapshot: @@ -571,6 +647,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -581,6 +658,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 = 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.compute_v1.RegionInstantSnapshotsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._Get._get_response( self._host, @@ -601,7 +705,29 @@ def __call__( pb_resp = compute.InstantSnapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstantSnapshot.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.compute_v1.RegionInstantSnapshotsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -639,7 +765,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -651,8 +777,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: ~.compute.Policy: @@ -685,6 +813,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -695,6 +824,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 = 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.compute_v1.RegionInstantSnapshotsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._GetIamPolicy._get_response( self._host, @@ -715,7 +871,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionInstantSnapshotsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -754,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -766,8 +944,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: ~.compute.Operation: @@ -794,6 +974,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -808,6 +989,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 = 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.compute_v1.RegionInstantSnapshotsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._Insert._get_response( self._host, @@ -829,7 +1037,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstantSnapshotsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -867,7 +1097,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]]] = (), ) -> compute.InstantSnapshotList: r"""Call the list method over HTTP. @@ -879,8 +1109,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: ~.compute.InstantSnapshotList: @@ -892,6 +1124,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -902,6 +1135,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 = 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.compute_v1.RegionInstantSnapshotsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._List._get_response( self._host, @@ -922,7 +1182,29 @@ def __call__( pb_resp = compute.InstantSnapshotList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.InstantSnapshotList.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.compute_v1.RegionInstantSnapshotsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -961,7 +1243,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -973,8 +1255,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: ~.compute.Policy: @@ -1007,6 +1291,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1021,6 +1306,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 = 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.compute_v1.RegionInstantSnapshotsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._SetIamPolicy._get_response( self._host, @@ -1042,7 +1354,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionInstantSnapshotsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1081,7 +1415,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1093,8 +1427,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: ~.compute.Operation: @@ -1121,6 +1457,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseRegionInstantSnapshotsRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -1135,6 +1472,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 = 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.compute_v1.RegionInstantSnapshotsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionInstantSnapshotsRestTransport._SetLabels._get_response( self._host, @@ -1156,7 +1520,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionInstantSnapshotsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1195,7 +1581,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1207,8 +1593,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: ~.compute.TestPermissionsResponse: @@ -1218,6 +1606,7 @@ def __call__( http_options = ( _BaseRegionInstantSnapshotsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1234,6 +1623,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 = 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.compute_v1.RegionInstantSnapshotsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionInstantSnapshotsRestTransport._TestIamPermissions._get_response( @@ -1257,7 +1673,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.RegionInstantSnapshotsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionInstantSnapshots", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/client.py index 1ad24a848865..dbce8049e4a0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_network_endpoint_groups import pagers @@ -568,6 +578,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( @@ -636,6 +650,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.compute_v1.RegionNetworkEndpointGroupsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "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.compute.v1.RegionNetworkEndpointGroups", + "credentialsType": None, + }, + ) + def attach_network_endpoints_unary( self, request: Optional[ @@ -650,7 +687,7 @@ def attach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Attach a list of network endpoints to the specified network endpoint group. @@ -718,8 +755,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -812,7 +851,7 @@ def attach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Attach a list of network endpoints to the specified network endpoint group. @@ -880,8 +919,10 @@ def sample_attach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -996,7 +1037,7 @@ def delete_unary( network_endpoint_group: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a @@ -1059,8 +1100,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1132,7 +1175,7 @@ def delete( network_endpoint_group: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a @@ -1195,8 +1238,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1296,7 +1341,7 @@ def detach_network_endpoints_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Detach the network endpoint from the specified network endpoint group. @@ -1364,8 +1409,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1458,7 +1505,7 @@ def detach_network_endpoints( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Detach the network endpoint from the specified network endpoint group. @@ -1526,8 +1573,10 @@ def sample_detach_network_endpoints(): 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.api_core.extended_operation.ExtendedOperation: @@ -1642,7 +1691,7 @@ def get( network_endpoint_group: 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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Returns the specified network endpoint group. @@ -1702,8 +1751,10 @@ def sample_get(): 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.compute_v1.types.NetworkEndpointGroup: @@ -1781,7 +1832,7 @@ def insert_unary( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> compute.Operation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -1840,8 +1891,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1914,7 +1967,7 @@ def insert( network_endpoint_group_resource: Optional[compute.NetworkEndpointGroup] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a network endpoint group in the specified project using the parameters that are included in the @@ -1973,8 +2026,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2071,7 +2126,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of regional network endpoint groups available to the specified project in the given @@ -2126,8 +2181,10 @@ def sample_list(): 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.compute_v1.services.region_network_endpoint_groups.pagers.ListPager: @@ -2208,7 +2265,7 @@ def list_network_endpoints( network_endpoint_group: 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.ListNetworkEndpointsPager: r"""Lists the network endpoints in the specified network endpoint group. @@ -2272,8 +2329,10 @@ def sample_list_network_endpoints(): 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.compute_v1.services.region_network_endpoint_groups.pagers.ListNetworkEndpointsPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/pagers.py index e7a26890732f..0902784ad407 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/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 = compute.ListRegionNetworkEndpointGroupsRequest(request) @@ -141,7 +143,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. @@ -155,8 +157,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 = compute.ListNetworkEndpointsRegionNetworkEndpointGroupsRequest( diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/transports/rest.py index 2baa65e1b9d6..caf1f7fbe745 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_endpoint_groups/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 @@ -37,6 +37,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, @@ -125,10 +133,10 @@ def post_list_network_endpoints(self, response): def pre_attach_network_endpoints( self, request: compute.AttachNetworkEndpointsRegionNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AttachNetworkEndpointsRegionNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for attach_network_endpoints @@ -151,9 +159,10 @@ def post_attach_network_endpoints( def pre_delete( self, request: compute.DeleteRegionNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteRegionNetworkEndpointGroupRequest, Sequence[Tuple[str, str]] + compute.DeleteRegionNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -174,10 +183,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_detach_network_endpoints( self, request: compute.DetachNetworkEndpointsRegionNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.DetachNetworkEndpointsRegionNetworkEndpointGroupRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for detach_network_endpoints @@ -200,8 +209,11 @@ def post_detach_network_endpoints( def pre_get( self, request: compute.GetRegionNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionNetworkEndpointGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -223,9 +235,10 @@ def post_get( def pre_insert( self, request: compute.InsertRegionNetworkEndpointGroupRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertRegionNetworkEndpointGroupRequest, Sequence[Tuple[str, str]] + compute.InsertRegionNetworkEndpointGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -246,9 +259,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListRegionNetworkEndpointGroupsRequest, Sequence[Tuple[str, str]] + compute.ListRegionNetworkEndpointGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -271,10 +285,10 @@ def post_list( def pre_list_network_endpoints( self, request: compute.ListNetworkEndpointsRegionNetworkEndpointGroupsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListNetworkEndpointsRegionNetworkEndpointGroupsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_network_endpoints @@ -425,7 +439,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]]] = (), ) -> compute.Operation: r"""Call the attach network endpoints method over HTTP. @@ -437,8 +451,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: ~.compute.Operation: @@ -465,6 +481,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseAttachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_attach_network_endpoints( request, metadata ) @@ -481,6 +498,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.AttachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._AttachNetworkEndpoints._get_response( self._host, @@ -502,7 +546,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_attach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkEndpointGroupsClient.attach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "AttachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -540,7 +606,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -552,8 +618,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: ~.compute.Operation: @@ -580,6 +648,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionNetworkEndpointGroupsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -590,6 +659,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._Delete._get_response( self._host, @@ -610,7 +706,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkEndpointGroupsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetachNetworkEndpoints( @@ -651,7 +769,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]]] = (), ) -> compute.Operation: r"""Call the detach network endpoints method over HTTP. @@ -663,8 +781,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: ~.compute.Operation: @@ -691,6 +811,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseDetachNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_detach_network_endpoints( request, metadata ) @@ -707,6 +828,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.DetachNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._DetachNetworkEndpoints._get_response( self._host, @@ -728,7 +876,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkEndpointGroupsClient.detach_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "DetachNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -766,7 +936,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]]] = (), ) -> compute.NetworkEndpointGroup: r"""Call the get method over HTTP. @@ -778,8 +948,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: ~.compute.NetworkEndpointGroup: @@ -797,6 +969,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionNetworkEndpointGroupsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -807,6 +980,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._Get._get_response( self._host, @@ -827,7 +1027,29 @@ def __call__( pb_resp = compute.NetworkEndpointGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroup.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.compute_v1.RegionNetworkEndpointGroupsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -866,7 +1088,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -878,8 +1100,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: ~.compute.Operation: @@ -906,6 +1130,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionNetworkEndpointGroupsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -920,6 +1145,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._Insert._get_response( self._host, @@ -941,7 +1193,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkEndpointGroupsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -979,7 +1253,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]]] = (), ) -> compute.NetworkEndpointGroupList: r"""Call the list method over HTTP. @@ -991,8 +1265,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: ~.compute.NetworkEndpointGroupList: @@ -1002,6 +1278,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionNetworkEndpointGroupsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1012,6 +1289,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._List._get_response( self._host, @@ -1032,7 +1336,31 @@ def __call__( pb_resp = compute.NetworkEndpointGroupList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NetworkEndpointGroupList.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.compute_v1.RegionNetworkEndpointGroupsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkEndpoints( @@ -1070,7 +1398,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]]] = (), ) -> compute.NetworkEndpointGroupsListNetworkEndpoints: r"""Call the list network endpoints method over HTTP. @@ -1082,8 +1410,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: ~.compute.NetworkEndpointGroupsListNetworkEndpoints: @@ -1093,6 +1423,7 @@ def __call__( http_options = ( _BaseRegionNetworkEndpointGroupsRestTransport._BaseListNetworkEndpoints._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_endpoints( request, metadata ) @@ -1105,6 +1436,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 = 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.compute_v1.RegionNetworkEndpointGroupsClient.ListNetworkEndpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkEndpointGroupsRestTransport._ListNetworkEndpoints._get_response( self._host, @@ -1125,7 +1483,33 @@ def __call__( pb_resp = compute.NetworkEndpointGroupsListNetworkEndpoints.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_endpoints(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkEndpointGroupsListNetworkEndpoints.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.compute_v1.RegionNetworkEndpointGroupsClient.list_network_endpoints", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkEndpointGroups", + "rpcName": "ListNetworkEndpoints", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/client.py index 84de4e030a39..0fe4acd9ec43 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_network_firewall_policies import pagers @@ -570,6 +580,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( @@ -640,6 +654,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.compute_v1.RegionNetworkFirewallPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "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.compute.v1.RegionNetworkFirewallPolicies", + "credentialsType": None, + }, + ) + def add_association_unary( self, request: Optional[ @@ -654,7 +691,7 @@ def add_association_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Inserts an association for the specified network firewall policy. @@ -719,8 +756,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -803,7 +842,7 @@ def add_association( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts an association for the specified network firewall policy. @@ -868,8 +907,10 @@ def sample_add_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -975,7 +1016,7 @@ def add_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Inserts a rule into a network firewall policy. @@ -1039,8 +1080,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1117,7 +1160,7 @@ def add_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts a rule into a network firewall policy. @@ -1181,8 +1224,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -1283,7 +1328,7 @@ def clone_rules_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Copies rules to the specified network firewall policy. @@ -1343,8 +1388,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1418,7 +1465,7 @@ def clone_rules( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Copies rules to the specified network firewall policy. @@ -1478,8 +1525,10 @@ def sample_clone_rules(): 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.api_core.extended_operation.ExtendedOperation: @@ -1578,7 +1627,7 @@ def delete_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified network firewall policy. @@ -1637,8 +1686,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1710,7 +1761,7 @@ def delete( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified network firewall policy. @@ -1769,8 +1820,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1867,7 +1920,7 @@ def get( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicy: r"""Returns the specified network firewall policy. @@ -1924,8 +1977,10 @@ def sample_get(): 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.compute_v1.types.FirewallPolicy: @@ -1997,7 +2052,7 @@ def get_association( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Gets an association with the specified name. @@ -2056,8 +2111,10 @@ def sample_get_association(): 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.compute_v1.types.FirewallPolicyAssociation: @@ -2129,7 +2186,7 @@ def get_effective_firewalls( network: 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]]] = (), ) -> compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse: r"""Returns the effective firewalls on a given network. @@ -2186,8 +2243,10 @@ def sample_get_effective_firewalls(): 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.compute_v1.types.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse: @@ -2260,7 +2319,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -2320,8 +2379,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.cloud.compute_v1.types.Policy: @@ -2415,7 +2476,7 @@ def get_rule( firewall_policy: 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]]] = (), ) -> compute.FirewallPolicyRule: r"""Gets a rule of the specified priority. @@ -2474,8 +2535,10 @@ def sample_get_rule(): 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.compute_v1.types.FirewallPolicyRule: @@ -2549,7 +2612,7 @@ def insert_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new network firewall policy in the specified project and region. @@ -2606,8 +2669,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2678,7 +2743,7 @@ def insert( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new network firewall policy in the specified project and region. @@ -2735,8 +2800,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2831,7 +2898,7 @@ def list( region: 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.ListPager: r"""Lists all the network firewall policies that have been configured for the specified project in the given @@ -2885,8 +2952,10 @@ def sample_list(): 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.compute_v1.services.region_network_firewall_policies.pagers.ListPager: @@ -2968,7 +3037,7 @@ def patch_unary( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified network firewall policy. @@ -3032,8 +3101,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -3110,7 +3181,7 @@ def patch( firewall_policy_resource: Optional[compute.FirewallPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified network firewall policy. @@ -3174,8 +3245,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -3277,7 +3350,7 @@ def patch_rule_unary( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Patches a rule of the specified priority. @@ -3341,8 +3414,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3419,7 +3494,7 @@ def patch_rule( firewall_policy_rule_resource: Optional[compute.FirewallPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches a rule of the specified priority. @@ -3483,8 +3558,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -3585,7 +3662,7 @@ def remove_association_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Removes an association for the specified network firewall policy. @@ -3645,8 +3722,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3722,7 +3801,7 @@ def remove_association( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes an association for the specified network firewall policy. @@ -3782,8 +3861,10 @@ def sample_remove_association(): 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.api_core.extended_operation.ExtendedOperation: @@ -3884,7 +3965,7 @@ def remove_rule_unary( firewall_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes a rule of the specified priority. @@ -3943,8 +4024,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -4018,7 +4101,7 @@ def remove_rule( firewall_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a rule of the specified priority. @@ -4077,8 +4160,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -4180,7 +4265,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -4245,8 +4330,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.cloud.compute_v1.types.Policy: @@ -4349,7 +4436,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -4414,8 +4501,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/pagers.py index 19263f0d316c..ffd515f297dd 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/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 = compute.ListRegionNetworkFirewallPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/transports/rest.py index 34e5f93c8159..fd6aa01c219f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_network_firewall_policies/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 @@ -37,6 +37,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, @@ -205,10 +213,10 @@ def post_test_iam_permissions(self, response): def pre_add_association( self, request: compute.AddAssociationRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.AddAssociationRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_association @@ -229,9 +237,10 @@ def post_add_association(self, response: compute.Operation) -> compute.Operation def pre_add_rule( self, request: compute.AddRuleRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AddRuleRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.AddRuleRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for add_rule @@ -252,9 +261,10 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: def pre_clone_rules( self, request: compute.CloneRulesRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.CloneRulesRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.CloneRulesRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for clone_rules @@ -275,9 +285,10 @@ def post_clone_rules(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.DeleteRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -298,9 +309,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.GetRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get @@ -321,10 +333,10 @@ def post_get(self, response: compute.FirewallPolicy) -> compute.FirewallPolicy: def pre_get_association( self, request: compute.GetAssociationRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.GetAssociationRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_association @@ -347,10 +359,10 @@ def post_get_association( def pre_get_effective_firewalls( self, request: compute.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_effective_firewalls @@ -374,10 +386,10 @@ def post_get_effective_firewalls( def pre_get_iam_policy( self, request: compute.GetIamPolicyRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.GetIamPolicyRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_iam_policy @@ -398,9 +410,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_get_rule( self, request: compute.GetRuleRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.GetRuleRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.GetRuleRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_rule @@ -423,9 +436,10 @@ def post_get_rule( def pre_insert( self, request: compute.InsertRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.InsertRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -446,9 +460,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionNetworkFirewallPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListRegionNetworkFirewallPoliciesRequest, Sequence[Tuple[str, str]] + compute.ListRegionNetworkFirewallPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -471,9 +486,10 @@ def post_list( def pre_patch( self, request: compute.PatchRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.PatchRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch @@ -494,9 +510,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_rule( self, request: compute.PatchRuleRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.PatchRuleRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.PatchRuleRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for patch_rule @@ -517,10 +534,10 @@ def post_patch_rule(self, response: compute.Operation) -> compute.Operation: def pre_remove_association( self, request: compute.RemoveAssociationRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.RemoveAssociationRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_association @@ -541,9 +558,10 @@ def post_remove_association(self, response: compute.Operation) -> compute.Operat def pre_remove_rule( self, request: compute.RemoveRuleRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveRuleRegionNetworkFirewallPolicyRequest, Sequence[Tuple[str, str]] + compute.RemoveRuleRegionNetworkFirewallPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_rule @@ -564,10 +582,10 @@ def post_remove_rule(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetIamPolicyRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_iam_policy @@ -588,10 +606,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsRegionNetworkFirewallPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.TestIamPermissionsRegionNetworkFirewallPolicyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -742,7 +760,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]]] = (), ) -> compute.Operation: r"""Call the add association method over HTTP. @@ -754,8 +772,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: ~.compute.Operation: @@ -782,6 +802,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseAddAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_add_association(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseAddAssociation._get_transcoded_request( http_options, request @@ -796,6 +817,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.AddAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "AddAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._AddAssociation._get_response( self._host, @@ -817,7 +865,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.add_association", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "AddAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddRule( @@ -856,7 +926,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]]] = (), ) -> compute.Operation: r"""Call the add rule method over HTTP. @@ -868,8 +938,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: ~.compute.Operation: @@ -896,6 +968,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseAddRule._get_http_options() ) + request, metadata = self._interceptor.pre_add_rule(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseAddRule._get_transcoded_request( http_options, request @@ -910,6 +983,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.AddRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "AddRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._AddRule._get_response( @@ -933,7 +1033,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.add_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "AddRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CloneRules( @@ -971,7 +1093,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]]] = (), ) -> compute.Operation: r"""Call the clone rules method over HTTP. @@ -983,8 +1105,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: ~.compute.Operation: @@ -1011,6 +1135,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseCloneRules._get_http_options() ) + request, metadata = self._interceptor.pre_clone_rules(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseCloneRules._get_transcoded_request( http_options, request @@ -1021,6 +1146,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.CloneRules", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "CloneRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._CloneRules._get_response( @@ -1043,7 +1195,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clone_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.clone_rules", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "CloneRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -1081,7 +1255,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -1093,8 +1267,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: ~.compute.Operation: @@ -1121,6 +1297,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -1131,6 +1308,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._Delete._get_response( self._host, @@ -1151,7 +1355,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -1189,7 +1415,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]]] = (), ) -> compute.FirewallPolicy: r"""Call the get method over HTTP. @@ -1201,8 +1427,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: ~.compute.FirewallPolicy: @@ -1214,6 +1442,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -1224,6 +1453,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._Get._get_response( self._host, @@ -1244,7 +1500,29 @@ def __call__( pb_resp = compute.FirewallPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicy.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.compute_v1.RegionNetworkFirewallPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAssociation( @@ -1282,7 +1560,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]]] = (), ) -> compute.FirewallPolicyAssociation: r"""Call the get association method over HTTP. @@ -1294,8 +1572,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: ~.compute.FirewallPolicyAssociation: @@ -1305,6 +1585,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_get_association(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetAssociation._get_transcoded_request( http_options, request @@ -1315,6 +1596,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.GetAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._GetAssociation._get_response( self._host, @@ -1335,7 +1643,31 @@ def __call__( pb_resp = compute.FirewallPolicyAssociation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyAssociation.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.compute_v1.RegionNetworkFirewallPoliciesClient.get_association", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEffectiveFirewalls( @@ -1375,7 +1707,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]]] = (), ) -> compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse: r"""Call the get effective firewalls method over HTTP. @@ -1387,8 +1719,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: ~.compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse: @@ -1398,6 +1732,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetEffectiveFirewalls._get_http_options() ) + request, metadata = self._interceptor.pre_get_effective_firewalls( request, metadata ) @@ -1410,6 +1745,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.GetEffectiveFirewalls", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetEffectiveFirewalls", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._GetEffectiveFirewalls._get_response( self._host, @@ -1434,7 +1796,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_firewalls(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse.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.compute_v1.RegionNetworkFirewallPoliciesClient.get_effective_firewalls", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetEffectiveFirewalls", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1472,7 +1858,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -1484,8 +1870,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: ~.compute.Policy: @@ -1518,6 +1906,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1528,6 +1917,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._GetIamPolicy._get_response( @@ -1550,7 +1966,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionNetworkFirewallPoliciesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -1588,7 +2026,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]]] = (), ) -> compute.FirewallPolicyRule: r"""Call the get rule method over HTTP. @@ -1600,8 +2038,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: ~.compute.FirewallPolicyRule: @@ -1615,6 +2055,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseGetRule._get_transcoded_request( http_options, request @@ -1625,6 +2066,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.GetRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._GetRule._get_response( @@ -1647,7 +2115,29 @@ def __call__( pb_resp = compute.FirewallPolicyRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyRule.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.compute_v1.RegionNetworkFirewallPoliciesClient.get_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1686,7 +2176,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1698,8 +2188,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: ~.compute.Operation: @@ -1726,6 +2218,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -1740,6 +2233,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._Insert._get_response( self._host, @@ -1761,7 +2281,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -1799,7 +2341,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]]] = (), ) -> compute.FirewallPolicyList: r"""Call the list method over HTTP. @@ -1811,8 +2353,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: ~.compute.FirewallPolicyList: @@ -1822,6 +2366,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1832,6 +2377,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._List._get_response( self._host, @@ -1852,7 +2424,29 @@ def __call__( pb_resp = compute.FirewallPolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.FirewallPolicyList.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.compute_v1.RegionNetworkFirewallPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1891,7 +2485,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1903,8 +2497,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: ~.compute.Operation: @@ -1931,6 +2527,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -1945,6 +2542,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._Patch._get_response( self._host, @@ -1966,7 +2590,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchRule( @@ -2005,7 +2651,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]]] = (), ) -> compute.Operation: r"""Call the patch rule method over HTTP. @@ -2017,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: ~.compute.Operation: @@ -2045,6 +2693,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BasePatchRule._get_http_options() ) + request, metadata = self._interceptor.pre_patch_rule(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BasePatchRule._get_transcoded_request( http_options, request @@ -2059,6 +2708,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.PatchRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "PatchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._PatchRule._get_response( @@ -2082,7 +2758,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.patch_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "PatchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveAssociation( @@ -2120,7 +2818,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]]] = (), ) -> compute.Operation: r"""Call the remove association method over HTTP. @@ -2132,8 +2830,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: ~.compute.Operation: @@ -2160,6 +2860,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseRemoveAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_remove_association( request, metadata ) @@ -2172,6 +2873,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.RemoveAssociation", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "RemoveAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._RemoveAssociation._get_response( self._host, @@ -2192,7 +2920,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.remove_association", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "RemoveAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveRule( @@ -2230,7 +2980,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]]] = (), ) -> compute.Operation: r"""Call the remove rule method over HTTP. @@ -2242,8 +2992,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: ~.compute.Operation: @@ -2270,6 +3022,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseRemoveRule._get_http_options() ) + request, metadata = self._interceptor.pre_remove_rule(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseRemoveRule._get_transcoded_request( http_options, request @@ -2280,6 +3033,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.RemoveRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "RemoveRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._RemoveRule._get_response( @@ -2302,7 +3082,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNetworkFirewallPoliciesClient.remove_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "RemoveRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2341,7 +3143,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -2353,8 +3155,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: ~.compute.Policy: @@ -2387,6 +3191,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRegionNetworkFirewallPoliciesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2401,6 +3206,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionNetworkFirewallPoliciesRestTransport._SetIamPolicy._get_response( @@ -2424,7 +3256,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.RegionNetworkFirewallPoliciesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2463,7 +3317,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2475,8 +3329,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: ~.compute.TestPermissionsResponse: @@ -2486,6 +3342,7 @@ def __call__( http_options = ( _BaseRegionNetworkFirewallPoliciesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2502,6 +3359,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 = 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.compute_v1.RegionNetworkFirewallPoliciesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNetworkFirewallPoliciesRestTransport._TestIamPermissions._get_response( self._host, @@ -2523,7 +3407,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.RegionNetworkFirewallPoliciesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNetworkFirewallPolicies", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/client.py index 387c17e95b14..ec840c2311b0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_notification_endpoints import pagers @@ -568,6 +578,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( @@ -636,6 +650,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.compute_v1.RegionNotificationEndpointsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "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.compute.v1.RegionNotificationEndpoints", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -647,7 +684,7 @@ def delete_unary( notification_endpoint: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified NotificationEndpoint in the given region @@ -707,8 +744,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -780,7 +819,7 @@ def delete( notification_endpoint: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified NotificationEndpoint in the given region @@ -840,8 +879,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -938,7 +979,7 @@ def get( notification_endpoint: 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]]] = (), ) -> compute.NotificationEndpoint: r"""Returns the specified NotificationEndpoint resource in the given region. @@ -998,8 +1039,10 @@ def sample_get(): 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.compute_v1.types.NotificationEndpoint: @@ -1076,7 +1119,7 @@ def insert_unary( notification_endpoint_resource: Optional[compute.NotificationEndpoint] = 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]]] = (), ) -> compute.Operation: r"""Create a NotificationEndpoint in the specified project in the given region using the parameters that @@ -1134,8 +1177,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1206,7 +1251,7 @@ def insert( notification_endpoint_resource: Optional[compute.NotificationEndpoint] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Create a NotificationEndpoint in the specified project in the given region using the parameters that @@ -1264,8 +1309,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1360,7 +1407,7 @@ def list( region: 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.ListPager: r"""Lists the NotificationEndpoints for a project in the given region. @@ -1413,8 +1460,10 @@ def sample_list(): 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.compute_v1.services.region_notification_endpoints.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/pagers.py index 922b919fd8e3..dd8388faa1f0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/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 = compute.ListRegionNotificationEndpointsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/transports/rest.py index c963d91f44c1..edbf0ba208d4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_notification_endpoints/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 @@ -37,6 +37,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, @@ -101,9 +109,10 @@ def post_list(self, response): def pre_delete( self, request: compute.DeleteRegionNotificationEndpointRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.DeleteRegionNotificationEndpointRequest, Sequence[Tuple[str, str]] + compute.DeleteRegionNotificationEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete @@ -124,8 +133,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionNotificationEndpointRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionNotificationEndpointRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionNotificationEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -147,9 +159,10 @@ def post_get( def pre_insert( self, request: compute.InsertRegionNotificationEndpointRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.InsertRegionNotificationEndpointRequest, Sequence[Tuple[str, str]] + compute.InsertRegionNotificationEndpointRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for insert @@ -170,9 +183,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionNotificationEndpointsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListRegionNotificationEndpointsRequest, Sequence[Tuple[str, str]] + compute.ListRegionNotificationEndpointsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list @@ -320,7 +334,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -332,8 +346,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: ~.compute.Operation: @@ -360,6 +376,7 @@ def __call__( http_options = ( _BaseRegionNotificationEndpointsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionNotificationEndpointsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -370,6 +387,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 = 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.compute_v1.RegionNotificationEndpointsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNotificationEndpointsRestTransport._Delete._get_response( self._host, @@ -390,7 +434,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNotificationEndpointsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -428,7 +494,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]]] = (), ) -> compute.NotificationEndpoint: r"""Call the get method over HTTP. @@ -440,8 +506,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: ~.compute.NotificationEndpoint: @@ -458,6 +526,7 @@ def __call__( http_options = ( _BaseRegionNotificationEndpointsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionNotificationEndpointsRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -468,6 +537,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 = 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.compute_v1.RegionNotificationEndpointsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNotificationEndpointsRestTransport._Get._get_response( self._host, @@ -488,7 +584,29 @@ def __call__( pb_resp = compute.NotificationEndpoint.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NotificationEndpoint.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.compute_v1.RegionNotificationEndpointsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -527,7 +645,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -539,8 +657,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: ~.compute.Operation: @@ -567,6 +687,7 @@ def __call__( http_options = ( _BaseRegionNotificationEndpointsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionNotificationEndpointsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -581,6 +702,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 = 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.compute_v1.RegionNotificationEndpointsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNotificationEndpointsRestTransport._Insert._get_response( self._host, @@ -602,7 +750,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionNotificationEndpointsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -640,7 +810,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]]] = (), ) -> compute.NotificationEndpointList: r"""Call the list method over HTTP. @@ -652,8 +822,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: ~.compute.NotificationEndpointList: @@ -663,6 +835,7 @@ def __call__( http_options = ( _BaseRegionNotificationEndpointsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionNotificationEndpointsRestTransport._BaseList._get_transcoded_request( http_options, request @@ -673,6 +846,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 = 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.compute_v1.RegionNotificationEndpointsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionNotificationEndpointsRestTransport._List._get_response( self._host, @@ -693,7 +893,31 @@ def __call__( pb_resp = compute.NotificationEndpointList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NotificationEndpointList.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.compute_v1.RegionNotificationEndpointsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionNotificationEndpoints", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/client.py index 65cfbb9d8166..4acc182d914d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/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.compute_v1.services.region_operations import pagers from google.cloud.compute_v1.types import compute @@ -557,6 +567,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( @@ -623,6 +637,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.compute_v1.RegionOperationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "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.compute.v1.RegionOperations", + "credentialsType": None, + }, + ) + def delete( self, request: Optional[Union[compute.DeleteRegionOperationRequest, dict]] = None, @@ -632,7 +669,7 @@ def delete( operation: 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]]] = (), ) -> compute.DeleteRegionOperationResponse: r"""Deletes the specified region-specific Operations resource. @@ -691,8 +728,10 @@ def sample_delete(): 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.compute_v1.types.DeleteRegionOperationResponse: @@ -763,7 +802,7 @@ def get( operation: 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]]] = (), ) -> compute.Operation: r"""Retrieves the specified region-specific Operations resource. @@ -822,8 +861,10 @@ def sample_get(): 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.compute_v1.types.Operation: @@ -907,7 +948,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of Operation resources contained within the specified region. @@ -958,8 +999,10 @@ def sample_list(): 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.compute_v1.services.region_operations.pagers.ListPager: @@ -1040,7 +1083,7 @@ def wait( operation: 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]]] = (), ) -> compute.Operation: r"""Waits for the specified Operation resource to return as ``DONE`` or for the request to approach the 2 minute deadline, and @@ -1110,8 +1153,10 @@ def sample_wait(): 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.compute_v1.types.Operation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/pagers.py index d3fa01a35dd0..d9ebfcc8b291 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/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 = compute.ListRegionOperationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/transports/rest.py index ac0ee3599e72..48d16f6f571a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_operations/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 @@ -37,6 +37,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, @@ -101,8 +109,10 @@ def post_wait(self, response): def pre_delete( self, request: compute.DeleteRegionOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -124,8 +134,10 @@ def post_delete( def pre_get( self, request: compute.GetRegionOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -145,8 +157,10 @@ def post_get(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_list(self, response: compute.OperationList) -> compute.OperationList: def pre_wait( self, request: compute.WaitRegionOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.WaitRegionOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.WaitRegionOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait Override in a subclass to manipulate the request or metadata @@ -309,7 +325,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]]] = (), ) -> compute.DeleteRegionOperationResponse: r"""Call the delete method over HTTP. @@ -321,8 +337,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: ~.compute.DeleteRegionOperationResponse: @@ -335,6 +353,7 @@ def __call__( http_options = ( _BaseRegionOperationsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRegionOperationsRestTransport._BaseDelete._get_transcoded_request( @@ -349,6 +368,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.compute_v1.RegionOperationsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionOperationsRestTransport._Delete._get_response( self._host, @@ -369,7 +415,31 @@ def __call__( pb_resp = compute.DeleteRegionOperationResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DeleteRegionOperationResponse.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.compute_v1.RegionOperationsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionOperationsRestTransport._BaseGet, RegionOperationsRestStub): @@ -404,7 +474,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]]] = (), ) -> compute.Operation: r"""Call the get method over HTTP. @@ -416,8 +486,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: ~.compute.Operation: @@ -444,6 +516,7 @@ def __call__( http_options = ( _BaseRegionOperationsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionOperationsRestTransport._BaseGet._get_transcoded_request( @@ -458,6 +531,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.compute_v1.RegionOperationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionOperationsRestTransport._Get._get_response( self._host, @@ -478,7 +578,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionOperationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRegionOperationsRestTransport._BaseList, RegionOperationsRestStub): @@ -513,7 +635,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]]] = (), ) -> compute.OperationList: r"""Call the list method over HTTP. @@ -525,8 +647,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: ~.compute.OperationList: @@ -538,6 +662,7 @@ def __call__( http_options = ( _BaseRegionOperationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionOperationsRestTransport._BaseList._get_transcoded_request( @@ -552,6 +677,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.compute_v1.RegionOperationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionOperationsRestTransport._List._get_response( self._host, @@ -572,7 +724,29 @@ def __call__( pb_resp = compute.OperationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.OperationList.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.compute_v1.RegionOperationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Wait(_BaseRegionOperationsRestTransport._BaseWait, RegionOperationsRestStub): @@ -607,7 +781,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]]] = (), ) -> compute.Operation: r"""Call the wait method over HTTP. @@ -619,8 +793,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: ~.compute.Operation: @@ -647,6 +823,7 @@ def __call__( http_options = ( _BaseRegionOperationsRestTransport._BaseWait._get_http_options() ) + request, metadata = self._interceptor.pre_wait(request, metadata) transcoded_request = ( _BaseRegionOperationsRestTransport._BaseWait._get_transcoded_request( @@ -661,6 +838,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.compute_v1.RegionOperationsClient.Wait", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Wait", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionOperationsRestTransport._Wait._get_response( self._host, @@ -681,7 +885,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_wait(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionOperationsClient.wait", + extra={ + "serviceName": "google.cloud.compute.v1.RegionOperations", + "rpcName": "Wait", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/client.py index a8e94a8e5768..5397a4f2c083 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_security_policies import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.RegionSecurityPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "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.compute.v1.RegionSecurityPolicies", + "credentialsType": None, + }, + ) + def add_rule_unary( self, request: Optional[ @@ -642,7 +679,7 @@ def add_rule_unary( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Inserts a rule into a security policy. @@ -706,8 +743,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -784,7 +823,7 @@ def add_rule( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts a rule into a security policy. @@ -848,8 +887,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -950,7 +991,7 @@ def delete_unary( security_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified policy. @@ -1009,8 +1050,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1082,7 +1125,7 @@ def delete( security_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified policy. @@ -1141,8 +1184,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1237,7 +1282,7 @@ def get( security_policy: 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]]] = (), ) -> compute.SecurityPolicy: r"""List all of the ordered rules present in a single specified policy. @@ -1295,8 +1340,10 @@ def sample_get(): 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.compute_v1.types.SecurityPolicy: @@ -1372,7 +1419,7 @@ def get_rule( security_policy: 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]]] = (), ) -> compute.SecurityPolicyRule: r"""Gets a rule at the specified priority. @@ -1431,8 +1478,10 @@ def sample_get_rule(): 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.compute_v1.types.SecurityPolicyRule: @@ -1506,7 +1555,7 @@ def insert_unary( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new policy in the specified project using the data included in the request. @@ -1563,8 +1612,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1635,7 +1686,7 @@ def insert( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new policy in the specified project using the data included in the request. @@ -1692,8 +1743,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1788,7 +1841,7 @@ def list( region: 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.ListPager: r"""List all the policies that have been configured for the specified project and region. @@ -1841,8 +1894,10 @@ def sample_list(): 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.compute_v1.services.region_security_policies.pagers.ListPager: @@ -1922,7 +1977,7 @@ def patch_unary( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified policy with the data included in the request. To clear fields in the policy, leave the @@ -1991,8 +2046,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2067,7 +2124,7 @@ def patch( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified policy with the data included in the request. To clear fields in the policy, leave the @@ -2136,8 +2193,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2239,7 +2298,7 @@ def patch_rule_unary( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify @@ -2305,8 +2364,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2383,7 +2444,7 @@ def patch_rule( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify @@ -2449,8 +2510,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2551,7 +2614,7 @@ def remove_rule_unary( security_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes a rule at the specified priority. @@ -2610,8 +2673,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2683,7 +2748,7 @@ def remove_rule( security_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a rule at the specified priority. @@ -2742,8 +2807,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2829,6 +2896,325 @@ def error_code(self): # Done; return the response. return response + def set_labels_unary( + self, + request: Optional[ + Union[compute.SetLabelsRegionSecurityPolicyRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + resource: Optional[str] = None, + region_set_labels_request_resource: Optional[ + compute.RegionSetLabelsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Sets the labels on a security policy. To learn more + about labels, read the Labeling Resources documentation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_labels(): + # Create a client + client = compute_v1.RegionSecurityPoliciesClient() + + # Initialize request argument(s) + request = compute_v1.SetLabelsRegionSecurityPolicyRequest( + project="project_value", + region="region_value", + resource="resource_value", + ) + + # Make the request + response = client.set_labels(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetLabelsRegionSecurityPolicyRequest, dict]): + The request object. A request message for + RegionSecurityPolicies.SetLabels. See + the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + The region for this request. + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (str): + Name or id of the resource for this + request. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_set_labels_request_resource (google.cloud.compute_v1.types.RegionSetLabelsRequest): + The body resource for this request + This corresponds to the ``region_set_labels_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [project, region, resource, region_set_labels_request_resource] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SetLabelsRegionSecurityPolicyRequest): + request = compute.SetLabelsRegionSecurityPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if resource is not None: + request.resource = resource + if region_set_labels_request_resource is not None: + request.region_set_labels_request_resource = ( + region_set_labels_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_labels] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("resource", request.resource), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def set_labels( + self, + request: Optional[ + Union[compute.SetLabelsRegionSecurityPolicyRequest, dict] + ] = None, + *, + project: Optional[str] = None, + region: Optional[str] = None, + resource: Optional[str] = None, + region_set_labels_request_resource: Optional[ + compute.RegionSetLabelsRequest + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> extended_operation.ExtendedOperation: + r"""Sets the labels on a security policy. To learn more + about labels, read the Labeling Resources documentation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import compute_v1 + + def sample_set_labels(): + # Create a client + client = compute_v1.RegionSecurityPoliciesClient() + + # Initialize request argument(s) + request = compute_v1.SetLabelsRegionSecurityPolicyRequest( + project="project_value", + region="region_value", + resource="resource_value", + ) + + # Make the request + response = client.set_labels(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.SetLabelsRegionSecurityPolicyRequest, dict]): + The request object. A request message for + RegionSecurityPolicies.SetLabels. See + the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region (str): + The region for this request. + This corresponds to the ``region`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (str): + Name or id of the resource for this + request. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + region_set_labels_request_resource (google.cloud.compute_v1.types.RegionSetLabelsRequest): + The body resource for this request + This corresponds to the ``region_set_labels_request_resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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, 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.api_core.extended_operation.ExtendedOperation: + An object representing a extended + long-running operation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any( + [project, region, resource, region_set_labels_request_resource] + ) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, compute.SetLabelsRegionSecurityPolicyRequest): + request = compute.SetLabelsRegionSecurityPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + if region is not None: + request.region = region + if resource is not None: + request.resource = resource + if region_set_labels_request_resource is not None: + request.region_set_labels_request_resource = ( + region_set_labels_request_resource + ) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_labels] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project", request.project), + ("region", request.region), + ("resource", request.resource), + ) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + operation_service = self._transport._region_operations_client + operation_request = compute.GetRegionOperationRequest() + operation_request.project = request.project + operation_request.region = request.region + operation_request.operation = response.name + + get_operation = functools.partial(operation_service.get, operation_request) + # Cancel is not part of extended operations yet. + cancel_operation = lambda: None + + # Note: this class is an implementation detail to provide a uniform + # set of names for certain fields in the extended operation proto message. + # See google.api_core.extended_operation.ExtendedOperation for details + # on these properties and the expected interface. + class _CustomOperation(extended_operation.ExtendedOperation): + @property + def error_message(self): + return self._extended_operation.http_error_message + + @property + def error_code(self): + return self._extended_operation.http_error_status_code + + response = _CustomOperation.make(get_operation, cancel_operation, response) + + # Done; return the response. + return response + def __enter__(self) -> "RegionSecurityPoliciesClient": return self diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/pagers.py index 3599a0c9e43c..6ff335c4fca3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/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 = compute.ListRegionSecurityPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/base.py index 729b109fbec2..c22a424a1696 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/base.py @@ -178,6 +178,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.set_labels: gapic_v1.method.wrap_method( + self.set_labels, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -270,6 +275,15 @@ def remove_rule( ]: raise NotImplementedError() + @property + def set_labels( + self, + ) -> Callable[ + [compute.SetLabelsRegionSecurityPolicyRequest], + Union[compute.Operation, Awaitable[compute.Operation]], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest.py index 22e65bc13bad..944ecf5f46ac 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/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 @@ -37,6 +37,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, @@ -132,6 +140,14 @@ def post_remove_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_set_labels(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_set_labels(self, response): + logging.log(f"Received response: {response}") + return response + transport = RegionSecurityPoliciesRestTransport(interceptor=MyCustomRegionSecurityPoliciesInterceptor()) client = RegionSecurityPoliciesClient(transport=transport) @@ -141,8 +157,11 @@ def post_remove_rule(self, response): def pre_add_rule( self, request: compute.AddRuleRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddRuleRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddRuleRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for add_rule Override in a subclass to manipulate the request or metadata @@ -162,8 +181,11 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: def pre_delete( self, request: compute.DeleteRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -183,8 +205,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -204,8 +228,11 @@ def post_get(self, response: compute.SecurityPolicy) -> compute.SecurityPolicy: def pre_get_rule( self, request: compute.GetRuleRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRuleRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRuleRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_rule Override in a subclass to manipulate the request or metadata @@ -227,8 +254,11 @@ def post_get_rule( def pre_insert( self, request: compute.InsertRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -248,8 +278,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionSecurityPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionSecurityPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionSecurityPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -271,8 +304,11 @@ def post_list( def pre_patch( self, request: compute.PatchRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -292,8 +328,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_rule( self, request: compute.PatchRuleRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRuleRegionSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRuleRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch_rule Override in a subclass to manipulate the request or metadata @@ -313,9 +352,10 @@ def post_patch_rule(self, response: compute.Operation) -> compute.Operation: def pre_remove_rule( self, request: compute.RemoveRuleRegionSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.RemoveRuleRegionSecurityPolicyRequest, Sequence[Tuple[str, str]] + compute.RemoveRuleRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for remove_rule @@ -333,6 +373,30 @@ def post_remove_rule(self, response: compute.Operation) -> compute.Operation: """ return response + def pre_set_labels( + self, + request: compute.SetLabelsRegionSecurityPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsRegionSecurityPolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for set_labels + + Override in a subclass to manipulate the request or metadata + before they are sent to the RegionSecurityPolicies server. + """ + return request, metadata + + def post_set_labels(self, response: compute.Operation) -> compute.Operation: + """Post-rpc interceptor for set_labels + + Override in a subclass to manipulate the response + after it is returned by the RegionSecurityPolicies server but before + it is returned to user code. + """ + return response + @dataclasses.dataclass class RegionSecurityPoliciesRestStub: @@ -460,7 +524,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]]] = (), ) -> compute.Operation: r"""Call the add rule method over HTTP. @@ -472,8 +536,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: ~.compute.Operation: @@ -500,6 +566,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseAddRule._get_http_options() ) + request, metadata = self._interceptor.pre_add_rule(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseAddRule._get_transcoded_request( http_options, request @@ -514,6 +581,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 = 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.compute_v1.RegionSecurityPoliciesClient.AddRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "AddRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._AddRule._get_response( self._host, @@ -535,7 +629,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.add_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "AddRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -573,7 +689,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -585,8 +701,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: ~.compute.Operation: @@ -613,6 +731,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -623,6 +742,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 = 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.compute_v1.RegionSecurityPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._Delete._get_response( self._host, @@ -643,7 +789,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -681,7 +849,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]]] = (), ) -> compute.SecurityPolicy: r"""Call the get method over HTTP. @@ -693,8 +861,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: ~.compute.SecurityPolicy: @@ -710,6 +880,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -720,6 +891,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 = 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.compute_v1.RegionSecurityPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._Get._get_response( self._host, @@ -740,7 +938,29 @@ def __call__( pb_resp = compute.SecurityPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicy.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.compute_v1.RegionSecurityPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -778,7 +998,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]]] = (), ) -> compute.SecurityPolicyRule: r"""Call the get rule method over HTTP. @@ -790,8 +1010,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: ~.compute.SecurityPolicyRule: @@ -805,6 +1027,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseGetRule._get_transcoded_request( http_options, request @@ -815,6 +1038,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 = 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.compute_v1.RegionSecurityPoliciesClient.GetRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._GetRule._get_response( self._host, @@ -835,7 +1085,29 @@ def __call__( pb_resp = compute.SecurityPolicyRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicyRule.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.compute_v1.RegionSecurityPoliciesClient.get_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -874,7 +1146,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -886,8 +1158,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: ~.compute.Operation: @@ -914,6 +1188,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -928,6 +1203,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 = 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.compute_v1.RegionSecurityPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._Insert._get_response( self._host, @@ -949,7 +1251,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -987,7 +1311,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]]] = (), ) -> compute.SecurityPolicyList: r"""Call the list method over HTTP. @@ -999,8 +1323,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: ~.compute.SecurityPolicyList: @@ -1010,6 +1336,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -1020,6 +1347,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 = 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.compute_v1.RegionSecurityPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._List._get_response( self._host, @@ -1040,7 +1394,29 @@ def __call__( pb_resp = compute.SecurityPolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicyList.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.compute_v1.RegionSecurityPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1079,7 +1455,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1091,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: ~.compute.Operation: @@ -1119,6 +1497,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -1133,6 +1512,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 = 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.compute_v1.RegionSecurityPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._Patch._get_response( self._host, @@ -1154,7 +1560,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchRule( @@ -1193,7 +1621,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]]] = (), ) -> compute.Operation: r"""Call the patch rule method over HTTP. @@ -1205,8 +1633,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: ~.compute.Operation: @@ -1233,6 +1663,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BasePatchRule._get_http_options() ) + request, metadata = self._interceptor.pre_patch_rule(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BasePatchRule._get_transcoded_request( http_options, request @@ -1247,6 +1678,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 = 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.compute_v1.RegionSecurityPoliciesClient.PatchRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "PatchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._PatchRule._get_response( self._host, @@ -1268,7 +1726,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.patch_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "PatchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveRule( @@ -1306,7 +1786,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]]] = (), ) -> compute.Operation: r"""Call the remove rule method over HTTP. @@ -1318,8 +1798,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: ~.compute.Operation: @@ -1346,6 +1828,7 @@ def __call__( http_options = ( _BaseRegionSecurityPoliciesRestTransport._BaseRemoveRule._get_http_options() ) + request, metadata = self._interceptor.pre_remove_rule(request, metadata) transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseRemoveRule._get_transcoded_request( http_options, request @@ -1356,6 +1839,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 = 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.compute_v1.RegionSecurityPoliciesClient.RemoveRule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "RemoveRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSecurityPoliciesRestTransport._RemoveRule._get_response( self._host, @@ -1376,7 +1886,195 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.remove_rule", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "RemoveRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _SetLabels( + _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels, + RegionSecurityPoliciesRestStub, + ): + def __hash__(self): + return hash("RegionSecurityPoliciesRestTransport.SetLabels") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: compute.SetLabelsRegionSecurityPolicyRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.Operation: + r"""Call the set labels method over HTTP. + + Args: + request (~.compute.SetLabelsRegionSecurityPolicyRequest): + The request object. A request message for + RegionSecurityPolicies.SetLabels. See + the method description for details. + 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, 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: + ~.compute.Operation: + Represents an Operation resource. Google Compute Engine + has three Operation resources: \* + `Global `__ + \* + `Regional `__ + \* + `Zonal `__ + You can use an operation resource to manage asynchronous + API requests. For more information, read Handling API + responses. Operations can be global, regional or zonal. + - For global operations, use the ``globalOperations`` + resource. - For regional operations, use the + ``regionOperations`` resource. - For zonal operations, + use the ``zoneOperations`` resource. For more + information, read Global, Regional, and Zonal Resources. + Note that completed Operation resources have a limited + retention period. + + """ + + http_options = ( + _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels._get_http_options() + ) + + request, metadata = self._interceptor.pre_set_labels(request, metadata) + transcoded_request = _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels._get_transcoded_request( + http_options, request + ) + + body = _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels._get_query_params_json( + 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 = 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.compute_v1.RegionSecurityPoliciesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = RegionSecurityPoliciesRestTransport._SetLabels._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.Operation() + pb_resp = compute.Operation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSecurityPoliciesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSecurityPolicies", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1455,6 +2153,14 @@ def remove_rule( # In C++ this would require a dynamic_cast return self._RemoveRule(self._session, self._host, self._interceptor) # type: ignore + @property + def set_labels( + self, + ) -> Callable[[compute.SetLabelsRegionSecurityPolicyRequest], compute.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SetLabels(self._session, self._host, self._interceptor) # type: ignore + @property def kind(self) -> str: return "rest" diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest_base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest_base.py index c958a70bf3cf..563afad8e9ed 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest_base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_security_policies/transports/rest_base.py @@ -541,5 +541,61 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseSetLabels: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/compute/v1/projects/{project}/regions/{region}/securityPolicies/{resource}/setLabels", + "body": "region_set_labels_request_resource", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.SetLabelsRegionSecurityPolicyRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=False + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseRegionSecurityPoliciesRestTransport._BaseSetLabels._get_unset_required_fields( + query_params + ) + ) + + return query_params + __all__ = ("_BaseRegionSecurityPoliciesRestTransport",) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/client.py index d22361bc8215..95b6fa9697ed 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_ssl_certificates import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.RegionSslCertificatesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "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.compute.v1.RegionSslCertificates", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -641,7 +678,7 @@ def delete_unary( ssl_certificate: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified SslCertificate resource in the region. @@ -701,8 +738,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -774,7 +813,7 @@ def delete( ssl_certificate: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified SslCertificate resource in the region. @@ -834,8 +873,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -930,7 +971,7 @@ def get( ssl_certificate: 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]]] = (), ) -> compute.SslCertificate: r"""Returns the specified SslCertificate resource in the specified region. Get a list of available SSL @@ -991,8 +1032,10 @@ def sample_get(): 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.compute_v1.types.SslCertificate: @@ -1082,7 +1125,7 @@ def insert_unary( ssl_certificate_resource: Optional[compute.SslCertificate] = 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]]] = (), ) -> compute.Operation: r"""Creates a SslCertificate resource in the specified project and region using the data included in the @@ -1140,8 +1183,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1212,7 +1257,7 @@ def insert( ssl_certificate_resource: Optional[compute.SslCertificate] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a SslCertificate resource in the specified project and region using the data included in the @@ -1270,8 +1315,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1364,7 +1411,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of SslCertificate resources available to the specified project in the specified @@ -1418,8 +1465,10 @@ def sample_list(): 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.compute_v1.services.region_ssl_certificates.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/pagers.py index e0bb3e299987..41adc29ccef6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/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 = compute.ListRegionSslCertificatesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/transports/rest.py index dd6741bcbea4..0a623f2a845c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_certificates/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 @@ -37,6 +37,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, @@ -101,8 +109,11 @@ def post_list(self, response): def pre_delete( self, request: compute.DeleteRegionSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionSslCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -122,8 +133,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionSslCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -143,8 +156,11 @@ def post_get(self, response: compute.SslCertificate) -> compute.SslCertificate: def pre_insert( self, request: compute.InsertRegionSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionSslCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -164,8 +180,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionSslCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionSslCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionSslCertificatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -310,7 +329,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -322,8 +341,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: ~.compute.Operation: @@ -350,6 +371,7 @@ def __call__( http_options = ( _BaseRegionSslCertificatesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionSslCertificatesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -360,6 +382,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 = 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.compute_v1.RegionSslCertificatesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslCertificatesRestTransport._Delete._get_response( self._host, @@ -380,7 +429,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSslCertificatesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -417,7 +488,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]]] = (), ) -> compute.SslCertificate: r"""Call the get method over HTTP. @@ -429,8 +500,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: ~.compute.SslCertificate: @@ -460,6 +533,7 @@ def __call__( http_options = ( _BaseRegionSslCertificatesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionSslCertificatesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -472,6 +546,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.compute_v1.RegionSslCertificatesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslCertificatesRestTransport._Get._get_response( self._host, @@ -492,7 +593,29 @@ def __call__( pb_resp = compute.SslCertificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslCertificate.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.compute_v1.RegionSslCertificatesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -531,7 +654,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -543,8 +666,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: ~.compute.Operation: @@ -571,6 +696,7 @@ def __call__( http_options = ( _BaseRegionSslCertificatesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionSslCertificatesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -585,6 +711,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 = 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.compute_v1.RegionSslCertificatesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslCertificatesRestTransport._Insert._get_response( self._host, @@ -606,7 +759,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSslCertificatesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -643,7 +818,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]]] = (), ) -> compute.SslCertificateList: r"""Call the list method over HTTP. @@ -655,8 +830,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: ~.compute.SslCertificateList: @@ -668,6 +845,7 @@ def __call__( http_options = ( _BaseRegionSslCertificatesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionSslCertificatesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -678,6 +856,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 = 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.compute_v1.RegionSslCertificatesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslCertificatesRestTransport._List._get_response( self._host, @@ -698,7 +903,29 @@ def __call__( pb_resp = compute.SslCertificateList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslCertificateList.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.compute_v1.RegionSslCertificatesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslCertificates", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/client.py index b5130166d07b..aa70dd7b6b0c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_ssl_policies import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.RegionSslPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "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.compute.v1.RegionSslPolicies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteRegionSslPolicyRequest, dict]] = None, @@ -637,7 +674,7 @@ def delete_unary( ssl_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any @@ -699,8 +736,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -770,7 +809,7 @@ def delete( ssl_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any @@ -832,8 +871,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -928,7 +969,7 @@ def get( ssl_policy: 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]]] = (), ) -> compute.SslPolicy: r"""Lists all of the ordered rules present in a single specified policy. @@ -989,8 +1030,10 @@ def sample_get(): 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.compute_v1.types.SslPolicy: @@ -1065,7 +1108,7 @@ def insert_unary( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new policy in the specified project and region using the data included in the request. @@ -1122,8 +1165,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1192,7 +1237,7 @@ def insert( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new policy in the specified project and region using the data included in the request. @@ -1249,8 +1294,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1343,7 +1390,7 @@ def list( region: 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.ListPager: r"""Lists all the SSL policies that have been configured for the specified project and region. @@ -1396,8 +1443,10 @@ def sample_list(): 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.compute_v1.services.region_ssl_policies.pagers.ListPager: @@ -1477,7 +1526,7 @@ def list_available_features( region: 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]]] = (), ) -> compute.SslPoliciesListAvailableFeaturesResponse: r"""Lists all features that can be specified in the SSL policy when using custom profile. @@ -1529,8 +1578,10 @@ def sample_list_available_features(): 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.compute_v1.types.SslPoliciesListAvailableFeaturesResponse: @@ -1598,7 +1649,7 @@ def patch_unary( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified SSL policy with the data included in the request. @@ -1664,8 +1715,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1738,7 +1791,7 @@ def patch( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified SSL policy with the data included in the request. @@ -1804,8 +1857,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/pagers.py index c73b0e7e455e..ed5a79f4db12 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/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 = compute.ListRegionSslPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/transports/rest.py index 8eab8199d62e..7e0f71dd5fd4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_ssl_policies/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_patch(self, response): def pre_delete( self, request: compute.DeleteRegionSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -138,8 +148,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -159,8 +171,10 @@ def post_get(self, response: compute.SslPolicy) -> compute.SslPolicy: def pre_insert( self, request: compute.InsertRegionSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -180,8 +194,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionSslPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionSslPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionSslPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -201,9 +217,10 @@ def post_list(self, response: compute.SslPoliciesList) -> compute.SslPoliciesLis def pre_list_available_features( self, request: compute.ListAvailableFeaturesRegionSslPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListAvailableFeaturesRegionSslPoliciesRequest, Sequence[Tuple[str, str]] + compute.ListAvailableFeaturesRegionSslPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_available_features @@ -226,8 +243,10 @@ def post_list_available_features( def pre_patch( self, request: compute.PatchRegionSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -369,7 +388,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -381,8 +400,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: ~.compute.Operation: @@ -409,6 +430,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRegionSslPoliciesRestTransport._BaseDelete._get_transcoded_request( @@ -423,6 +445,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.compute_v1.RegionSslPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslPoliciesRestTransport._Delete._get_response( self._host, @@ -443,7 +492,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSslPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionSslPoliciesRestTransport._BaseGet, RegionSslPoliciesRestStub): @@ -478,7 +549,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]]] = (), ) -> compute.SslPolicy: r"""Call the get method over HTTP. @@ -490,8 +561,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: ~.compute.SslPolicy: @@ -508,6 +581,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionSslPoliciesRestTransport._BaseGet._get_transcoded_request( @@ -522,6 +596,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.compute_v1.RegionSslPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslPoliciesRestTransport._Get._get_response( self._host, @@ -542,7 +643,29 @@ def __call__( pb_resp = compute.SslPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslPolicy.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.compute_v1.RegionSslPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -580,7 +703,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -592,8 +715,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: ~.compute.Operation: @@ -620,6 +745,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRegionSslPoliciesRestTransport._BaseInsert._get_transcoded_request( @@ -640,6 +766,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.compute_v1.RegionSslPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslPoliciesRestTransport._Insert._get_response( self._host, @@ -661,7 +814,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSslPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -698,7 +873,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]]] = (), ) -> compute.SslPoliciesList: r"""Call the list method over HTTP. @@ -710,8 +885,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: ~.compute.SslPoliciesList: @@ -721,6 +898,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionSslPoliciesRestTransport._BaseList._get_transcoded_request( @@ -735,6 +913,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.compute_v1.RegionSslPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslPoliciesRestTransport._List._get_response( self._host, @@ -755,7 +960,29 @@ def __call__( pb_resp = compute.SslPoliciesList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslPoliciesList.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.compute_v1.RegionSslPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAvailableFeatures( @@ -793,7 +1020,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]]] = (), ) -> compute.SslPoliciesListAvailableFeaturesResponse: r"""Call the list available features method over HTTP. @@ -805,8 +1032,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: ~.compute.SslPoliciesListAvailableFeaturesResponse: @@ -816,6 +1045,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BaseListAvailableFeatures._get_http_options() ) + request, metadata = self._interceptor.pre_list_available_features( request, metadata ) @@ -828,6 +1058,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 = 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.compute_v1.RegionSslPoliciesClient.ListAvailableFeatures", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "ListAvailableFeatures", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionSslPoliciesRestTransport._ListAvailableFeatures._get_response( @@ -850,7 +1107,33 @@ def __call__( pb_resp = compute.SslPoliciesListAvailableFeaturesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_available_features(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.SslPoliciesListAvailableFeaturesResponse.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.compute_v1.RegionSslPoliciesClient.list_available_features", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "ListAvailableFeatures", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -888,7 +1171,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -900,8 +1183,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: ~.compute.Operation: @@ -928,6 +1213,7 @@ def __call__( http_options = ( _BaseRegionSslPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseRegionSslPoliciesRestTransport._BasePatch._get_transcoded_request( @@ -948,6 +1234,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.compute_v1.RegionSslPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionSslPoliciesRestTransport._Patch._get_response( self._host, @@ -969,7 +1282,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionSslPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionSslPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/client.py index 758f93df3c10..fa54a59e5bb3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_target_http_proxies import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.RegionTargetHttpProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "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.compute.v1.RegionTargetHttpProxies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -643,7 +680,7 @@ def delete_unary( target_http_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetHttpProxy resource. @@ -702,8 +739,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -775,7 +814,7 @@ def delete( target_http_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetHttpProxy resource. @@ -834,8 +873,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -930,7 +971,7 @@ def get( target_http_proxy: 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]]] = (), ) -> compute.TargetHttpProxy: r"""Returns the specified TargetHttpProxy resource in the specified region. @@ -990,8 +1031,10 @@ def sample_get(): 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.compute_v1.types.TargetHttpProxy: @@ -1077,7 +1120,7 @@ def insert_unary( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetHttpProxy resource in the specified project and region using the data included in the @@ -1135,8 +1178,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1207,7 +1252,7 @@ def insert( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetHttpProxy resource in the specified project and region using the data included in the @@ -1265,8 +1310,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1361,7 +1408,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of TargetHttpProxy resources available to the specified project in the specified @@ -1415,8 +1462,10 @@ def sample_list(): 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.compute_v1.services.region_target_http_proxies.pagers.ListPager: @@ -1500,7 +1549,7 @@ def set_url_map_unary( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> compute.Operation: r"""Changes the URL map for TargetHttpProxy. @@ -1564,8 +1613,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -1642,7 +1693,7 @@ def set_url_map( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the URL map for TargetHttpProxy. @@ -1706,8 +1757,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/pagers.py index e3afd668ee3e..c83fdef89d71 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/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 = compute.ListRegionTargetHttpProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/transports/rest.py index 07d9d3da23ac..c68fd20b9ff7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_http_proxies/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 @@ -37,6 +37,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, @@ -109,8 +117,11 @@ def post_set_url_map(self, response): def pre_delete( self, request: compute.DeleteRegionTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionTargetHttpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -130,8 +141,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -151,8 +164,11 @@ def post_get(self, response: compute.TargetHttpProxy) -> compute.TargetHttpProxy def pre_insert( self, request: compute.InsertRegionTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionTargetHttpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -172,8 +188,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionTargetHttpProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionTargetHttpProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionTargetHttpProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -195,9 +214,10 @@ def post_list( def pre_set_url_map( self, request: compute.SetUrlMapRegionTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetUrlMapRegionTargetHttpProxyRequest, Sequence[Tuple[str, str]] + compute.SetUrlMapRegionTargetHttpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_url_map @@ -341,7 +361,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -353,8 +373,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: ~.compute.Operation: @@ -381,6 +403,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionTargetHttpProxiesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -391,6 +414,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 = 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.compute_v1.RegionTargetHttpProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpProxiesRestTransport._Delete._get_response( self._host, @@ -411,7 +461,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -449,7 +521,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]]] = (), ) -> compute.TargetHttpProxy: r"""Call the get method over HTTP. @@ -461,8 +533,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: ~.compute.TargetHttpProxy: @@ -488,6 +562,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionTargetHttpProxiesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -498,6 +573,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 = 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.compute_v1.RegionTargetHttpProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpProxiesRestTransport._Get._get_response( self._host, @@ -518,7 +620,29 @@ def __call__( pb_resp = compute.TargetHttpProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpProxy.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.compute_v1.RegionTargetHttpProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -557,7 +681,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -569,8 +693,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: ~.compute.Operation: @@ -597,6 +723,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionTargetHttpProxiesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -611,6 +738,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 = 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.compute_v1.RegionTargetHttpProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpProxiesRestTransport._Insert._get_response( self._host, @@ -632,7 +786,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -670,7 +846,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]]] = (), ) -> compute.TargetHttpProxyList: r"""Call the list method over HTTP. @@ -682,8 +858,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: ~.compute.TargetHttpProxyList: @@ -693,6 +871,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionTargetHttpProxiesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -703,6 +882,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 = 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.compute_v1.RegionTargetHttpProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpProxiesRestTransport._List._get_response( self._host, @@ -723,7 +929,29 @@ def __call__( pb_resp = compute.TargetHttpProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpProxyList.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.compute_v1.RegionTargetHttpProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUrlMap( @@ -762,7 +990,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]]] = (), ) -> compute.Operation: r"""Call the set url map method over HTTP. @@ -774,8 +1002,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: ~.compute.Operation: @@ -802,6 +1032,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpProxiesRestTransport._BaseSetUrlMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_url_map(request, metadata) transcoded_request = _BaseRegionTargetHttpProxiesRestTransport._BaseSetUrlMap._get_transcoded_request( http_options, request @@ -816,6 +1047,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 = 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.compute_v1.RegionTargetHttpProxiesClient.SetUrlMap", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "SetUrlMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpProxiesRestTransport._SetUrlMap._get_response( self._host, @@ -837,7 +1095,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_url_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpProxiesClient.set_url_map", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpProxies", + "rpcName": "SetUrlMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/client.py index a4963f9723b4..73a0907ef29b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_target_https_proxies import pagers @@ -566,6 +576,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( @@ -632,6 +646,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.compute_v1.RegionTargetHttpsProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "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.compute.v1.RegionTargetHttpsProxies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -643,7 +680,7 @@ def delete_unary( target_https_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetHttpsProxy resource. @@ -702,8 +739,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -775,7 +814,7 @@ def delete( target_https_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetHttpsProxy resource. @@ -834,8 +873,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -930,7 +971,7 @@ def get( target_https_proxy: 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]]] = (), ) -> compute.TargetHttpsProxy: r"""Returns the specified TargetHttpsProxy resource in the specified region. @@ -990,8 +1031,10 @@ def sample_get(): 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.compute_v1.types.TargetHttpsProxy: @@ -1000,11 +1043,11 @@ def sample_get(): [Global](/compute/docs/reference/rest/v1/targetHttpsProxies) \* [Regional](/compute/docs/reference/rest/v1/regionTargetHttpsProxies) - A target HTTPS proxy is a component of GCP HTTPS load - balancers. \* targetHttpProxies are used by global - external Application Load Balancers, classic Application - Load Balancers, cross-region internal Application Load - Balancers, and Traffic Director. \* + A target HTTPS proxy is a component of Google Cloud + HTTPS load balancers. \* targetHttpProxies are used by + global external Application Load Balancers, classic + Application Load Balancers, cross-region internal + Application Load Balancers, and Traffic Director. \* regionTargetHttpProxies are used by regional internal Application Load Balancers and regional external Application Load Balancers. Forwarding rules reference a @@ -1077,7 +1120,7 @@ def insert_unary( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetHttpsProxy resource in the specified project and region using the data included in the @@ -1135,8 +1178,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1207,7 +1252,7 @@ def insert( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetHttpsProxy resource in the specified project and region using the data included in the @@ -1265,8 +1310,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1361,7 +1408,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified @@ -1415,8 +1462,10 @@ def sample_list(): 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.compute_v1.services.region_target_https_proxies.pagers.ListPager: @@ -1500,7 +1549,7 @@ def patch_unary( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified regional TargetHttpsProxy resource with the data included in the request. This @@ -1565,8 +1614,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1643,7 +1694,7 @@ def patch( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified regional TargetHttpsProxy resource with the data included in the request. This @@ -1708,8 +1759,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1813,7 +1866,7 @@ def set_ssl_certificates_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Replaces SslCertificates for TargetHttpsProxy. @@ -1877,8 +1930,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -1969,7 +2024,7 @@ def set_ssl_certificates( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Replaces SslCertificates for TargetHttpsProxy. @@ -2033,8 +2088,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -2148,7 +2205,7 @@ def set_url_map_unary( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> compute.Operation: r"""Changes the URL map for TargetHttpsProxy. @@ -2212,8 +2269,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -2290,7 +2349,7 @@ def set_url_map( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the URL map for TargetHttpsProxy. @@ -2354,8 +2413,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/pagers.py index e1be340c4443..bfcd27ff12ae 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/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 = compute.ListRegionTargetHttpsProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/transports/rest.py index 66d9c45602aa..8c0ca8797d45 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_https_proxies/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 @@ -37,6 +37,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, @@ -125,8 +133,11 @@ def post_set_url_map(self, response): def pre_delete( self, request: compute.DeleteRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -146,8 +157,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -167,8 +181,11 @@ def post_get(self, response: compute.TargetHttpsProxy) -> compute.TargetHttpsPro def pre_insert( self, request: compute.InsertRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -188,8 +205,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionTargetHttpsProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionTargetHttpsProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionTargetHttpsProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -211,8 +231,11 @@ def post_list( def pre_patch( self, request: compute.PatchRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -232,10 +255,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_ssl_certificates( self, request: compute.SetSslCertificatesRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.SetSslCertificatesRegionTargetHttpsProxyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_ssl_certificates @@ -258,9 +281,10 @@ def post_set_ssl_certificates( def pre_set_url_map( self, request: compute.SetUrlMapRegionTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetUrlMapRegionTargetHttpsProxyRequest, Sequence[Tuple[str, str]] + compute.SetUrlMapRegionTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_url_map @@ -404,7 +428,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -416,8 +440,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: ~.compute.Operation: @@ -444,6 +470,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -454,6 +481,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._Delete._get_response( self._host, @@ -474,7 +528,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpsProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -512,7 +588,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]]] = (), ) -> compute.TargetHttpsProxy: r"""Call the get method over HTTP. @@ -524,8 +600,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: ~.compute.TargetHttpsProxy: @@ -534,11 +612,11 @@ def __call__( `Global `__ \* `Regional `__ - A target HTTPS proxy is a component of GCP HTTPS load - balancers. \* targetHttpProxies are used by global - external Application Load Balancers, classic Application - Load Balancers, cross-region internal Application Load - Balancers, and Traffic Director. \* + A target HTTPS proxy is a component of Google Cloud + HTTPS load balancers. \* targetHttpProxies are used by + global external Application Load Balancers, classic + Application Load Balancers, cross-region internal + Application Load Balancers, and Traffic Director. \* regionTargetHttpProxies are used by regional internal Application Load Balancers and regional external Application Load Balancers. Forwarding rules reference a @@ -551,6 +629,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -561,6 +640,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._Get._get_response( self._host, @@ -581,7 +687,29 @@ def __call__( pb_resp = compute.TargetHttpsProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpsProxy.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.compute_v1.RegionTargetHttpsProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -620,7 +748,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -632,8 +760,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: ~.compute.Operation: @@ -660,6 +790,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -674,6 +805,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._Insert._get_response( self._host, @@ -695,7 +853,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpsProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -733,7 +913,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]]] = (), ) -> compute.TargetHttpsProxyList: r"""Call the list method over HTTP. @@ -745,8 +925,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: ~.compute.TargetHttpsProxyList: @@ -758,6 +940,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -768,6 +951,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._List._get_response( self._host, @@ -788,7 +998,29 @@ def __call__( pb_resp = compute.TargetHttpsProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpsProxyList.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.compute_v1.RegionTargetHttpsProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -827,7 +1059,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -839,8 +1071,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: ~.compute.Operation: @@ -867,6 +1101,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -881,6 +1116,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._Patch._get_response( self._host, @@ -902,7 +1164,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpsProxiesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSslCertificates( @@ -941,7 +1225,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]]] = (), ) -> compute.Operation: r"""Call the set ssl certificates method over HTTP. @@ -953,8 +1237,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: ~.compute.Operation: @@ -981,6 +1267,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseSetSslCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_set_ssl_certificates( request, metadata ) @@ -997,6 +1284,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.SetSslCertificates", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "SetSslCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RegionTargetHttpsProxiesRestTransport._SetSslCertificates._get_response( @@ -1020,7 +1334,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_ssl_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpsProxiesClient.set_ssl_certificates", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "SetSslCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUrlMap( @@ -1059,7 +1395,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]]] = (), ) -> compute.Operation: r"""Call the set url map method over HTTP. @@ -1071,8 +1407,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: ~.compute.Operation: @@ -1099,6 +1437,7 @@ def __call__( http_options = ( _BaseRegionTargetHttpsProxiesRestTransport._BaseSetUrlMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_url_map(request, metadata) transcoded_request = _BaseRegionTargetHttpsProxiesRestTransport._BaseSetUrlMap._get_transcoded_request( http_options, request @@ -1113,6 +1452,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 = 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.compute_v1.RegionTargetHttpsProxiesClient.SetUrlMap", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "SetUrlMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetHttpsProxiesRestTransport._SetUrlMap._get_response( self._host, @@ -1134,7 +1500,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_url_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetHttpsProxiesClient.set_url_map", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetHttpsProxies", + "rpcName": "SetUrlMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/client.py index 62f5bbb2439c..50ecedd90e0f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_target_tcp_proxies import pagers @@ -564,6 +574,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( @@ -630,6 +644,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.compute_v1.RegionTargetTcpProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "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.compute.v1.RegionTargetTcpProxies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[ @@ -641,7 +678,7 @@ def delete_unary( target_tcp_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetTcpProxy resource. @@ -700,8 +737,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -773,7 +812,7 @@ def delete( target_tcp_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetTcpProxy resource. @@ -832,8 +871,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -928,7 +969,7 @@ def get( target_tcp_proxy: 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]]] = (), ) -> compute.TargetTcpProxy: r"""Returns the specified TargetTcpProxy resource. @@ -987,8 +1028,10 @@ def sample_get(): 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.compute_v1.types.TargetTcpProxy: @@ -1066,7 +1109,7 @@ def insert_unary( target_tcp_proxy_resource: Optional[compute.TargetTcpProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetTcpProxy resource in the specified project and region using the data included in the @@ -1124,8 +1167,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1196,7 +1241,7 @@ def insert( target_tcp_proxy_resource: Optional[compute.TargetTcpProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetTcpProxy resource in the specified project and region using the data included in the @@ -1254,8 +1299,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1350,7 +1397,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of TargetTcpProxy resources available to the specified project in a given region. @@ -1403,8 +1450,10 @@ def sample_list(): 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.compute_v1.services.region_target_tcp_proxies.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/pagers.py index 3a34409cf1d3..041a1b959601 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/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 = compute.ListRegionTargetTcpProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/transports/rest.py index 627d4eed452f..37db37a45b23 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_target_tcp_proxies/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 @@ -37,6 +37,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, @@ -101,8 +109,11 @@ def post_list(self, response): def pre_delete( self, request: compute.DeleteRegionTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionTargetTcpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -122,8 +133,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRegionTargetTcpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -143,8 +156,11 @@ def post_get(self, response: compute.TargetTcpProxy) -> compute.TargetTcpProxy: def pre_insert( self, request: compute.InsertRegionTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionTargetTcpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -164,8 +180,11 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionTargetTcpProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionTargetTcpProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionTargetTcpProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -310,7 +329,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -322,8 +341,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: ~.compute.Operation: @@ -350,6 +371,7 @@ def __call__( http_options = ( _BaseRegionTargetTcpProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseRegionTargetTcpProxiesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -360,6 +382,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 = 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.compute_v1.RegionTargetTcpProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetTcpProxiesRestTransport._Delete._get_response( self._host, @@ -380,7 +429,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetTcpProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -418,7 +489,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]]] = (), ) -> compute.TargetTcpProxy: r"""Call the get method over HTTP. @@ -430,8 +501,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: ~.compute.TargetTcpProxy: @@ -449,6 +522,7 @@ def __call__( http_options = ( _BaseRegionTargetTcpProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseRegionTargetTcpProxiesRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -459,6 +533,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 = 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.compute_v1.RegionTargetTcpProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetTcpProxiesRestTransport._Get._get_response( self._host, @@ -479,7 +580,29 @@ def __call__( pb_resp = compute.TargetTcpProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetTcpProxy.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.compute_v1.RegionTargetTcpProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -518,7 +641,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -530,8 +653,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: ~.compute.Operation: @@ -558,6 +683,7 @@ def __call__( http_options = ( _BaseRegionTargetTcpProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseRegionTargetTcpProxiesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -572,6 +698,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 = 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.compute_v1.RegionTargetTcpProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetTcpProxiesRestTransport._Insert._get_response( self._host, @@ -593,7 +746,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionTargetTcpProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -631,7 +806,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]]] = (), ) -> compute.TargetTcpProxyList: r"""Call the list method over HTTP. @@ -643,8 +818,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: ~.compute.TargetTcpProxyList: @@ -656,6 +833,7 @@ def __call__( http_options = ( _BaseRegionTargetTcpProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = _BaseRegionTargetTcpProxiesRestTransport._BaseList._get_transcoded_request( http_options, request @@ -666,6 +844,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 = 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.compute_v1.RegionTargetTcpProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionTargetTcpProxiesRestTransport._List._get_response( self._host, @@ -686,7 +891,29 @@ def __call__( pb_resp = compute.TargetTcpProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetTcpProxyList.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.compute_v1.RegionTargetTcpProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionTargetTcpProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/client.py index c48097adc175..4fd963616d99 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.region_url_maps import pagers @@ -556,6 +566,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( @@ -621,6 +635,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.compute_v1.RegionUrlMapsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "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.compute.v1.RegionUrlMaps", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteRegionUrlMapRequest, dict]] = None, @@ -630,7 +667,7 @@ def delete_unary( url_map: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified UrlMap resource. @@ -689,8 +726,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -760,7 +799,7 @@ def delete( url_map: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified UrlMap resource. @@ -819,8 +858,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -915,7 +956,7 @@ def get( url_map: 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]]] = (), ) -> compute.UrlMap: r"""Returns the specified UrlMap resource. @@ -974,8 +1015,10 @@ def sample_get(): 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.compute_v1.types.UrlMap: @@ -1068,7 +1111,7 @@ def insert_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Creates a UrlMap resource in the specified project using the data included in the request. @@ -1125,8 +1168,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1195,7 +1240,7 @@ def insert( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a UrlMap resource in the specified project using the data included in the request. @@ -1252,8 +1297,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1346,7 +1393,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of UrlMap resources available to the specified project in the specified region. @@ -1399,8 +1446,10 @@ def sample_list(): 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.compute_v1.services.region_url_maps.pagers.ListPager: @@ -1482,7 +1531,7 @@ def patch_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified UrlMap resource with the data included in the request. This method supports PATCH @@ -1547,8 +1596,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1621,7 +1672,7 @@ def patch( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified UrlMap resource with the data included in the request. This method supports PATCH @@ -1686,8 +1737,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1785,7 +1838,7 @@ def update_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified UrlMap resource with the data included in the request. @@ -1850,8 +1903,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -1924,7 +1979,7 @@ def update( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified UrlMap resource with the data included in the request. @@ -1989,8 +2044,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2090,7 +2147,7 @@ def validate( ] = 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]]] = (), ) -> compute.UrlMapsValidateResponse: r"""Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling @@ -2156,8 +2213,10 @@ def sample_validate(): 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.compute_v1.types.UrlMapsValidateResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/pagers.py index 7894de0a5270..aee229e4c336 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/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 = compute.ListRegionUrlMapsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/transports/rest.py index 88391751ac3f..e6e09e728059 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_url_maps/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 @@ -37,6 +37,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, @@ -125,8 +133,10 @@ def post_validate(self, response): def pre_delete( self, request: compute.DeleteRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -146,8 +156,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -167,8 +177,10 @@ def post_get(self, response: compute.UrlMap) -> compute.UrlMap: def pre_insert( self, request: compute.InsertRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -188,8 +200,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListRegionUrlMapsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionUrlMapsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListRegionUrlMapsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -209,8 +223,10 @@ def post_list(self, response: compute.UrlMapList) -> compute.UrlMapList: def pre_patch( self, request: compute.PatchRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -230,8 +246,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_update( self, request: compute.UpdateRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -251,8 +269,10 @@ def post_update(self, response: compute.Operation) -> compute.Operation: def pre_validate( self, request: compute.ValidateRegionUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ValidateRegionUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ValidateRegionUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for validate Override in a subclass to manipulate the request or metadata @@ -394,7 +414,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -406,8 +426,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: ~.compute.Operation: @@ -434,6 +456,7 @@ def __call__( http_options = ( _BaseRegionUrlMapsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseDelete._get_transcoded_request( @@ -448,6 +471,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.compute_v1.RegionUrlMapsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Delete._get_response( self._host, @@ -468,7 +518,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionUrlMapsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRegionUrlMapsRestTransport._BaseGet, RegionUrlMapsRestStub): @@ -503,7 +575,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]]] = (), ) -> compute.UrlMap: r"""Call the get method over HTTP. @@ -515,8 +587,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: ~.compute.UrlMap: @@ -549,6 +623,7 @@ def __call__( """ http_options = _BaseRegionUrlMapsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseGet._get_transcoded_request( @@ -563,6 +638,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.compute_v1.RegionUrlMapsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Get._get_response( self._host, @@ -583,7 +685,29 @@ def __call__( pb_resp = compute.UrlMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMap.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.compute_v1.RegionUrlMapsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseRegionUrlMapsRestTransport._BaseInsert, RegionUrlMapsRestStub): @@ -619,7 +743,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -631,8 +755,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: ~.compute.Operation: @@ -659,6 +785,7 @@ def __call__( http_options = ( _BaseRegionUrlMapsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseInsert._get_transcoded_request( @@ -677,6 +804,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.compute_v1.RegionUrlMapsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Insert._get_response( self._host, @@ -698,7 +852,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionUrlMapsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRegionUrlMapsRestTransport._BaseList, RegionUrlMapsRestStub): @@ -733,7 +909,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]]] = (), ) -> compute.UrlMapList: r"""Call the list method over HTTP. @@ -745,8 +921,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: ~.compute.UrlMapList: @@ -754,6 +932,7 @@ def __call__( """ http_options = _BaseRegionUrlMapsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseList._get_transcoded_request( @@ -768,6 +947,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.compute_v1.RegionUrlMapsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._List._get_response( self._host, @@ -788,7 +994,29 @@ def __call__( pb_resp = compute.UrlMapList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMapList.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.compute_v1.RegionUrlMapsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseRegionUrlMapsRestTransport._BasePatch, RegionUrlMapsRestStub): @@ -824,7 +1052,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -836,8 +1064,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: ~.compute.Operation: @@ -864,6 +1094,7 @@ def __call__( http_options = ( _BaseRegionUrlMapsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BasePatch._get_transcoded_request( @@ -882,6 +1113,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.compute_v1.RegionUrlMapsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Patch._get_response( self._host, @@ -903,7 +1161,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionUrlMapsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseRegionUrlMapsRestTransport._BaseUpdate, RegionUrlMapsRestStub): @@ -939,7 +1219,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -951,8 +1231,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: ~.compute.Operation: @@ -979,6 +1261,7 @@ def __call__( http_options = ( _BaseRegionUrlMapsRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseUpdate._get_transcoded_request( @@ -997,6 +1280,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.compute_v1.RegionUrlMapsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Update._get_response( self._host, @@ -1018,7 +1328,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RegionUrlMapsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Validate( @@ -1056,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]]] = (), ) -> compute.UrlMapsValidateResponse: r"""Call the validate method over HTTP. @@ -1068,8 +1400,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: ~.compute.UrlMapsValidateResponse: @@ -1079,6 +1413,7 @@ def __call__( http_options = ( _BaseRegionUrlMapsRestTransport._BaseValidate._get_http_options() ) + request, metadata = self._interceptor.pre_validate(request, metadata) transcoded_request = ( _BaseRegionUrlMapsRestTransport._BaseValidate._get_transcoded_request( @@ -1097,6 +1432,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.compute_v1.RegionUrlMapsClient.Validate", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Validate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionUrlMapsRestTransport._Validate._get_response( self._host, @@ -1118,7 +1480,29 @@ def __call__( pb_resp = compute.UrlMapsValidateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMapsValidateResponse.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.compute_v1.RegionUrlMapsClient.validate", + extra={ + "serviceName": "google.cloud.compute.v1.RegionUrlMaps", + "rpcName": "Validate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/client.py index b7b7de589541..530559c6120b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/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.compute_v1.services.region_zones import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.RegionZonesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.RegionZones", + "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.compute.v1.RegionZones", + "credentialsType": None, + }, + ) + def list( self, request: Optional[Union[compute.ListRegionZonesRequest, dict]] = None, @@ -623,7 +660,7 @@ def list( region: 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.ListPager: r"""Retrieves the list of Zone resources under the specific region available to the specified project. @@ -674,8 +711,10 @@ def sample_list(): 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.compute_v1.services.region_zones.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/pagers.py index 237580a9faa9..a0c3ca873604 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/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 = compute.ListRegionZonesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/transports/rest.py index e14c83074b3d..256ede8e847e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/region_zones/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 @@ -37,6 +37,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, @@ -77,8 +85,8 @@ def post_list(self, response): def pre_list( self, request: compute.ListRegionZonesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListRegionZonesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListRegionZonesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -218,7 +226,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]]] = (), ) -> compute.ZoneList: r"""Call the list method over HTTP. @@ -230,8 +238,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: ~.compute.ZoneList: @@ -239,6 +249,7 @@ def __call__( """ http_options = _BaseRegionZonesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionZonesRestTransport._BaseList._get_transcoded_request( @@ -253,6 +264,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.compute_v1.RegionZonesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.RegionZones", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionZonesRestTransport._List._get_response( self._host, @@ -273,7 +311,29 @@ def __call__( pb_resp = compute.ZoneList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ZoneList.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.compute_v1.RegionZonesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.RegionZones", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/client.py index 51c4d28dd76c..decc780fcfc5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/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.compute_v1.services.regions import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.RegionsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Regions", + "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.compute.v1.Regions", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetRegionRequest, dict]] = None, @@ -623,7 +660,7 @@ def get( region: 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]]] = (), ) -> compute.Region: r"""Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information @@ -689,8 +726,10 @@ def sample_get(): 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.compute_v1.types.Region: @@ -757,7 +796,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can @@ -816,8 +855,10 @@ def sample_list(): 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.compute_v1.services.regions.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/pagers.py index 0696ddf206c8..44857d98879e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/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 = compute.ListRegionsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/transports/rest.py index 234eeb7a0249..f3c963e4cd20 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/regions/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 @@ -37,6 +37,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, @@ -83,8 +91,10 @@ def post_list(self, response): """ def pre_get( - self, request: compute.GetRegionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetRegionRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetRegionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetRegionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_get(self, response: compute.Region) -> compute.Region: return response def pre_list( - self, request: compute.ListRegionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListRegionsRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListRegionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListRegionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -243,7 +255,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]]] = (), ) -> compute.Region: r"""Call the get method over HTTP. @@ -254,8 +266,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: ~.compute.Region: @@ -267,6 +281,7 @@ def __call__( """ http_options = _BaseRegionsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRegionsRestTransport._BaseGet._get_transcoded_request( @@ -279,6 +294,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 = 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.compute_v1.RegionsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Regions", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionsRestTransport._Get._get_response( self._host, @@ -299,7 +341,29 @@ def __call__( pb_resp = compute.Region.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Region.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.compute_v1.RegionsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Regions", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRegionsRestTransport._BaseList, RegionsRestStub): @@ -334,7 +398,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]]] = (), ) -> compute.RegionList: r"""Call the list method over HTTP. @@ -345,8 +409,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: ~.compute.RegionList: @@ -354,6 +420,7 @@ def __call__( """ http_options = _BaseRegionsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRegionsRestTransport._BaseList._get_transcoded_request( @@ -366,6 +433,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 = 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.compute_v1.RegionsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Regions", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegionsRestTransport._List._get_response( self._host, @@ -386,7 +480,29 @@ def __call__( pb_resp = compute.RegionList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RegionList.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.compute_v1.RegionsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Regions", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/client.py index a9353f050c70..7f9b16706854 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.reservations import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.ReservationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "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.compute.v1.Reservations", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -627,7 +664,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of reservations. To prevent failure, Google recommends that you set the @@ -673,8 +710,10 @@ def sample_aggregated_list(): 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.compute_v1.services.reservations.pagers.AggregatedListPager: @@ -748,7 +787,7 @@ def delete_unary( reservation: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified reservation. @@ -803,8 +842,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -874,7 +915,7 @@ def delete( reservation: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified reservation. @@ -929,8 +970,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1025,7 +1068,7 @@ def get( reservation: 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]]] = (), ) -> compute.Reservation: r"""Retrieves information about the specified reservation. @@ -1081,8 +1124,10 @@ def sample_get(): 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.compute_v1.types.Reservation: @@ -1156,7 +1201,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1216,8 +1261,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.cloud.compute_v1.types.Policy: @@ -1307,7 +1354,7 @@ def insert_unary( reservation_resource: Optional[compute.Reservation] = 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]]] = (), ) -> compute.Operation: r"""Creates a new reservation. For more information, read Reserving zonal resources. @@ -1362,8 +1409,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1432,7 +1481,7 @@ def insert( reservation_resource: Optional[compute.Reservation] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new reservation. For more information, read Reserving zonal resources. @@ -1487,8 +1536,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1581,7 +1632,7 @@ def list( zone: 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.ListPager: r"""A list of all the reservations that have been configured for the specified project in specified zone. @@ -1632,8 +1683,10 @@ def sample_list(): 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.compute_v1.services.reservations.pagers.ListPager: @@ -1715,7 +1768,7 @@ def resize_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying @@ -1777,8 +1830,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -1857,7 +1912,7 @@ def resize( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying @@ -1919,8 +1974,10 @@ def sample_resize(): 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.api_core.extended_operation.ExtendedOperation: @@ -2022,7 +2079,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2087,8 +2144,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.cloud.compute_v1.types.Policy: @@ -2189,7 +2248,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2254,8 +2313,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -2330,7 +2391,7 @@ def update_unary( reservation_resource: Optional[compute.Reservation] = 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]]] = (), ) -> compute.Operation: r"""Update share settings of the reservation. @@ -2390,8 +2451,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2464,7 +2527,7 @@ def update( reservation_resource: Optional[compute.Reservation] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Update share settings of the reservation. @@ -2524,8 +2587,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/pagers.py index 1a06cbaf030a..ec47b3d8f92f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/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 = compute.AggregatedListReservationsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListReservationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/transports/rest.py index f306b7539c1e..3451435a917e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/reservations/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 @@ -37,6 +37,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, @@ -149,8 +157,11 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListReservationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListReservationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListReservationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -172,8 +183,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -193,8 +206,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetReservationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -214,8 +227,10 @@ def post_get(self, response: compute.Reservation) -> compute.Reservation: def pre_get_iam_policy( self, request: compute.GetIamPolicyReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -235,8 +250,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -256,8 +273,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListReservationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListReservationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListReservationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -277,8 +296,10 @@ def post_list(self, response: compute.ReservationList) -> compute.ReservationLis def pre_resize( self, request: compute.ResizeReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ResizeReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ResizeReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for resize Override in a subclass to manipulate the request or metadata @@ -298,8 +319,10 @@ def post_resize(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -319,8 +342,11 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsReservationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -342,8 +368,10 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -485,7 +513,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]]] = (), ) -> compute.ReservationAggregatedList: r"""Call the aggregated list method over HTTP. @@ -497,8 +525,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: ~.compute.ReservationAggregatedList: @@ -508,6 +538,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseReservationsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -518,6 +549,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 = 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.compute_v1.ReservationsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._AggregatedList._get_response( self._host, @@ -538,7 +596,31 @@ def __call__( pb_resp = compute.ReservationAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ReservationAggregatedList.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.compute_v1.ReservationsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseReservationsRestTransport._BaseDelete, ReservationsRestStub): @@ -573,7 +655,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -585,8 +667,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: ~.compute.Operation: @@ -613,6 +697,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseDelete._get_transcoded_request( @@ -627,6 +712,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.compute_v1.ReservationsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._Delete._get_response( self._host, @@ -647,7 +759,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ReservationsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseReservationsRestTransport._BaseGet, ReservationsRestStub): @@ -682,7 +816,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]]] = (), ) -> compute.Reservation: r"""Call the get method over HTTP. @@ -694,8 +828,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: ~.compute.Reservation: @@ -709,6 +845,7 @@ def __call__( """ http_options = _BaseReservationsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseGet._get_transcoded_request( @@ -723,6 +860,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.compute_v1.ReservationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._Get._get_response( self._host, @@ -743,7 +907,29 @@ def __call__( pb_resp = compute.Reservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Reservation.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.compute_v1.ReservationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -780,7 +966,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -792,8 +978,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: ~.compute.Policy: @@ -826,6 +1014,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseReservationsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -838,6 +1027,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.compute_v1.ReservationsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._GetIamPolicy._get_response( self._host, @@ -858,7 +1074,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ReservationsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseReservationsRestTransport._BaseInsert, ReservationsRestStub): @@ -894,7 +1132,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -906,8 +1144,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: ~.compute.Operation: @@ -934,6 +1174,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseInsert._get_transcoded_request( @@ -952,6 +1193,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.compute_v1.ReservationsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._Insert._get_response( self._host, @@ -973,7 +1241,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ReservationsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseReservationsRestTransport._BaseList, ReservationsRestStub): @@ -1008,7 +1298,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]]] = (), ) -> compute.ReservationList: r"""Call the list method over HTTP. @@ -1020,8 +1310,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: ~.compute.ReservationList: @@ -1029,6 +1321,7 @@ def __call__( """ http_options = _BaseReservationsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseList._get_transcoded_request( @@ -1043,6 +1336,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.compute_v1.ReservationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._List._get_response( self._host, @@ -1063,7 +1383,29 @@ def __call__( pb_resp = compute.ReservationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ReservationList.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.compute_v1.ReservationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Resize(_BaseReservationsRestTransport._BaseResize, ReservationsRestStub): @@ -1099,7 +1441,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]]] = (), ) -> compute.Operation: r"""Call the resize method over HTTP. @@ -1111,8 +1453,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: ~.compute.Operation: @@ -1139,6 +1483,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseResize._get_http_options() ) + request, metadata = self._interceptor.pre_resize(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseResize._get_transcoded_request( @@ -1157,6 +1502,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.compute_v1.ReservationsClient.Resize", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Resize", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._Resize._get_response( self._host, @@ -1178,7 +1550,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ReservationsClient.resize", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Resize", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1216,7 +1610,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1228,8 +1622,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: ~.compute.Policy: @@ -1262,6 +1658,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseReservationsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1280,6 +1677,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.compute_v1.ReservationsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._SetIamPolicy._get_response( self._host, @@ -1301,7 +1725,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ReservationsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1339,7 +1785,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1351,8 +1797,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: ~.compute.TestPermissionsResponse: @@ -1362,6 +1810,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1378,6 +1827,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 = 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.compute_v1.ReservationsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._TestIamPermissions._get_response( self._host, @@ -1399,7 +1875,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.ReservationsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseReservationsRestTransport._BaseUpdate, ReservationsRestStub): @@ -1435,7 +1933,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1447,8 +1945,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: ~.compute.Operation: @@ -1475,6 +1975,7 @@ def __call__( http_options = ( _BaseReservationsRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseReservationsRestTransport._BaseUpdate._get_transcoded_request( @@ -1493,6 +1994,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.compute_v1.ReservationsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationsRestTransport._Update._get_response( self._host, @@ -1514,7 +2042,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ReservationsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Reservations", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/client.py index 29a86eb90826..ac504cf7992c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.resource_policies import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.ResourcePoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "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.compute.v1.ResourcePolicies", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -635,7 +672,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of resource policies. To prevent failure, Google recommends that you set the @@ -681,8 +718,10 @@ def sample_aggregated_list(): 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.compute_v1.services.resource_policies.pagers.AggregatedListPager: @@ -756,7 +795,7 @@ def delete_unary( resource_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified resource policy. @@ -813,8 +852,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -884,7 +925,7 @@ def delete( resource_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified resource policy. @@ -941,8 +982,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1037,7 +1080,7 @@ def get( resource_policy: 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]]] = (), ) -> compute.ResourcePolicy: r"""Retrieves all information of the specified resource policy. @@ -1095,8 +1138,10 @@ def sample_get(): 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.compute_v1.types.ResourcePolicy: @@ -1172,7 +1217,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1232,8 +1277,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.cloud.compute_v1.types.Policy: @@ -1323,7 +1370,7 @@ def insert_unary( resource_policy_resource: Optional[compute.ResourcePolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new resource policy. @@ -1377,8 +1424,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1447,7 +1496,7 @@ def insert( resource_policy_resource: Optional[compute.ResourcePolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new resource policy. @@ -1501,8 +1550,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1595,7 +1646,7 @@ def list( region: 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.ListPager: r"""A list all the resource policies that have been configured for the specified project in specified @@ -1647,8 +1698,10 @@ def sample_list(): 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.compute_v1.services.resource_policies.pagers.ListPager: @@ -1728,7 +1781,7 @@ def patch_unary( resource_policy_resource: Optional[compute.ResourcePolicy] = 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]]] = (), ) -> compute.Operation: r"""Modify the specified resource policy. @@ -1788,8 +1841,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1864,7 +1919,7 @@ def patch( resource_policy_resource: Optional[compute.ResourcePolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Modify the specified resource policy. @@ -1924,8 +1979,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2029,7 +2086,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2094,8 +2151,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.cloud.compute_v1.types.Policy: @@ -2196,7 +2255,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2261,8 +2320,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/pagers.py index 2b91ebc77413..27b5f9b427d3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/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 = compute.AggregatedListResourcePoliciesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListResourcePoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/transports/rest.py index ac8eefc7af8b..c6844bf8cd3a 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/resource_policies/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 @@ -37,6 +37,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, @@ -141,9 +149,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListResourcePoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListResourcePoliciesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListResourcePoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -166,8 +175,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteResourcePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -187,8 +198,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetResourcePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -208,8 +221,11 @@ def post_get(self, response: compute.ResourcePolicy) -> compute.ResourcePolicy: def pre_get_iam_policy( self, request: compute.GetIamPolicyResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyResourcePolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -229,8 +245,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertResourcePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -250,8 +268,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListResourcePoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListResourcePoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListResourcePoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -273,8 +293,10 @@ def post_list( def pre_patch( self, request: compute.PatchResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchResourcePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -294,8 +316,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyResourcePolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyResourcePolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -315,9 +340,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsResourcePolicyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsResourcePolicyRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsResourcePolicyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -462,7 +488,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]]] = (), ) -> compute.ResourcePolicyAggregatedList: r"""Call the aggregated list method over HTTP. @@ -474,8 +500,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: ~.compute.ResourcePolicyAggregatedList: @@ -485,6 +513,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseResourcePoliciesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -495,6 +524,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 = 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.compute_v1.ResourcePoliciesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._AggregatedList._get_response( self._host, @@ -515,7 +571,31 @@ def __call__( pb_resp = compute.ResourcePolicyAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ResourcePolicyAggregatedList.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.compute_v1.ResourcePoliciesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -552,7 +632,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -564,8 +644,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: ~.compute.Operation: @@ -592,6 +674,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseResourcePoliciesRestTransport._BaseDelete._get_transcoded_request( @@ -606,6 +689,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.compute_v1.ResourcePoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._Delete._get_response( self._host, @@ -626,7 +736,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ResourcePoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseResourcePoliciesRestTransport._BaseGet, ResourcePoliciesRestStub): @@ -661,7 +793,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]]] = (), ) -> compute.ResourcePolicy: r"""Call the get method over HTTP. @@ -673,8 +805,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: ~.compute.ResourcePolicy: @@ -690,6 +824,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseResourcePoliciesRestTransport._BaseGet._get_transcoded_request( @@ -704,6 +839,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.compute_v1.ResourcePoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._Get._get_response( self._host, @@ -724,7 +886,29 @@ def __call__( pb_resp = compute.ResourcePolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ResourcePolicy.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.compute_v1.ResourcePoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -761,7 +945,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -773,8 +957,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: ~.compute.Policy: @@ -807,6 +993,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseResourcePoliciesRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -817,6 +1004,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 = 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.compute_v1.ResourcePoliciesClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._GetIamPolicy._get_response( self._host, @@ -837,7 +1051,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ResourcePoliciesClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -875,7 +1111,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -887,8 +1123,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: ~.compute.Operation: @@ -915,6 +1153,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseResourcePoliciesRestTransport._BaseInsert._get_transcoded_request( @@ -935,6 +1174,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.compute_v1.ResourcePoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._Insert._get_response( self._host, @@ -956,7 +1222,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ResourcePoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseResourcePoliciesRestTransport._BaseList, ResourcePoliciesRestStub): @@ -991,7 +1279,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]]] = (), ) -> compute.ResourcePolicyList: r"""Call the list method over HTTP. @@ -1003,8 +1291,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: ~.compute.ResourcePolicyList: @@ -1014,6 +1304,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseResourcePoliciesRestTransport._BaseList._get_transcoded_request( @@ -1028,6 +1319,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.compute_v1.ResourcePoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._List._get_response( self._host, @@ -1048,7 +1366,29 @@ def __call__( pb_resp = compute.ResourcePolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ResourcePolicyList.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.compute_v1.ResourcePoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1086,7 +1426,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1098,8 +1438,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: ~.compute.Operation: @@ -1126,6 +1468,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseResourcePoliciesRestTransport._BasePatch._get_transcoded_request( @@ -1144,6 +1487,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.compute_v1.ResourcePoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._Patch._get_response( self._host, @@ -1165,7 +1535,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ResourcePoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1203,7 +1595,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1215,8 +1607,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: ~.compute.Policy: @@ -1249,6 +1643,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseResourcePoliciesRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1263,6 +1658,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 = 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.compute_v1.ResourcePoliciesClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._SetIamPolicy._get_response( self._host, @@ -1284,7 +1706,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ResourcePoliciesClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1323,7 +1767,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1335,8 +1779,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: ~.compute.TestPermissionsResponse: @@ -1346,6 +1792,7 @@ def __call__( http_options = ( _BaseResourcePoliciesRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1362,6 +1809,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 = 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.compute_v1.ResourcePoliciesClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ResourcePoliciesRestTransport._TestIamPermissions._get_response( self._host, @@ -1383,7 +1857,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.ResourcePoliciesClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.ResourcePolicies", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/client.py index 434841575504..7c0d840508e2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.routers import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.RoutersClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "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.compute.v1.Routers", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListRoutersRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of routers. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.routers.pagers.AggregatedListPager: @@ -746,7 +785,7 @@ def delete_unary( router: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified Router resource. @@ -802,8 +841,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -873,7 +914,7 @@ def delete( router: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified Router resource. @@ -929,8 +970,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1025,7 +1068,7 @@ def get( router: 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]]] = (), ) -> compute.Router: r"""Returns the specified Router resource. @@ -1081,8 +1124,10 @@ def sample_get(): 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.compute_v1.types.Router: @@ -1153,7 +1198,7 @@ def get_nat_ip_info( router: 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]]] = (), ) -> compute.NatIpInfoResponse: r"""Retrieves runtime NAT IP information. @@ -1211,8 +1256,10 @@ def sample_get_nat_ip_info(): 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.compute_v1.types.NatIpInfoResponse: @@ -1280,7 +1327,7 @@ def get_nat_mapping_info( router: 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.GetNatMappingInfoPager: r"""Retrieves runtime Nat mapping information of VM endpoints. @@ -1340,8 +1387,10 @@ def sample_get_nat_mapping_info(): 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.compute_v1.services.routers.pagers.GetNatMappingInfoPager: @@ -1425,7 +1474,7 @@ def get_router_status( router: 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]]] = (), ) -> compute.RouterStatusResponse: r"""Retrieves runtime information of the specified router. @@ -1481,8 +1530,10 @@ def sample_get_router_status(): 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.compute_v1.types.RouterStatusResponse: @@ -1550,7 +1601,7 @@ def insert_unary( router_resource: Optional[compute.Router] = 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]]] = (), ) -> compute.Operation: r"""Creates a Router resource in the specified project and region using the data included in the request. @@ -1604,8 +1655,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1674,7 +1727,7 @@ def insert( router_resource: Optional[compute.Router] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a Router resource in the specified project and region using the data included in the request. @@ -1728,8 +1781,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1822,7 +1877,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of Router resources available to the specified project. @@ -1872,8 +1927,10 @@ def sample_list(): 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.compute_v1.services.routers.pagers.ListPager: @@ -1955,7 +2012,7 @@ def patch_unary( router_resource: Optional[compute.Router] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified Router resource with the data included in the request. This method supports PATCH @@ -2017,8 +2074,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2091,7 +2150,7 @@ def patch( router_resource: Optional[compute.Router] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified Router resource with the data included in the request. This method supports PATCH @@ -2153,8 +2212,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2252,7 +2313,7 @@ def preview( router_resource: Optional[compute.Router] = 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]]] = (), ) -> compute.RoutersPreviewResponse: r"""Preview fields auto-generated during router create and update operations. Calling this method does NOT @@ -2314,8 +2375,10 @@ def sample_preview(): 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.compute_v1.types.RoutersPreviewResponse: @@ -2386,7 +2449,7 @@ def update_unary( router_resource: Optional[compute.Router] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified Router resource with the data included in the request. This method conforms to PUT @@ -2452,8 +2515,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2526,7 +2591,7 @@ def update( router_resource: Optional[compute.Router] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified Router resource with the data included in the request. This method conforms to PUT @@ -2592,8 +2657,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/pagers.py index 5b414498352a..35694a7cc2d9 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/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 = compute.AggregatedListRoutersRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.GetNatMappingInfoRoutersRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListRoutersRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/transports/rest.py index 858b6b4a44a7..b93cd18f9006 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routers/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 @@ -37,6 +37,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, @@ -157,8 +165,10 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListRoutersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListRoutersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListRoutersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -178,8 +188,10 @@ def post_aggregated_list( return response def pre_delete( - self, request: compute.DeleteRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -197,8 +209,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -218,8 +232,10 @@ def post_get(self, response: compute.Router) -> compute.Router: def pre_get_nat_ip_info( self, request: compute.GetNatIpInfoRouterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNatIpInfoRouterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNatIpInfoRouterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_nat_ip_info Override in a subclass to manipulate the request or metadata @@ -241,8 +257,10 @@ def post_get_nat_ip_info( def pre_get_nat_mapping_info( self, request: compute.GetNatMappingInfoRoutersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetNatMappingInfoRoutersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetNatMappingInfoRoutersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_nat_mapping_info Override in a subclass to manipulate the request or metadata @@ -264,8 +282,10 @@ def post_get_nat_mapping_info( def pre_get_router_status( self, request: compute.GetRouterStatusRouterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRouterStatusRouterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRouterStatusRouterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_router_status Override in a subclass to manipulate the request or metadata @@ -285,8 +305,10 @@ def post_get_router_status( return response def pre_insert( - self, request: compute.InsertRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -304,8 +326,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListRoutersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListRoutersRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListRoutersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListRoutersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -323,8 +347,10 @@ def post_list(self, response: compute.RouterList) -> compute.RouterList: return response def pre_patch( - self, request: compute.PatchRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PatchRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PatchRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -342,8 +368,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: return response def pre_preview( - self, request: compute.PreviewRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PreviewRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PreviewRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PreviewRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for preview Override in a subclass to manipulate the request or metadata @@ -363,8 +391,10 @@ def post_preview( return response def pre_update( - self, request: compute.UpdateRouterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.UpdateRouterRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.UpdateRouterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.UpdateRouterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -506,7 +536,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]]] = (), ) -> compute.RouterAggregatedList: r"""Call the aggregated list method over HTTP. @@ -518,8 +548,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: ~.compute.RouterAggregatedList: @@ -529,6 +561,7 @@ def __call__( http_options = ( _BaseRoutersRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseAggregatedList._get_transcoded_request( @@ -543,6 +576,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.compute_v1.RoutersClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._AggregatedList._get_response( self._host, @@ -563,7 +623,29 @@ def __call__( pb_resp = compute.RouterAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RouterAggregatedList.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.compute_v1.RoutersClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseRoutersRestTransport._BaseDelete, RoutersRestStub): @@ -598,7 +680,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -609,8 +691,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: ~.compute.Operation: @@ -635,6 +719,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseDelete._get_transcoded_request( @@ -647,6 +732,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 = 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.compute_v1.RoutersClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Delete._get_response( self._host, @@ -667,7 +779,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutersClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRoutersRestTransport._BaseGet, RoutersRestStub): @@ -702,7 +836,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]]] = (), ) -> compute.Router: r"""Call the get method over HTTP. @@ -713,8 +847,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: ~.compute.Router: @@ -725,6 +861,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseGet._get_transcoded_request( @@ -737,6 +874,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 = 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.compute_v1.RoutersClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Get._get_response( self._host, @@ -757,7 +921,29 @@ def __call__( pb_resp = compute.Router.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Router.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.compute_v1.RoutersClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNatIpInfo(_BaseRoutersRestTransport._BaseGetNatIpInfo, RoutersRestStub): @@ -792,7 +978,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]]] = (), ) -> compute.NatIpInfoResponse: r"""Call the get nat ip info method over HTTP. @@ -804,8 +990,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: ~.compute.NatIpInfoResponse: @@ -815,6 +1003,7 @@ def __call__( http_options = ( _BaseRoutersRestTransport._BaseGetNatIpInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_nat_ip_info(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseGetNatIpInfo._get_transcoded_request( @@ -829,6 +1018,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.compute_v1.RoutersClient.GetNatIpInfo", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetNatIpInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._GetNatIpInfo._get_response( self._host, @@ -849,7 +1065,29 @@ def __call__( pb_resp = compute.NatIpInfoResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_nat_ip_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.NatIpInfoResponse.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.compute_v1.RoutersClient.get_nat_ip_info", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetNatIpInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNatMappingInfo( @@ -886,7 +1124,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]]] = (), ) -> compute.VmEndpointNatMappingsList: r"""Call the get nat mapping info method over HTTP. @@ -898,8 +1136,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: ~.compute.VmEndpointNatMappingsList: @@ -911,6 +1151,7 @@ def __call__( http_options = ( _BaseRoutersRestTransport._BaseGetNatMappingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_nat_mapping_info( request, metadata ) @@ -925,6 +1166,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.compute_v1.RoutersClient.GetNatMappingInfo", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetNatMappingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._GetNatMappingInfo._get_response( self._host, @@ -945,7 +1213,31 @@ def __call__( pb_resp = compute.VmEndpointNatMappingsList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_nat_mapping_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VmEndpointNatMappingsList.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.compute_v1.RoutersClient.get_nat_mapping_info", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetNatMappingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRouterStatus( @@ -982,7 +1274,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]]] = (), ) -> compute.RouterStatusResponse: r"""Call the get router status method over HTTP. @@ -994,8 +1286,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: ~.compute.RouterStatusResponse: @@ -1005,6 +1299,7 @@ def __call__( http_options = ( _BaseRoutersRestTransport._BaseGetRouterStatus._get_http_options() ) + request, metadata = self._interceptor.pre_get_router_status( request, metadata ) @@ -1021,6 +1316,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.compute_v1.RoutersClient.GetRouterStatus", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetRouterStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._GetRouterStatus._get_response( self._host, @@ -1041,7 +1363,29 @@ def __call__( pb_resp = compute.RouterStatusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_router_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RouterStatusResponse.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.compute_v1.RoutersClient.get_router_status", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "GetRouterStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseRoutersRestTransport._BaseInsert, RoutersRestStub): @@ -1077,7 +1421,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1088,8 +1432,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: ~.compute.Operation: @@ -1114,6 +1460,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseInsert._get_transcoded_request( @@ -1130,6 +1477,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 = 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.compute_v1.RoutersClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Insert._get_response( self._host, @@ -1151,7 +1525,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutersClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRoutersRestTransport._BaseList, RoutersRestStub): @@ -1186,7 +1582,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]]] = (), ) -> compute.RouterList: r"""Call the list method over HTTP. @@ -1197,8 +1593,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: ~.compute.RouterList: @@ -1206,6 +1604,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseList._get_transcoded_request( @@ -1218,6 +1617,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 = 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.compute_v1.RoutersClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._List._get_response( self._host, @@ -1238,7 +1664,29 @@ def __call__( pb_resp = compute.RouterList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RouterList.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.compute_v1.RoutersClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseRoutersRestTransport._BasePatch, RoutersRestStub): @@ -1274,7 +1722,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1285,8 +1733,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: ~.compute.Operation: @@ -1311,6 +1761,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BasePatch._get_transcoded_request( @@ -1327,6 +1778,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 = 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.compute_v1.RoutersClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Patch._get_response( self._host, @@ -1348,7 +1826,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutersClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Preview(_BaseRoutersRestTransport._BasePreview, RoutersRestStub): @@ -1384,7 +1884,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]]] = (), ) -> compute.RoutersPreviewResponse: r"""Call the preview method over HTTP. @@ -1396,8 +1896,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: ~.compute.RoutersPreviewResponse: @@ -1405,6 +1907,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BasePreview._get_http_options() + request, metadata = self._interceptor.pre_preview(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BasePreview._get_transcoded_request( @@ -1423,6 +1926,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.compute_v1.RoutersClient.Preview", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Preview", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Preview._get_response( self._host, @@ -1444,7 +1974,29 @@ def __call__( pb_resp = compute.RoutersPreviewResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_preview(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RoutersPreviewResponse.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.compute_v1.RoutersClient.preview", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Preview", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseRoutersRestTransport._BaseUpdate, RoutersRestStub): @@ -1480,7 +2032,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1491,8 +2043,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: ~.compute.Operation: @@ -1517,6 +2071,7 @@ def __call__( """ http_options = _BaseRoutersRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseRoutersRestTransport._BaseUpdate._get_transcoded_request( @@ -1533,6 +2088,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 = 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.compute_v1.RoutersClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutersRestTransport._Update._get_response( self._host, @@ -1554,7 +2136,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutersClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.Routers", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/client.py index 5602426546eb..90fd226d634e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.routes import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.RoutesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "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.compute.v1.Routes", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteRouteRequest, dict]] = None, @@ -626,7 +663,7 @@ def delete_unary( route: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified Route resource. @@ -674,8 +711,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -741,7 +780,7 @@ def delete( route: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified Route resource. @@ -789,8 +828,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -880,7 +921,7 @@ def get( route: 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]]] = (), ) -> compute.Route: r"""Returns the specified Route resource. @@ -928,8 +969,10 @@ def sample_get(): 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.compute_v1.types.Route: @@ -999,7 +1042,7 @@ def insert_unary( route_resource: Optional[compute.Route] = 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]]] = (), ) -> compute.Operation: r"""Creates a Route resource in the specified project using the data included in the request. @@ -1047,8 +1090,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1109,7 +1154,7 @@ def insert( route_resource: Optional[compute.Route] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a Route resource in the specified project using the data included in the request. @@ -1157,8 +1202,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1242,7 +1289,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of Route resources available to the specified project. @@ -1286,8 +1333,10 @@ def sample_list(): 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.compute_v1.services.routes.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/pagers.py index c0741a76c5a7..857e40793323 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/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 = compute.ListRoutesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/transports/rest.py index ecb7192a4442..a973f61e35ce 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/routes/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 @@ -37,6 +37,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, @@ -99,8 +107,10 @@ def post_list(self, response): """ def pre_delete( - self, request: compute.DeleteRouteRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteRouteRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteRouteRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteRouteRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -118,8 +128,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetRouteRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetRouteRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetRouteRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetRouteRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -137,8 +149,10 @@ def post_get(self, response: compute.Route) -> compute.Route: return response def pre_insert( - self, request: compute.InsertRouteRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertRouteRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertRouteRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertRouteRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -156,8 +170,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListRoutesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListRoutesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListRoutesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListRoutesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -297,7 +313,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -308,8 +324,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: ~.compute.Operation: @@ -334,6 +352,7 @@ def __call__( """ http_options = _BaseRoutesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseRoutesRestTransport._BaseDelete._get_transcoded_request( @@ -346,6 +365,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 = 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.compute_v1.RoutesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutesRestTransport._Delete._get_response( self._host, @@ -366,7 +412,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseRoutesRestTransport._BaseGet, RoutesRestStub): @@ -401,7 +469,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]]] = (), ) -> compute.Route: r"""Call the get method over HTTP. @@ -412,8 +480,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: ~.compute.Route: @@ -427,6 +497,7 @@ def __call__( """ http_options = _BaseRoutesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseRoutesRestTransport._BaseGet._get_transcoded_request( @@ -439,6 +510,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 = 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.compute_v1.RoutesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutesRestTransport._Get._get_response( self._host, @@ -459,7 +557,29 @@ def __call__( pb_resp = compute.Route.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Route.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.compute_v1.RoutesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseRoutesRestTransport._BaseInsert, RoutesRestStub): @@ -495,7 +615,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -506,8 +626,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: ~.compute.Operation: @@ -532,6 +654,7 @@ def __call__( """ http_options = _BaseRoutesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseRoutesRestTransport._BaseInsert._get_transcoded_request( @@ -548,6 +671,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 = 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.compute_v1.RoutesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutesRestTransport._Insert._get_response( self._host, @@ -569,7 +719,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.RoutesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseRoutesRestTransport._BaseList, RoutesRestStub): @@ -604,7 +776,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]]] = (), ) -> compute.RouteList: r"""Call the list method over HTTP. @@ -615,8 +787,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: ~.compute.RouteList: @@ -624,6 +798,7 @@ def __call__( """ http_options = _BaseRoutesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseRoutesRestTransport._BaseList._get_transcoded_request( @@ -636,6 +811,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 = 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.compute_v1.RoutesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoutesRestTransport._List._get_response( self._host, @@ -656,7 +858,29 @@ def __call__( pb_resp = compute.RouteList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.RouteList.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.compute_v1.RoutesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Routes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/client.py index 1a489a6fa42f..1ff21e572484 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.security_policies import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.SecurityPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "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.compute.v1.SecurityPolicies", + "credentialsType": None, + }, + ) + def add_rule_unary( self, request: Optional[Union[compute.AddRuleSecurityPolicyRequest, dict]] = None, @@ -635,7 +672,7 @@ def add_rule_unary( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Inserts a rule into a security policy. @@ -691,8 +728,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -763,7 +802,7 @@ def add_rule( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Inserts a rule into a security policy. @@ -819,8 +858,10 @@ def sample_add_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -915,7 +956,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. To prevent failure, @@ -964,8 +1005,10 @@ def sample_aggregated_list(): 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.compute_v1.services.security_policies.pagers.AggregatedListPager: @@ -1036,7 +1079,7 @@ def delete_unary( security_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified policy. @@ -1087,8 +1130,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1154,7 +1199,7 @@ def delete( security_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified policy. @@ -1205,8 +1250,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1296,7 +1343,7 @@ def get( security_policy: 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]]] = (), ) -> compute.SecurityPolicy: r"""List all of the ordered rules present in a single specified policy. @@ -1346,8 +1393,10 @@ def sample_get(): 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.compute_v1.types.SecurityPolicy: @@ -1417,7 +1466,7 @@ def get_rule( security_policy: 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]]] = (), ) -> compute.SecurityPolicyRule: r"""Gets a rule at the specified priority. @@ -1468,8 +1517,10 @@ def sample_get_rule(): 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.compute_v1.types.SecurityPolicyRule: @@ -1537,7 +1588,7 @@ def insert_unary( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> compute.Operation: r"""Creates a new policy in the specified project using the data included in the request. @@ -1586,8 +1637,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1648,7 +1701,7 @@ def insert( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a new policy in the specified project using the data included in the request. @@ -1697,8 +1750,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1782,7 +1837,7 @@ def list( project: 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.ListPager: r"""List all the policies that have been configured for the specified project. @@ -1827,8 +1882,10 @@ def sample_list(): 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.compute_v1.services.security_policies.pagers.ListPager: @@ -1900,7 +1957,7 @@ def list_preconfigured_expression_sets( project: 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]]] = (), ) -> compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse: r"""Gets the current list of preconfigured Web Application Firewall (WAF) expressions. @@ -1944,8 +2001,10 @@ def sample_list_preconfigured_expression_sets(): 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.compute_v1.types.SecurityPoliciesListPreconfiguredExpressionSetsResponse: @@ -2009,7 +2068,7 @@ def patch_unary( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified policy with the data included in the request. To clear fields in the policy, leave the @@ -2070,8 +2129,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2140,7 +2201,7 @@ def patch( security_policy_resource: Optional[compute.SecurityPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified policy with the data included in the request. To clear fields in the policy, leave the @@ -2201,8 +2262,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2295,7 +2358,7 @@ def patch_rule_unary( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> compute.Operation: r"""Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify @@ -2353,8 +2416,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2425,7 +2490,7 @@ def patch_rule( security_policy_rule_resource: Optional[compute.SecurityPolicyRule] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify @@ -2483,8 +2548,10 @@ def sample_patch_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2578,7 +2645,7 @@ def remove_rule_unary( security_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes a rule at the specified priority. @@ -2629,8 +2696,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2696,7 +2765,7 @@ def remove_rule( security_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes a rule at the specified priority. @@ -2747,8 +2816,10 @@ def sample_remove_rule(): 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.api_core.extended_operation.ExtendedOperation: @@ -2841,7 +2912,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. @@ -2898,8 +2969,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2974,7 +3047,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. @@ -3031,8 +3104,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/pagers.py index e97c5f813db7..4b0323b97abc 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/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 = compute.AggregatedListSecurityPoliciesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListSecurityPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/transports/rest.py index 8f294afa4d20..bce161ff8039 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/security_policies/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 @@ -37,6 +37,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, @@ -165,8 +173,10 @@ def post_set_labels(self, response): def pre_add_rule( self, request: compute.AddRuleSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddRuleSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddRuleSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_rule Override in a subclass to manipulate the request or metadata @@ -186,9 +196,10 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: def pre_aggregated_list( self, request: compute.AggregatedListSecurityPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListSecurityPoliciesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListSecurityPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -211,8 +222,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -232,8 +245,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -253,8 +268,10 @@ def post_get(self, response: compute.SecurityPolicy) -> compute.SecurityPolicy: def pre_get_rule( self, request: compute.GetRuleSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetRuleSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetRuleSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_rule Override in a subclass to manipulate the request or metadata @@ -276,8 +293,10 @@ def post_get_rule( def pre_insert( self, request: compute.InsertSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -297,8 +316,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListSecurityPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListSecurityPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListSecurityPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -320,10 +341,10 @@ def post_list( def pre_list_preconfigured_expression_sets( self, request: compute.ListPreconfiguredExpressionSetsSecurityPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ compute.ListPreconfiguredExpressionSetsSecurityPoliciesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_preconfigured_expression_sets @@ -346,8 +367,10 @@ def post_list_preconfigured_expression_sets( def pre_patch( self, request: compute.PatchSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -367,8 +390,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_patch_rule( self, request: compute.PatchRuleSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchRuleSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchRuleSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch_rule Override in a subclass to manipulate the request or metadata @@ -388,8 +413,10 @@ def post_patch_rule(self, response: compute.Operation) -> compute.Operation: def pre_remove_rule( self, request: compute.RemoveRuleSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveRuleSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveRuleSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_rule Override in a subclass to manipulate the request or metadata @@ -409,8 +436,10 @@ def post_remove_rule(self, response: compute.Operation) -> compute.Operation: def pre_set_labels( self, request: compute.SetLabelsSecurityPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsSecurityPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsSecurityPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -553,7 +582,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]]] = (), ) -> compute.Operation: r"""Call the add rule method over HTTP. @@ -565,8 +594,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: ~.compute.Operation: @@ -593,6 +624,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseAddRule._get_http_options() ) + request, metadata = self._interceptor.pre_add_rule(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseAddRule._get_transcoded_request( @@ -613,6 +645,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.compute_v1.SecurityPoliciesClient.AddRule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "AddRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._AddRule._get_response( self._host, @@ -634,7 +693,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.add_rule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "AddRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -671,7 +752,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]]] = (), ) -> compute.SecurityPoliciesAggregatedList: r"""Call the aggregated list method over HTTP. @@ -683,8 +764,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: ~.compute.SecurityPoliciesAggregatedList: @@ -694,6 +777,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseSecurityPoliciesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -704,6 +788,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 = 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.compute_v1.SecurityPoliciesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._AggregatedList._get_response( self._host, @@ -724,7 +835,31 @@ def __call__( pb_resp = compute.SecurityPoliciesAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPoliciesAggregatedList.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.compute_v1.SecurityPoliciesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -761,7 +896,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -773,8 +908,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: ~.compute.Operation: @@ -801,6 +938,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseDelete._get_transcoded_request( @@ -815,6 +953,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.compute_v1.SecurityPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._Delete._get_response( self._host, @@ -835,7 +1000,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseSecurityPoliciesRestTransport._BaseGet, SecurityPoliciesRestStub): @@ -870,7 +1057,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]]] = (), ) -> compute.SecurityPolicy: r"""Call the get method over HTTP. @@ -882,8 +1069,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: ~.compute.SecurityPolicy: @@ -899,6 +1088,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseGet._get_transcoded_request( @@ -913,6 +1103,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.compute_v1.SecurityPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._Get._get_response( self._host, @@ -933,7 +1150,29 @@ def __call__( pb_resp = compute.SecurityPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicy.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.compute_v1.SecurityPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -970,7 +1209,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]]] = (), ) -> compute.SecurityPolicyRule: r"""Call the get rule method over HTTP. @@ -982,8 +1221,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: ~.compute.SecurityPolicyRule: @@ -997,6 +1238,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseGetRule._get_transcoded_request( @@ -1011,6 +1253,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.compute_v1.SecurityPoliciesClient.GetRule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._GetRule._get_response( self._host, @@ -1031,7 +1300,29 @@ def __call__( pb_resp = compute.SecurityPolicyRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicyRule.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.compute_v1.SecurityPoliciesClient.get_rule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -1069,7 +1360,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1081,8 +1372,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: ~.compute.Operation: @@ -1109,6 +1402,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseInsert._get_transcoded_request( @@ -1129,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 = 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.compute_v1.SecurityPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._Insert._get_response( self._host, @@ -1150,7 +1471,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseSecurityPoliciesRestTransport._BaseList, SecurityPoliciesRestStub): @@ -1185,7 +1528,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]]] = (), ) -> compute.SecurityPolicyList: r"""Call the list method over HTTP. @@ -1197,8 +1540,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: ~.compute.SecurityPolicyList: @@ -1208,6 +1553,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BaseList._get_transcoded_request( @@ -1222,6 +1568,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.compute_v1.SecurityPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._List._get_response( self._host, @@ -1242,7 +1615,29 @@ def __call__( pb_resp = compute.SecurityPolicyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPolicyList.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.compute_v1.SecurityPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPreconfiguredExpressionSets( @@ -1280,7 +1675,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]]] = (), ) -> compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse: r"""Call the list preconfigured expression sets method over HTTP. @@ -1293,8 +1688,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: ~.compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse: @@ -1304,6 +1701,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseListPreconfiguredExpressionSets._get_http_options() ) + ( request, metadata, @@ -1319,6 +1717,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 = 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.compute_v1.SecurityPoliciesClient.ListPreconfiguredExpressionSets", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "ListPreconfiguredExpressionSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._ListPreconfiguredExpressionSets._get_response( self._host, @@ -1341,7 +1766,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_preconfigured_expression_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse.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.compute_v1.SecurityPoliciesClient.list_preconfigured_expression_sets", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "ListPreconfiguredExpressionSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1379,7 +1828,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1391,8 +1840,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: ~.compute.Operation: @@ -1419,6 +1870,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseSecurityPoliciesRestTransport._BasePatch._get_transcoded_request( @@ -1437,6 +1889,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.compute_v1.SecurityPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._Patch._get_response( self._host, @@ -1458,7 +1937,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PatchRule( @@ -1496,7 +1997,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]]] = (), ) -> compute.Operation: r"""Call the patch rule method over HTTP. @@ -1508,8 +2009,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: ~.compute.Operation: @@ -1536,6 +2039,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BasePatchRule._get_http_options() ) + request, metadata = self._interceptor.pre_patch_rule(request, metadata) transcoded_request = _BaseSecurityPoliciesRestTransport._BasePatchRule._get_transcoded_request( http_options, request @@ -1550,6 +2054,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 = 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.compute_v1.SecurityPoliciesClient.PatchRule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "PatchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._PatchRule._get_response( self._host, @@ -1571,7 +2102,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.patch_rule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "PatchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveRule( @@ -1608,7 +2161,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]]] = (), ) -> compute.Operation: r"""Call the remove rule method over HTTP. @@ -1620,8 +2173,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: ~.compute.Operation: @@ -1648,6 +2203,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseRemoveRule._get_http_options() ) + request, metadata = self._interceptor.pre_remove_rule(request, metadata) transcoded_request = _BaseSecurityPoliciesRestTransport._BaseRemoveRule._get_transcoded_request( http_options, request @@ -1658,6 +2214,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 = 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.compute_v1.SecurityPoliciesClient.RemoveRule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "RemoveRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._RemoveRule._get_response( self._host, @@ -1678,7 +2261,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.remove_rule", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "RemoveRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -1716,7 +2321,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1728,8 +2333,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: ~.compute.Operation: @@ -1756,6 +2363,7 @@ def __call__( http_options = ( _BaseSecurityPoliciesRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseSecurityPoliciesRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -1770,6 +2378,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 = 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.compute_v1.SecurityPoliciesClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SecurityPoliciesRestTransport._SetLabels._get_response( self._host, @@ -1791,7 +2426,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SecurityPoliciesClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.SecurityPolicies", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/client.py index 473c5260eca9..7c34bed46ae0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.service_attachments import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.ServiceAttachmentsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "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.compute.v1.ServiceAttachments", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project. To prevent @@ -686,8 +723,10 @@ def sample_aggregated_list(): 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.compute_v1.services.service_attachments.pagers.AggregatedListPager: @@ -761,7 +800,7 @@ def delete_unary( service_attachment: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified ServiceAttachment in the given scope @@ -819,8 +858,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -890,7 +931,7 @@ def delete( service_attachment: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified ServiceAttachment in the given scope @@ -948,8 +989,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1044,7 +1087,7 @@ def get( service_attachment: 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]]] = (), ) -> compute.ServiceAttachment: r"""Returns the specified ServiceAttachment resource in the given scope. @@ -1102,8 +1145,10 @@ def sample_get(): 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.compute_v1.types.ServiceAttachment: @@ -1181,7 +1226,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1241,8 +1286,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.cloud.compute_v1.types.Policy: @@ -1332,7 +1379,7 @@ def insert_unary( service_attachment_resource: Optional[compute.ServiceAttachment] = 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]]] = (), ) -> compute.Operation: r"""Creates a ServiceAttachment in the specified project in the given scope using the parameters that are @@ -1388,8 +1435,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1458,7 +1507,7 @@ def insert( service_attachment_resource: Optional[compute.ServiceAttachment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a ServiceAttachment in the specified project in the given scope using the parameters that are @@ -1514,8 +1563,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1608,7 +1659,7 @@ def list( region: 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.ListPager: r"""Lists the ServiceAttachments for a project in the given scope. @@ -1659,8 +1710,10 @@ def sample_list(): 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.compute_v1.services.service_attachments.pagers.ListPager: @@ -1740,7 +1793,7 @@ def patch_unary( service_attachment_resource: Optional[compute.ServiceAttachment] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified ServiceAttachment resource with the data included in the request. This method supports @@ -1809,8 +1862,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1885,7 +1940,7 @@ def patch( service_attachment_resource: Optional[compute.ServiceAttachment] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified ServiceAttachment resource with the data included in the request. This method supports @@ -1954,8 +2009,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2059,7 +2116,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2124,8 +2181,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.cloud.compute_v1.types.Policy: @@ -2226,7 +2285,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2291,8 +2350,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/pagers.py index 8efff3be515d..c3212aa733f5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/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 = compute.AggregatedListServiceAttachmentsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListServiceAttachmentsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/transports/rest.py index d48cd391afc8..85c9177639c3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/service_attachments/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 @@ -37,6 +37,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, @@ -141,9 +149,10 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListServiceAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListServiceAttachmentsRequest, Sequence[Tuple[str, str]] + compute.AggregatedListServiceAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -166,8 +175,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteServiceAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -187,8 +198,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetServiceAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -210,8 +223,11 @@ def post_get( def pre_get_iam_policy( self, request: compute.GetIamPolicyServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyServiceAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -231,8 +247,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertServiceAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -252,8 +270,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListServiceAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListServiceAttachmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListServiceAttachmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -275,8 +295,10 @@ def post_list( def pre_patch( self, request: compute.PatchServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchServiceAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -296,8 +318,11 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicyServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyServiceAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyServiceAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -317,9 +342,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsServiceAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.TestIamPermissionsServiceAttachmentRequest, Sequence[Tuple[str, str]] + compute.TestIamPermissionsServiceAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for test_iam_permissions @@ -465,7 +491,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]]] = (), ) -> compute.ServiceAttachmentAggregatedList: r"""Call the aggregated list method over HTTP. @@ -477,8 +503,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: ~.compute.ServiceAttachmentAggregatedList: @@ -490,6 +518,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseServiceAttachmentsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -500,6 +529,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 = 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.compute_v1.ServiceAttachmentsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._AggregatedList._get_response( self._host, @@ -520,7 +576,31 @@ def __call__( pb_resp = compute.ServiceAttachmentAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ServiceAttachmentAggregatedList.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.compute_v1.ServiceAttachmentsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -557,7 +637,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -569,8 +649,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: ~.compute.Operation: @@ -597,6 +679,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseServiceAttachmentsRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -609,6 +692,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.compute_v1.ServiceAttachmentsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._Delete._get_response( self._host, @@ -629,7 +739,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ServiceAttachmentsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -666,7 +798,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]]] = (), ) -> compute.ServiceAttachment: r"""Call the get method over HTTP. @@ -678,8 +810,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: ~.compute.ServiceAttachment: @@ -697,6 +831,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseServiceAttachmentsRestTransport._BaseGet._get_transcoded_request( @@ -711,6 +846,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.compute_v1.ServiceAttachmentsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._Get._get_response( self._host, @@ -731,7 +893,29 @@ def __call__( pb_resp = compute.ServiceAttachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ServiceAttachment.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.compute_v1.ServiceAttachmentsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -769,7 +953,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -781,8 +965,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: ~.compute.Policy: @@ -815,6 +1001,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseServiceAttachmentsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -825,6 +1012,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 = 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.compute_v1.ServiceAttachmentsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._GetIamPolicy._get_response( self._host, @@ -845,7 +1059,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ServiceAttachmentsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -883,7 +1119,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -895,8 +1131,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: ~.compute.Operation: @@ -923,6 +1161,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseServiceAttachmentsRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -941,6 +1180,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.compute_v1.ServiceAttachmentsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._Insert._get_response( self._host, @@ -962,7 +1228,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ServiceAttachmentsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -999,7 +1287,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]]] = (), ) -> compute.ServiceAttachmentList: r"""Call the list method over HTTP. @@ -1011,8 +1299,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: ~.compute.ServiceAttachmentList: @@ -1022,6 +1312,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseServiceAttachmentsRestTransport._BaseList._get_transcoded_request( @@ -1036,6 +1327,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.compute_v1.ServiceAttachmentsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._List._get_response( self._host, @@ -1056,7 +1374,29 @@ def __call__( pb_resp = compute.ServiceAttachmentList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ServiceAttachmentList.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.compute_v1.ServiceAttachmentsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1094,7 +1434,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1106,8 +1446,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: ~.compute.Operation: @@ -1134,6 +1476,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseServiceAttachmentsRestTransport._BasePatch._get_transcoded_request( @@ -1154,6 +1497,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.compute_v1.ServiceAttachmentsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._Patch._get_response( self._host, @@ -1175,7 +1545,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ServiceAttachmentsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1214,7 +1606,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1226,8 +1618,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: ~.compute.Policy: @@ -1260,6 +1654,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseServiceAttachmentsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1274,6 +1669,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 = 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.compute_v1.ServiceAttachmentsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServiceAttachmentsRestTransport._SetIamPolicy._get_response( self._host, @@ -1295,7 +1717,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.ServiceAttachmentsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1334,7 +1778,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1346,8 +1790,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: ~.compute.TestPermissionsResponse: @@ -1357,6 +1803,7 @@ def __call__( http_options = ( _BaseServiceAttachmentsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1373,6 +1820,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 = 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.compute_v1.ServiceAttachmentsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ServiceAttachmentsRestTransport._TestIamPermissions._get_response( @@ -1396,7 +1870,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.ServiceAttachmentsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.ServiceAttachments", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/client.py index db5865f609cc..39f1664f6682 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.types import compute @@ -565,6 +575,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( @@ -631,6 +645,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.compute_v1.SnapshotSettingsServiceClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.SnapshotSettingsService", + "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.compute.v1.SnapshotSettingsService", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetSnapshotSettingRequest, dict]] = None, @@ -638,7 +675,7 @@ def get( project: 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]]] = (), ) -> compute.SnapshotSettings: r"""Get snapshot settings. @@ -681,8 +718,10 @@ def sample_get(): 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.compute_v1.types.SnapshotSettings: @@ -739,7 +778,7 @@ def patch_unary( snapshot_settings_resource: Optional[compute.SnapshotSettings] = 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]]] = (), ) -> compute.Operation: r"""Patch snapshot settings. @@ -787,8 +826,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -849,7 +890,7 @@ def patch( snapshot_settings_resource: Optional[compute.SnapshotSettings] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patch snapshot settings. @@ -897,8 +938,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/transports/rest.py index 1d04b6155ca8..5411c1eb79f5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshot_settings_service/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 @@ -37,6 +37,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, @@ -85,8 +93,10 @@ def post_patch(self, response): def pre_get( self, request: compute.GetSnapshotSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetSnapshotSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetSnapshotSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -106,8 +116,10 @@ def post_get(self, response: compute.SnapshotSettings) -> compute.SnapshotSettin def pre_patch( self, request: compute.PatchSnapshotSettingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchSnapshotSettingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchSnapshotSettingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -250,7 +262,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]]] = (), ) -> compute.SnapshotSettings: r"""Call the get method over HTTP. @@ -262,8 +274,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: ~.compute.SnapshotSettings: @@ -273,6 +287,7 @@ def __call__( http_options = ( _BaseSnapshotSettingsServiceRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = _BaseSnapshotSettingsServiceRestTransport._BaseGet._get_transcoded_request( http_options, request @@ -283,6 +298,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 = 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.compute_v1.SnapshotSettingsServiceClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.SnapshotSettingsService", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotSettingsServiceRestTransport._Get._get_response( self._host, @@ -303,7 +345,29 @@ def __call__( pb_resp = compute.SnapshotSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SnapshotSettings.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.compute_v1.SnapshotSettingsServiceClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.SnapshotSettingsService", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -342,7 +406,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -354,8 +418,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: ~.compute.Operation: @@ -382,6 +448,7 @@ def __call__( http_options = ( _BaseSnapshotSettingsServiceRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = _BaseSnapshotSettingsServiceRestTransport._BasePatch._get_transcoded_request( http_options, request @@ -396,6 +463,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 = 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.compute_v1.SnapshotSettingsServiceClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.SnapshotSettingsService", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotSettingsServiceRestTransport._Patch._get_response( self._host, @@ -417,7 +511,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SnapshotSettingsServiceClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.SnapshotSettingsService", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/client.py index ab2732030918..676dd0a725a7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.snapshots import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.SnapshotsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "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.compute.v1.Snapshots", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteSnapshotRequest, dict]] = None, @@ -626,7 +663,7 @@ def delete_unary( snapshot: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily @@ -683,8 +720,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -750,7 +789,7 @@ def delete( snapshot: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily @@ -807,8 +846,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -898,7 +939,7 @@ def get( snapshot: 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]]] = (), ) -> compute.Snapshot: r"""Returns the specified Snapshot resource. @@ -948,8 +989,10 @@ def sample_get(): 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.compute_v1.types.Snapshot: @@ -1018,7 +1061,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1070,8 +1113,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.cloud.compute_v1.types.Policy: @@ -1157,7 +1202,7 @@ def insert_unary( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> compute.Operation: r"""Creates a snapshot in the specified project using the data included in the request. For regular snapshot @@ -1210,8 +1255,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1272,7 +1319,7 @@ def insert( snapshot_resource: Optional[compute.Snapshot] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a snapshot in the specified project using the data included in the request. For regular snapshot @@ -1325,8 +1372,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1410,7 +1459,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of Snapshot resources contained within the specified project. @@ -1454,8 +1503,10 @@ def sample_list(): 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.compute_v1.services.snapshots.pagers.ListPager: @@ -1531,7 +1582,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1588,8 +1639,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.cloud.compute_v1.types.Policy: @@ -1684,7 +1737,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. @@ -1741,8 +1794,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1817,7 +1872,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. @@ -1874,8 +1929,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1976,7 +2033,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2033,8 +2090,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/pagers.py index b826b8cd8d3e..0dc1c0dfa68c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/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 = compute.ListSnapshotsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/transports/rest.py index 0f7f6858ea79..80fa5237ebbe 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/snapshots/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 @@ -37,6 +37,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, @@ -133,8 +141,8 @@ def post_test_iam_permissions(self, response): def pre_delete( self, request: compute.DeleteSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -152,8 +160,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetSnapshotRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetSnapshotRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetSnapshotRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -173,8 +183,10 @@ def post_get(self, response: compute.Snapshot) -> compute.Snapshot: def pre_get_iam_policy( self, request: compute.GetIamPolicySnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicySnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicySnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -194,8 +206,8 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -213,8 +225,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: return response def pre_list( - self, request: compute.ListSnapshotsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListSnapshotsRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListSnapshotsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListSnapshotsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -234,8 +248,10 @@ def post_list(self, response: compute.SnapshotList) -> compute.SnapshotList: def pre_set_iam_policy( self, request: compute.SetIamPolicySnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicySnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicySnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -255,8 +271,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_labels( self, request: compute.SetLabelsSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -276,8 +294,11 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -419,7 +440,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -431,8 +452,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: ~.compute.Operation: @@ -457,6 +480,7 @@ def __call__( """ http_options = _BaseSnapshotsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseDelete._get_transcoded_request( @@ -471,6 +495,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.compute_v1.SnapshotsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._Delete._get_response( self._host, @@ -491,7 +542,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SnapshotsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseSnapshotsRestTransport._BaseGet, SnapshotsRestStub): @@ -526,7 +599,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]]] = (), ) -> compute.Snapshot: r"""Call the get method over HTTP. @@ -537,8 +610,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: ~.compute.Snapshot: @@ -551,6 +626,7 @@ def __call__( """ http_options = _BaseSnapshotsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseGet._get_transcoded_request( @@ -563,6 +639,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 = 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.compute_v1.SnapshotsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._Get._get_response( self._host, @@ -583,7 +686,29 @@ def __call__( pb_resp = compute.Snapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Snapshot.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.compute_v1.SnapshotsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -620,7 +745,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -632,8 +757,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: ~.compute.Policy: @@ -666,6 +793,7 @@ def __call__( http_options = ( _BaseSnapshotsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -680,6 +808,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.compute_v1.SnapshotsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._GetIamPolicy._get_response( self._host, @@ -700,7 +855,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.SnapshotsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseSnapshotsRestTransport._BaseInsert, SnapshotsRestStub): @@ -736,7 +913,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -748,8 +925,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: ~.compute.Operation: @@ -774,6 +953,7 @@ def __call__( """ http_options = _BaseSnapshotsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseInsert._get_transcoded_request( @@ -792,6 +972,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.compute_v1.SnapshotsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._Insert._get_response( self._host, @@ -813,7 +1020,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SnapshotsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseSnapshotsRestTransport._BaseList, SnapshotsRestStub): @@ -848,7 +1077,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]]] = (), ) -> compute.SnapshotList: r"""Call the list method over HTTP. @@ -859,8 +1088,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: ~.compute.SnapshotList: @@ -870,6 +1101,7 @@ def __call__( """ http_options = _BaseSnapshotsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseList._get_transcoded_request( @@ -882,6 +1114,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 = 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.compute_v1.SnapshotsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._List._get_response( self._host, @@ -902,7 +1161,29 @@ def __call__( pb_resp = compute.SnapshotList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SnapshotList.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.compute_v1.SnapshotsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -940,7 +1221,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -952,8 +1233,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: ~.compute.Policy: @@ -986,6 +1269,7 @@ def __call__( http_options = ( _BaseSnapshotsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1004,6 +1288,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.compute_v1.SnapshotsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._SetIamPolicy._get_response( self._host, @@ -1025,7 +1336,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.SnapshotsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseSnapshotsRestTransport._BaseSetLabels, SnapshotsRestStub): @@ -1061,7 +1394,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1073,8 +1406,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: ~.compute.Operation: @@ -1101,6 +1436,7 @@ def __call__( http_options = ( _BaseSnapshotsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseSnapshotsRestTransport._BaseSetLabels._get_transcoded_request( @@ -1119,6 +1455,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.compute_v1.SnapshotsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._SetLabels._get_response( self._host, @@ -1140,7 +1503,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SnapshotsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1178,7 +1563,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1190,8 +1575,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: ~.compute.TestPermissionsResponse: @@ -1201,6 +1588,7 @@ def __call__( http_options = ( _BaseSnapshotsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1217,6 +1605,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 = 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.compute_v1.SnapshotsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SnapshotsRestTransport._TestIamPermissions._get_response( self._host, @@ -1238,7 +1653,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.SnapshotsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Snapshots", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/client.py index cce8256d7fc3..7da7fb9a85b2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.ssl_certificates import pagers @@ -560,6 +570,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( @@ -625,6 +639,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.compute_v1.SslCertificatesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "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.compute.v1.SslCertificates", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -634,7 +671,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all SslCertificate resources, regional and global, available to the specified project. To prevent failure, @@ -683,8 +720,10 @@ def sample_aggregated_list(): 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.compute_v1.services.ssl_certificates.pagers.AggregatedListPager: @@ -755,7 +794,7 @@ def delete_unary( ssl_certificate: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified SslCertificate resource. @@ -806,8 +845,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -873,7 +914,7 @@ def delete( ssl_certificate: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified SslCertificate resource. @@ -924,8 +965,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1015,7 +1058,7 @@ def get( ssl_certificate: 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]]] = (), ) -> compute.SslCertificate: r"""Returns the specified SslCertificate resource. @@ -1066,8 +1109,10 @@ def sample_get(): 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.compute_v1.types.SslCertificate: @@ -1151,7 +1196,7 @@ def insert_unary( ssl_certificate_resource: Optional[compute.SslCertificate] = 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]]] = (), ) -> compute.Operation: r"""Creates a SslCertificate resource in the specified project using the data included in the request. @@ -1200,8 +1245,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1262,7 +1309,7 @@ def insert( ssl_certificate_resource: Optional[compute.SslCertificate] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a SslCertificate resource in the specified project using the data included in the request. @@ -1311,8 +1358,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1396,7 +1445,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of SslCertificate resources available to the specified project. @@ -1441,8 +1490,10 @@ def sample_list(): 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.compute_v1.services.ssl_certificates.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/pagers.py index b012f5f4f042..5a4ecb0b3980 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/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 = compute.AggregatedListSslCertificatesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListSslCertificatesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/transports/rest.py index beed69693a2c..8728a4510312 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_certificates/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 @@ -37,6 +37,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, @@ -109,8 +117,11 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListSslCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListSslCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListSslCertificatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -132,8 +143,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteSslCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -153,8 +166,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetSslCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -174,8 +189,10 @@ def post_get(self, response: compute.SslCertificate) -> compute.SslCertificate: def pre_insert( self, request: compute.InsertSslCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertSslCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertSslCertificateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -195,8 +212,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListSslCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListSslCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListSslCertificatesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -340,7 +359,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]]] = (), ) -> compute.SslCertificateAggregatedList: r"""Call the aggregated list method over HTTP. @@ -352,8 +371,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: ~.compute.SslCertificateAggregatedList: @@ -363,6 +384,7 @@ def __call__( http_options = ( _BaseSslCertificatesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseSslCertificatesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -373,6 +395,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 = 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.compute_v1.SslCertificatesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslCertificatesRestTransport._AggregatedList._get_response( self._host, @@ -393,7 +442,31 @@ def __call__( pb_resp = compute.SslCertificateAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslCertificateAggregatedList.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.compute_v1.SslCertificatesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -430,7 +503,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -442,8 +515,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: ~.compute.Operation: @@ -470,6 +545,7 @@ def __call__( http_options = ( _BaseSslCertificatesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseSslCertificatesRestTransport._BaseDelete._get_transcoded_request( @@ -484,6 +560,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.compute_v1.SslCertificatesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslCertificatesRestTransport._Delete._get_response( self._host, @@ -504,7 +607,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SslCertificatesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseSslCertificatesRestTransport._BaseGet, SslCertificatesRestStub): @@ -539,7 +664,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]]] = (), ) -> compute.SslCertificate: r"""Call the get method over HTTP. @@ -551,8 +676,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: ~.compute.SslCertificate: @@ -582,6 +709,7 @@ def __call__( http_options = ( _BaseSslCertificatesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseSslCertificatesRestTransport._BaseGet._get_transcoded_request( @@ -596,6 +724,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.compute_v1.SslCertificatesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslCertificatesRestTransport._Get._get_response( self._host, @@ -616,7 +771,29 @@ def __call__( pb_resp = compute.SslCertificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslCertificate.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.compute_v1.SslCertificatesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -654,7 +831,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -666,8 +843,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: ~.compute.Operation: @@ -694,6 +873,7 @@ def __call__( http_options = ( _BaseSslCertificatesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseSslCertificatesRestTransport._BaseInsert._get_transcoded_request( @@ -712,6 +892,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.compute_v1.SslCertificatesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslCertificatesRestTransport._Insert._get_response( self._host, @@ -733,7 +940,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SslCertificatesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseSslCertificatesRestTransport._BaseList, SslCertificatesRestStub): @@ -768,7 +997,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]]] = (), ) -> compute.SslCertificateList: r"""Call the list method over HTTP. @@ -780,8 +1009,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: ~.compute.SslCertificateList: @@ -793,6 +1024,7 @@ def __call__( http_options = ( _BaseSslCertificatesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseSslCertificatesRestTransport._BaseList._get_transcoded_request( @@ -807,6 +1039,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.compute_v1.SslCertificatesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslCertificatesRestTransport._List._get_response( self._host, @@ -827,7 +1086,29 @@ def __call__( pb_resp = compute.SslCertificateList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslCertificateList.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.compute_v1.SslCertificatesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.SslCertificates", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/client.py index 1518200ad0b7..c5e3a107dc01 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.ssl_policies import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.SslPoliciesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "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.compute.v1.SslPolicies", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListSslPoliciesRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all SslPolicy resources, regional and global, available to the specified project. To prevent failure, @@ -674,8 +711,10 @@ def sample_aggregated_list(): 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.compute_v1.services.ssl_policies.pagers.AggregatedListPager: @@ -746,7 +785,7 @@ def delete_unary( ssl_policy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any @@ -800,8 +839,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -867,7 +908,7 @@ def delete( ssl_policy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any @@ -921,8 +962,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1012,7 +1055,7 @@ def get( ssl_policy: 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]]] = (), ) -> compute.SslPolicy: r"""Lists all of the ordered rules present in a single specified policy. @@ -1065,8 +1108,10 @@ def sample_get(): 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.compute_v1.types.SslPolicy: @@ -1137,7 +1182,7 @@ def insert_unary( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> compute.Operation: r"""Returns the specified SSL policy resource. @@ -1185,8 +1230,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1247,7 +1294,7 @@ def insert( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Returns the specified SSL policy resource. @@ -1295,8 +1342,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1380,7 +1429,7 @@ def list( project: 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.ListPager: r"""Lists all the SSL policies that have been configured for the specified project. @@ -1425,8 +1474,10 @@ def sample_list(): 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.compute_v1.services.ssl_policies.pagers.ListPager: @@ -1498,7 +1549,7 @@ def list_available_features( project: 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]]] = (), ) -> compute.SslPoliciesListAvailableFeaturesResponse: r"""Lists all features that can be specified in the SSL policy when using custom profile. @@ -1542,8 +1593,10 @@ def sample_list_available_features(): 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.compute_v1.types.SslPoliciesListAvailableFeaturesResponse: @@ -1601,7 +1654,7 @@ def patch_unary( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified SSL policy with the data included in the request. @@ -1659,8 +1712,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1729,7 +1784,7 @@ def patch( ssl_policy_resource: Optional[compute.SslPolicy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified SSL policy with the data included in the request. @@ -1787,8 +1842,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/pagers.py index 0a8412243c19..afac9ca3afec 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/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 = compute.AggregatedListSslPoliciesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListSslPoliciesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/transports/rest.py index 87780ac99380..b04302bfa91d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/ssl_policies/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 @@ -37,6 +37,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, @@ -125,8 +133,11 @@ def post_patch(self, response): def pre_aggregated_list( self, request: compute.AggregatedListSslPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListSslPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListSslPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -148,8 +159,8 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -167,8 +178,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetSslPolicyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetSslPolicyRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetSslPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -188,8 +201,8 @@ def post_get(self, response: compute.SslPolicy) -> compute.SslPolicy: def pre_insert( self, request: compute.InsertSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -209,8 +222,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListSslPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListSslPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListSslPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -230,9 +243,10 @@ def post_list(self, response: compute.SslPoliciesList) -> compute.SslPoliciesLis def pre_list_available_features( self, request: compute.ListAvailableFeaturesSslPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.ListAvailableFeaturesSslPoliciesRequest, Sequence[Tuple[str, str]] + compute.ListAvailableFeaturesSslPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_available_features @@ -255,8 +269,8 @@ def post_list_available_features( def pre_patch( self, request: compute.PatchSslPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchSslPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchSslPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -398,7 +412,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]]] = (), ) -> compute.SslPoliciesAggregatedList: r"""Call the aggregated list method over HTTP. @@ -410,8 +424,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: ~.compute.SslPoliciesAggregatedList: @@ -421,6 +437,7 @@ def __call__( http_options = ( _BaseSslPoliciesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseSslPoliciesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -431,6 +448,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 = 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.compute_v1.SslPoliciesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._AggregatedList._get_response( self._host, @@ -451,7 +495,31 @@ def __call__( pb_resp = compute.SslPoliciesAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslPoliciesAggregatedList.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.compute_v1.SslPoliciesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseSslPoliciesRestTransport._BaseDelete, SslPoliciesRestStub): @@ -486,7 +554,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -498,8 +566,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: ~.compute.Operation: @@ -524,6 +594,7 @@ def __call__( """ http_options = _BaseSslPoliciesRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseSslPoliciesRestTransport._BaseDelete._get_transcoded_request( @@ -538,6 +609,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.compute_v1.SslPoliciesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._Delete._get_response( self._host, @@ -558,7 +656,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SslPoliciesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseSslPoliciesRestTransport._BaseGet, SslPoliciesRestStub): @@ -593,7 +713,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]]] = (), ) -> compute.SslPolicy: r"""Call the get method over HTTP. @@ -605,8 +725,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: ~.compute.SslPolicy: @@ -621,6 +743,7 @@ def __call__( """ http_options = _BaseSslPoliciesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseSslPoliciesRestTransport._BaseGet._get_transcoded_request( @@ -635,6 +758,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.compute_v1.SslPoliciesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._Get._get_response( self._host, @@ -655,7 +805,29 @@ def __call__( pb_resp = compute.SslPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslPolicy.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.compute_v1.SslPoliciesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseSslPoliciesRestTransport._BaseInsert, SslPoliciesRestStub): @@ -691,7 +863,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -703,8 +875,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: ~.compute.Operation: @@ -729,6 +903,7 @@ def __call__( """ http_options = _BaseSslPoliciesRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseSslPoliciesRestTransport._BaseInsert._get_transcoded_request( @@ -747,6 +922,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.compute_v1.SslPoliciesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._Insert._get_response( self._host, @@ -768,7 +970,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SslPoliciesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseSslPoliciesRestTransport._BaseList, SslPoliciesRestStub): @@ -803,7 +1027,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]]] = (), ) -> compute.SslPoliciesList: r"""Call the list method over HTTP. @@ -815,8 +1039,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: ~.compute.SslPoliciesList: @@ -824,6 +1050,7 @@ def __call__( """ http_options = _BaseSslPoliciesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseSslPoliciesRestTransport._BaseList._get_transcoded_request( @@ -838,6 +1065,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.compute_v1.SslPoliciesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._List._get_response( self._host, @@ -858,7 +1112,29 @@ def __call__( pb_resp = compute.SslPoliciesList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SslPoliciesList.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.compute_v1.SslPoliciesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAvailableFeatures( @@ -895,7 +1171,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]]] = (), ) -> compute.SslPoliciesListAvailableFeaturesResponse: r"""Call the list available features method over HTTP. @@ -907,8 +1183,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: ~.compute.SslPoliciesListAvailableFeaturesResponse: @@ -918,6 +1196,7 @@ def __call__( http_options = ( _BaseSslPoliciesRestTransport._BaseListAvailableFeatures._get_http_options() ) + request, metadata = self._interceptor.pre_list_available_features( request, metadata ) @@ -930,6 +1209,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 = 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.compute_v1.SslPoliciesClient.ListAvailableFeatures", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "ListAvailableFeatures", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._ListAvailableFeatures._get_response( self._host, @@ -950,7 +1256,33 @@ def __call__( pb_resp = compute.SslPoliciesListAvailableFeaturesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_available_features(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.SslPoliciesListAvailableFeaturesResponse.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.compute_v1.SslPoliciesClient.list_available_features", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "ListAvailableFeatures", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseSslPoliciesRestTransport._BasePatch, SslPoliciesRestStub): @@ -986,7 +1318,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -998,8 +1330,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: ~.compute.Operation: @@ -1024,6 +1358,7 @@ def __call__( """ http_options = _BaseSslPoliciesRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseSslPoliciesRestTransport._BasePatch._get_transcoded_request( @@ -1042,6 +1377,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.compute_v1.SslPoliciesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SslPoliciesRestTransport._Patch._get_response( self._host, @@ -1063,7 +1425,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SslPoliciesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.SslPolicies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/client.py index 747e58f88d07..8f46a1cc808f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/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.compute_v1.services.storage_pool_types import pagers from google.cloud.compute_v1.types import compute @@ -557,6 +567,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( @@ -623,6 +637,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.compute_v1.StoragePoolTypesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "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.compute.v1.StoragePoolTypes", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -632,7 +669,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of storage pool types. To prevent failure, Google recommends that you set the @@ -678,8 +715,10 @@ def sample_aggregated_list(): 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.compute_v1.services.storage_pool_types.pagers.AggregatedListPager: @@ -751,7 +790,7 @@ def get( storage_pool_type: 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]]] = (), ) -> compute.StoragePoolType: r"""Returns the specified storage pool type. @@ -810,8 +849,10 @@ def sample_get(): 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.compute_v1.types.StoragePoolType: @@ -878,7 +919,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of storage pool types available to the specified project. @@ -931,8 +972,10 @@ def sample_list(): 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.compute_v1.services.storage_pool_types.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/pagers.py index a4a66ef8467e..afe71c3d6d78 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/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 = compute.AggregatedListStoragePoolTypesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListStoragePoolTypesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/transports/rest.py index e424cacaff56..20d3fe744250 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pool_types/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 @@ -37,6 +37,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, @@ -93,9 +101,10 @@ def post_list(self, response): def pre_aggregated_list( self, request: compute.AggregatedListStoragePoolTypesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListStoragePoolTypesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListStoragePoolTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -118,8 +127,10 @@ def post_aggregated_list( def pre_get( self, request: compute.GetStoragePoolTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetStoragePoolTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetStoragePoolTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -139,8 +150,10 @@ def post_get(self, response: compute.StoragePoolType) -> compute.StoragePoolType def pre_list( self, request: compute.ListStoragePoolTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListStoragePoolTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListStoragePoolTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -284,7 +297,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]]] = (), ) -> compute.StoragePoolTypeAggregatedList: r"""Call the aggregated list method over HTTP. @@ -296,8 +309,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: ~.compute.StoragePoolTypeAggregatedList: @@ -307,6 +322,7 @@ def __call__( http_options = ( _BaseStoragePoolTypesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseStoragePoolTypesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -317,6 +333,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 = 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.compute_v1.StoragePoolTypesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolTypesRestTransport._AggregatedList._get_response( self._host, @@ -337,7 +380,31 @@ def __call__( pb_resp = compute.StoragePoolTypeAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolTypeAggregatedList.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.compute_v1.StoragePoolTypesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseStoragePoolTypesRestTransport._BaseGet, StoragePoolTypesRestStub): @@ -372,7 +439,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]]] = (), ) -> compute.StoragePoolType: r"""Call the get method over HTTP. @@ -384,8 +451,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: ~.compute.StoragePoolType: @@ -395,6 +464,7 @@ def __call__( http_options = ( _BaseStoragePoolTypesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseStoragePoolTypesRestTransport._BaseGet._get_transcoded_request( @@ -409,6 +479,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.compute_v1.StoragePoolTypesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolTypesRestTransport._Get._get_response( self._host, @@ -429,7 +526,29 @@ def __call__( pb_resp = compute.StoragePoolType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolType.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.compute_v1.StoragePoolTypesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseStoragePoolTypesRestTransport._BaseList, StoragePoolTypesRestStub): @@ -464,7 +583,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]]] = (), ) -> compute.StoragePoolTypeList: r"""Call the list method over HTTP. @@ -476,8 +595,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: ~.compute.StoragePoolTypeList: @@ -489,6 +610,7 @@ def __call__( http_options = ( _BaseStoragePoolTypesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseStoragePoolTypesRestTransport._BaseList._get_transcoded_request( @@ -503,6 +625,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.compute_v1.StoragePoolTypesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolTypesRestTransport._List._get_response( self._host, @@ -523,7 +672,29 @@ def __call__( pb_resp = compute.StoragePoolTypeList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolTypeList.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.compute_v1.StoragePoolTypesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePoolTypes", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/client.py index 167bcab4d089..8668935c421f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.storage_pools import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.StoragePoolsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "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.compute.v1.StoragePools", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -627,7 +664,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of storage pools. To prevent failure, Google recommends that you set the @@ -673,8 +710,10 @@ def sample_aggregated_list(): 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.compute_v1.services.storage_pools.pagers.AggregatedListPager: @@ -746,7 +785,7 @@ def delete_unary( storage_pool: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified storage pool. Deleting a storagePool removes its data permanently and is @@ -807,8 +846,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -878,7 +919,7 @@ def delete( storage_pool: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified storage pool. Deleting a storagePool removes its data permanently and is @@ -939,8 +980,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1035,7 +1078,7 @@ def get( storage_pool: 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]]] = (), ) -> compute.StoragePool: r"""Returns a specified storage pool. Gets a list of available storage pools by making a list() request. @@ -1093,8 +1136,10 @@ def sample_get(): 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.compute_v1.types.StoragePool: @@ -1164,7 +1209,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1224,8 +1269,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.cloud.compute_v1.types.Policy: @@ -1315,7 +1362,7 @@ def insert_unary( storage_pool_resource: Optional[compute.StoragePool] = 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]]] = (), ) -> compute.Operation: r"""Creates a storage pool in the specified project using the data in the request. @@ -1372,8 +1419,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1442,7 +1491,7 @@ def insert( storage_pool_resource: Optional[compute.StoragePool] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a storage pool in the specified project using the data in the request. @@ -1499,8 +1548,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1593,7 +1644,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of storage pools contained within the specified zone. @@ -1646,8 +1697,10 @@ def sample_list(): 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.compute_v1.services.storage_pools.pagers.ListPager: @@ -1728,7 +1781,7 @@ def list_disks( storage_pool: 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.ListDisksPager: r"""Lists the disks in a specified storage pool. @@ -1788,8 +1841,10 @@ def sample_list_disks(): 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.compute_v1.services.storage_pools.pagers.ListDisksPager: @@ -1872,7 +1927,7 @@ def set_iam_policy( zone_set_policy_request_resource: Optional[compute.ZoneSetPolicyRequest] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1937,8 +1992,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.cloud.compute_v1.types.Policy: @@ -2039,7 +2096,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2104,8 +2161,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.cloud.compute_v1.types.TestPermissionsResponse: @@ -2180,7 +2239,7 @@ def update_unary( storage_pool_resource: Optional[compute.StoragePool] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified storagePool with the data included in the request. The update is performed only on selected fields @@ -2248,8 +2307,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2322,7 +2383,7 @@ def update( storage_pool_resource: Optional[compute.StoragePool] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified storagePool with the data included in the request. The update is performed only on selected fields @@ -2390,8 +2451,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/pagers.py index c94be22451a6..551e81b0fbb1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/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 = compute.AggregatedListStoragePoolsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListStoragePoolsRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListDisksStoragePoolsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/transports/rest.py index 5583fa7bf07b..e191b4b2723f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/storage_pools/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 @@ -37,6 +37,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, @@ -149,8 +157,11 @@ def post_update(self, response): def pre_aggregated_list( self, request: compute.AggregatedListStoragePoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListStoragePoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListStoragePoolsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -172,8 +183,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -193,8 +206,8 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -214,8 +227,10 @@ def post_get(self, response: compute.StoragePool) -> compute.StoragePool: def pre_get_iam_policy( self, request: compute.GetIamPolicyStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicyStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicyStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -235,8 +250,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -256,8 +273,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListStoragePoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListStoragePoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListStoragePoolsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -277,8 +296,10 @@ def post_list(self, response: compute.StoragePoolList) -> compute.StoragePoolLis def pre_list_disks( self, request: compute.ListDisksStoragePoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListDisksStoragePoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListDisksStoragePoolsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_disks Override in a subclass to manipulate the request or metadata @@ -300,8 +321,10 @@ def post_list_disks( def pre_set_iam_policy( self, request: compute.SetIamPolicyStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicyStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicyStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -321,8 +344,11 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsStoragePoolRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -344,8 +370,10 @@ def post_test_iam_permissions( def pre_update( self, request: compute.UpdateStoragePoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.UpdateStoragePoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.UpdateStoragePoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -487,7 +515,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]]] = (), ) -> compute.StoragePoolAggregatedList: r"""Call the aggregated list method over HTTP. @@ -499,8 +527,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: ~.compute.StoragePoolAggregatedList: @@ -510,6 +540,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseStoragePoolsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -520,6 +551,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 = 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.compute_v1.StoragePoolsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._AggregatedList._get_response( self._host, @@ -540,7 +598,31 @@ def __call__( pb_resp = compute.StoragePoolAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolAggregatedList.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.compute_v1.StoragePoolsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseStoragePoolsRestTransport._BaseDelete, StoragePoolsRestStub): @@ -575,7 +657,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -587,8 +669,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: ~.compute.Operation: @@ -615,6 +699,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseDelete._get_transcoded_request( @@ -629,6 +714,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.compute_v1.StoragePoolsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._Delete._get_response( self._host, @@ -649,7 +761,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.StoragePoolsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseStoragePoolsRestTransport._BaseGet, StoragePoolsRestStub): @@ -684,7 +818,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]]] = (), ) -> compute.StoragePool: r"""Call the get method over HTTP. @@ -696,8 +830,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: ~.compute.StoragePool: @@ -707,6 +843,7 @@ def __call__( """ http_options = _BaseStoragePoolsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseGet._get_transcoded_request( @@ -721,6 +858,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.compute_v1.StoragePoolsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._Get._get_response( self._host, @@ -741,7 +905,29 @@ def __call__( pb_resp = compute.StoragePool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePool.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.compute_v1.StoragePoolsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -778,7 +964,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -790,8 +976,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: ~.compute.Policy: @@ -824,6 +1012,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseStoragePoolsRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -836,6 +1025,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.compute_v1.StoragePoolsClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._GetIamPolicy._get_response( self._host, @@ -856,7 +1072,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.StoragePoolsClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseStoragePoolsRestTransport._BaseInsert, StoragePoolsRestStub): @@ -892,7 +1130,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -904,8 +1142,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: ~.compute.Operation: @@ -932,6 +1172,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseInsert._get_transcoded_request( @@ -950,6 +1191,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.compute_v1.StoragePoolsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._Insert._get_response( self._host, @@ -971,7 +1239,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.StoragePoolsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseStoragePoolsRestTransport._BaseList, StoragePoolsRestStub): @@ -1006,7 +1296,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]]] = (), ) -> compute.StoragePoolList: r"""Call the list method over HTTP. @@ -1018,8 +1308,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: ~.compute.StoragePoolList: @@ -1027,6 +1319,7 @@ def __call__( """ http_options = _BaseStoragePoolsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseList._get_transcoded_request( @@ -1041,6 +1334,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.compute_v1.StoragePoolsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._List._get_response( self._host, @@ -1061,7 +1381,29 @@ def __call__( pb_resp = compute.StoragePoolList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolList.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.compute_v1.StoragePoolsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDisks( @@ -1098,7 +1440,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]]] = (), ) -> compute.StoragePoolListDisks: r"""Call the list disks method over HTTP. @@ -1110,8 +1452,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: ~.compute.StoragePoolListDisks: @@ -1121,6 +1465,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseListDisks._get_http_options() ) + request, metadata = self._interceptor.pre_list_disks(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseListDisks._get_transcoded_request( @@ -1135,6 +1480,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.compute_v1.StoragePoolsClient.ListDisks", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "ListDisks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._ListDisks._get_response( self._host, @@ -1155,7 +1527,29 @@ def __call__( pb_resp = compute.StoragePoolListDisks.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_disks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.StoragePoolListDisks.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.compute_v1.StoragePoolsClient.list_disks", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "ListDisks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1193,7 +1587,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1205,8 +1599,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: ~.compute.Policy: @@ -1239,6 +1635,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseStoragePoolsRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1257,6 +1654,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.compute_v1.StoragePoolsClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._SetIamPolicy._get_response( self._host, @@ -1278,7 +1702,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.StoragePoolsClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1316,7 +1762,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1328,8 +1774,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: ~.compute.TestPermissionsResponse: @@ -1339,6 +1787,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1355,6 +1804,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 = 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.compute_v1.StoragePoolsClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._TestIamPermissions._get_response( self._host, @@ -1376,7 +1852,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.StoragePoolsClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseStoragePoolsRestTransport._BaseUpdate, StoragePoolsRestStub): @@ -1412,7 +1910,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1424,8 +1922,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: ~.compute.Operation: @@ -1452,6 +1952,7 @@ def __call__( http_options = ( _BaseStoragePoolsRestTransport._BaseUpdate._get_http_options() ) + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseStoragePoolsRestTransport._BaseUpdate._get_transcoded_request( @@ -1470,6 +1971,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.compute_v1.StoragePoolsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = StoragePoolsRestTransport._Update._get_response( self._host, @@ -1491,7 +2019,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.StoragePoolsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.StoragePools", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/client.py index be2fd4ed7237..530fef9cea2d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.subnetworks import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.SubnetworksClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "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.compute.v1.Subnetworks", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListSubnetworksRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of subnetworks. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.subnetworks.pagers.AggregatedListPager: @@ -744,7 +783,7 @@ def delete_unary( subnetwork: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified subnetwork. @@ -803,8 +842,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -874,7 +915,7 @@ def delete( subnetwork: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified subnetwork. @@ -933,8 +974,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1034,7 +1077,7 @@ def expand_ip_cidr_range_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Expands the IP CIDR range of the subnetwork to a specified value. @@ -1099,8 +1142,10 @@ def sample_expand_ip_cidr_range(): 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.api_core.extended_operation.ExtendedOperation: @@ -1186,7 +1231,7 @@ def expand_ip_cidr_range( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Expands the IP CIDR range of the subnetwork to a specified value. @@ -1251,8 +1296,10 @@ def sample_expand_ip_cidr_range(): 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.api_core.extended_operation.ExtendedOperation: @@ -1358,7 +1405,7 @@ def get( subnetwork: 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]]] = (), ) -> compute.Subnetwork: r"""Returns the specified subnetwork. @@ -1417,8 +1464,10 @@ def sample_get(): 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.compute_v1.types.Subnetwork: @@ -1493,7 +1542,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]]] = (), ) -> compute.Policy: r"""Gets the access control policy for a resource. May be empty if no such policy or resource exists. @@ -1553,8 +1602,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.cloud.compute_v1.types.Policy: @@ -1644,7 +1695,7 @@ def insert_unary( subnetwork_resource: Optional[compute.Subnetwork] = 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]]] = (), ) -> compute.Operation: r"""Creates a subnetwork in the specified project using the data included in the request. @@ -1701,8 +1752,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1771,7 +1824,7 @@ def insert( subnetwork_resource: Optional[compute.Subnetwork] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a subnetwork in the specified project using the data included in the request. @@ -1828,8 +1881,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1922,7 +1977,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of subnetworks available to the specified project. @@ -1975,8 +2030,10 @@ def sample_list(): 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.compute_v1.services.subnetworks.pagers.ListPager: @@ -2055,7 +2112,7 @@ def list_usable( project: 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.ListUsablePager: r"""Retrieves an aggregated list of all usable subnetworks in the project. @@ -2100,8 +2157,10 @@ def sample_list_usable(): 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.compute_v1.services.subnetworks.pagers.ListUsablePager: @@ -2174,7 +2233,7 @@ def patch_unary( subnetwork_resource: Optional[compute.Subnetwork] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified subnetwork with the data included in the request. Only certain fields can be @@ -2242,8 +2301,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2316,7 +2377,7 @@ def patch( subnetwork_resource: Optional[compute.Subnetwork] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified subnetwork with the data included in the request. Only certain fields can be @@ -2384,8 +2445,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2485,7 +2548,7 @@ def set_iam_policy( ] = 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]]] = (), ) -> compute.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -2550,8 +2613,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.cloud.compute_v1.types.Policy: @@ -2652,7 +2717,7 @@ def set_private_ip_google_access_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Set whether VMs in this subnet can access Google services without assigning external IP addresses through @@ -2716,8 +2781,10 @@ def sample_set_private_ip_google_access(): 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.api_core.extended_operation.ExtendedOperation: @@ -2805,7 +2872,7 @@ def set_private_ip_google_access( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Set whether VMs in this subnet can access Google services without assigning external IP addresses through @@ -2869,8 +2936,10 @@ def sample_set_private_ip_google_access(): 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.api_core.extended_operation.ExtendedOperation: @@ -2983,7 +3052,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -3048,8 +3117,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/pagers.py index 05a898137936..8cd0acc7c1ad 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/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 = compute.AggregatedListSubnetworksRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListSubnetworksRequest(request) @@ -218,7 +222,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. @@ -232,8 +236,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 = compute.ListUsableSubnetworksRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/transports/rest.py index cf2ebaa0bb39..227303005d92 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/subnetworks/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 @@ -37,6 +37,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, @@ -165,8 +173,11 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListSubnetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListSubnetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListSubnetworksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -188,8 +199,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteSubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteSubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -209,8 +222,11 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_expand_ip_cidr_range( self, request: compute.ExpandIpCidrRangeSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ExpandIpCidrRangeSubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ExpandIpCidrRangeSubnetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for expand_ip_cidr_range Override in a subclass to manipulate the request or metadata @@ -230,8 +246,10 @@ def post_expand_ip_cidr_range( return response def pre_get( - self, request: compute.GetSubnetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetSubnetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetSubnetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetSubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -251,8 +269,10 @@ def post_get(self, response: compute.Subnetwork) -> compute.Subnetwork: def pre_get_iam_policy( self, request: compute.GetIamPolicySubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetIamPolicySubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetIamPolicySubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -272,8 +292,10 @@ def post_get_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_insert( self, request: compute.InsertSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertSubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertSubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -293,8 +315,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListSubnetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListSubnetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListSubnetworksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -314,8 +336,10 @@ def post_list(self, response: compute.SubnetworkList) -> compute.SubnetworkList: def pre_list_usable( self, request: compute.ListUsableSubnetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListUsableSubnetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListUsableSubnetworksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_usable Override in a subclass to manipulate the request or metadata @@ -337,8 +361,8 @@ def post_list_usable( def pre_patch( self, request: compute.PatchSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchSubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchSubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -358,8 +382,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_iam_policy( self, request: compute.SetIamPolicySubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetIamPolicySubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetIamPolicySubnetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -379,9 +405,10 @@ def post_set_iam_policy(self, response: compute.Policy) -> compute.Policy: def pre_set_private_ip_google_access( self, request: compute.SetPrivateIpGoogleAccessSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetPrivateIpGoogleAccessSubnetworkRequest, Sequence[Tuple[str, str]] + compute.SetPrivateIpGoogleAccessSubnetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_private_ip_google_access @@ -404,8 +431,11 @@ def post_set_private_ip_google_access( def pre_test_iam_permissions( self, request: compute.TestIamPermissionsSubnetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsSubnetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsSubnetworkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -549,7 +579,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]]] = (), ) -> compute.SubnetworkAggregatedList: r"""Call the aggregated list method over HTTP. @@ -561,8 +591,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: ~.compute.SubnetworkAggregatedList: @@ -572,6 +604,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseSubnetworksRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -582,6 +615,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 = 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.compute_v1.SubnetworksClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._AggregatedList._get_response( self._host, @@ -602,7 +662,31 @@ def __call__( pb_resp = compute.SubnetworkAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SubnetworkAggregatedList.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.compute_v1.SubnetworksClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseSubnetworksRestTransport._BaseDelete, SubnetworksRestStub): @@ -637,7 +721,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -649,8 +733,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: ~.compute.Operation: @@ -675,6 +761,7 @@ def __call__( """ http_options = _BaseSubnetworksRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseDelete._get_transcoded_request( @@ -689,6 +776,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.compute_v1.SubnetworksClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._Delete._get_response( self._host, @@ -709,7 +823,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SubnetworksClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExpandIpCidrRange( @@ -747,7 +883,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]]] = (), ) -> compute.Operation: r"""Call the expand ip cidr range method over HTTP. @@ -759,8 +895,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: ~.compute.Operation: @@ -787,6 +925,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseExpandIpCidrRange._get_http_options() ) + request, metadata = self._interceptor.pre_expand_ip_cidr_range( request, metadata ) @@ -803,6 +942,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 = 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.compute_v1.SubnetworksClient.ExpandIpCidrRange", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "ExpandIpCidrRange", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._ExpandIpCidrRange._get_response( self._host, @@ -824,7 +990,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_expand_ip_cidr_range(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SubnetworksClient.expand_ip_cidr_range", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "ExpandIpCidrRange", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseSubnetworksRestTransport._BaseGet, SubnetworksRestStub): @@ -859,7 +1047,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]]] = (), ) -> compute.Subnetwork: r"""Call the get method over HTTP. @@ -871,8 +1059,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: ~.compute.Subnetwork: @@ -887,6 +1077,7 @@ def __call__( """ http_options = _BaseSubnetworksRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseGet._get_transcoded_request( @@ -901,6 +1092,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.compute_v1.SubnetworksClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._Get._get_response( self._host, @@ -921,7 +1139,29 @@ def __call__( pb_resp = compute.Subnetwork.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Subnetwork.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.compute_v1.SubnetworksClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -958,7 +1198,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]]] = (), ) -> compute.Policy: r"""Call the get iam policy method over HTTP. @@ -970,8 +1210,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: ~.compute.Policy: @@ -1004,6 +1246,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1018,6 +1261,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.compute_v1.SubnetworksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._GetIamPolicy._get_response( self._host, @@ -1038,7 +1308,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.SubnetworksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseSubnetworksRestTransport._BaseInsert, SubnetworksRestStub): @@ -1074,7 +1366,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1086,8 +1378,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: ~.compute.Operation: @@ -1112,6 +1406,7 @@ def __call__( """ http_options = _BaseSubnetworksRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseInsert._get_transcoded_request( @@ -1130,6 +1425,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.compute_v1.SubnetworksClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._Insert._get_response( self._host, @@ -1151,7 +1473,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SubnetworksClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseSubnetworksRestTransport._BaseList, SubnetworksRestStub): @@ -1186,7 +1530,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]]] = (), ) -> compute.SubnetworkList: r"""Call the list method over HTTP. @@ -1198,8 +1542,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: ~.compute.SubnetworkList: @@ -1209,6 +1555,7 @@ def __call__( """ http_options = _BaseSubnetworksRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseList._get_transcoded_request( @@ -1223,6 +1570,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.compute_v1.SubnetworksClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._List._get_response( self._host, @@ -1243,7 +1617,29 @@ def __call__( pb_resp = compute.SubnetworkList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.SubnetworkList.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.compute_v1.SubnetworksClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsable( @@ -1280,7 +1676,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]]] = (), ) -> compute.UsableSubnetworksAggregatedList: r"""Call the list usable method over HTTP. @@ -1292,8 +1688,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: ~.compute.UsableSubnetworksAggregatedList: @@ -1303,6 +1701,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseListUsable._get_http_options() ) + request, metadata = self._interceptor.pre_list_usable(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseListUsable._get_transcoded_request( @@ -1317,6 +1716,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.compute_v1.SubnetworksClient.ListUsable", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "ListUsable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._ListUsable._get_response( self._host, @@ -1337,7 +1763,31 @@ def __call__( pb_resp = compute.UsableSubnetworksAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_usable(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UsableSubnetworksAggregatedList.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.compute_v1.SubnetworksClient.list_usable", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "ListUsable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseSubnetworksRestTransport._BasePatch, SubnetworksRestStub): @@ -1373,7 +1823,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1385,8 +1835,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: ~.compute.Operation: @@ -1411,6 +1863,7 @@ def __call__( """ http_options = _BaseSubnetworksRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BasePatch._get_transcoded_request( @@ -1429,6 +1882,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.compute_v1.SubnetworksClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._Patch._get_response( self._host, @@ -1450,7 +1930,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SubnetworksClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1488,7 +1990,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]]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. @@ -1500,8 +2002,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: ~.compute.Policy: @@ -1534,6 +2038,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseSubnetworksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -1554,6 +2059,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.compute_v1.SubnetworksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._SetIamPolicy._get_response( self._host, @@ -1575,7 +2107,29 @@ def __call__( pb_resp = compute.Policy.pb(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 = compute.Policy.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.compute_v1.SubnetworksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetPrivateIpGoogleAccess( @@ -1613,7 +2167,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]]] = (), ) -> compute.Operation: r"""Call the set private ip google access method over HTTP. @@ -1626,8 +2180,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: ~.compute.Operation: @@ -1654,6 +2210,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseSetPrivateIpGoogleAccess._get_http_options() ) + request, metadata = self._interceptor.pre_set_private_ip_google_access( request, metadata ) @@ -1670,6 +2227,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 = 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.compute_v1.SubnetworksClient.SetPrivateIpGoogleAccess", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "SetPrivateIpGoogleAccess", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._SetPrivateIpGoogleAccess._get_response( self._host, @@ -1691,7 +2275,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_private_ip_google_access(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.SubnetworksClient.set_private_ip_google_access", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "SetPrivateIpGoogleAccess", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1729,7 +2335,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1741,8 +2347,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: ~.compute.TestPermissionsResponse: @@ -1752,6 +2360,7 @@ def __call__( http_options = ( _BaseSubnetworksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1768,6 +2377,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 = 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.compute_v1.SubnetworksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SubnetworksRestTransport._TestIamPermissions._get_response( self._host, @@ -1789,7 +2425,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.SubnetworksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.Subnetworks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/client.py index 93bbd3659722..63234e4dc5b6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_grpc_proxies import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.TargetGrpcProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "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.compute.v1.TargetGrpcProxies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteTargetGrpcProxyRequest, dict]] = None, @@ -636,7 +673,7 @@ def delete_unary( target_grpc_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetGrpcProxy in the given scope @@ -688,8 +725,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -755,7 +794,7 @@ def delete( target_grpc_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetGrpcProxy in the given scope @@ -807,8 +846,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -898,7 +939,7 @@ def get( target_grpc_proxy: 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]]] = (), ) -> compute.TargetGrpcProxy: r"""Returns the specified TargetGrpcProxy resource in the given scope. @@ -950,8 +991,10 @@ def sample_get(): 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.compute_v1.types.TargetGrpcProxy: @@ -1022,7 +1065,7 @@ def insert_unary( target_grpc_proxy_resource: Optional[compute.TargetGrpcProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included @@ -1072,8 +1115,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1134,7 +1179,7 @@ def insert( target_grpc_proxy_resource: Optional[compute.TargetGrpcProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included @@ -1184,8 +1229,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1269,7 +1316,7 @@ def list( project: 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.ListPager: r"""Lists the TargetGrpcProxies for a project in the given scope. @@ -1314,8 +1361,10 @@ def sample_list(): 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.compute_v1.services.target_grpc_proxies.pagers.ListPager: @@ -1387,7 +1436,7 @@ def patch_unary( target_grpc_proxy_resource: Optional[compute.TargetGrpcProxy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports @@ -1446,8 +1495,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1518,7 +1569,7 @@ def patch( target_grpc_proxy_resource: Optional[compute.TargetGrpcProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports @@ -1577,8 +1628,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/pagers.py index 694084b699f1..b2ce1f07c955 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/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 = compute.ListTargetGrpcProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/transports/rest.py index 885fbf39ed0a..21bd690dd631 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_grpc_proxies/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 @@ -37,6 +37,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, @@ -109,8 +117,10 @@ def post_patch(self, response): def pre_delete( self, request: compute.DeleteTargetGrpcProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetGrpcProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetGrpcProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetGrpcProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetGrpcProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetGrpcProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -151,8 +163,10 @@ def post_get(self, response: compute.TargetGrpcProxy) -> compute.TargetGrpcProxy def pre_insert( self, request: compute.InsertTargetGrpcProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetGrpcProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetGrpcProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -172,8 +186,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetGrpcProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetGrpcProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetGrpcProxiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -195,8 +211,10 @@ def post_list( def pre_patch( self, request: compute.PatchTargetGrpcProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchTargetGrpcProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchTargetGrpcProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -338,7 +356,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -350,8 +368,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: ~.compute.Operation: @@ -378,6 +398,7 @@ def __call__( http_options = ( _BaseTargetGrpcProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetGrpcProxiesRestTransport._BaseDelete._get_transcoded_request( @@ -392,6 +413,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.compute_v1.TargetGrpcProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetGrpcProxiesRestTransport._Delete._get_response( self._host, @@ -412,7 +460,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetGrpcProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetGrpcProxiesRestTransport._BaseGet, TargetGrpcProxiesRestStub): @@ -447,7 +517,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]]] = (), ) -> compute.TargetGrpcProxy: r"""Call the get method over HTTP. @@ -459,8 +529,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: ~.compute.TargetGrpcProxy: @@ -477,6 +549,7 @@ def __call__( http_options = ( _BaseTargetGrpcProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetGrpcProxiesRestTransport._BaseGet._get_transcoded_request( @@ -491,6 +564,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.compute_v1.TargetGrpcProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetGrpcProxiesRestTransport._Get._get_response( self._host, @@ -511,7 +611,29 @@ def __call__( pb_resp = compute.TargetGrpcProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetGrpcProxy.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.compute_v1.TargetGrpcProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -549,7 +671,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -561,8 +683,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: ~.compute.Operation: @@ -589,6 +713,7 @@ def __call__( http_options = ( _BaseTargetGrpcProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetGrpcProxiesRestTransport._BaseInsert._get_transcoded_request( @@ -609,6 +734,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.compute_v1.TargetGrpcProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetGrpcProxiesRestTransport._Insert._get_response( self._host, @@ -630,7 +782,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetGrpcProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -667,7 +841,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]]] = (), ) -> compute.TargetGrpcProxyList: r"""Call the list method over HTTP. @@ -679,8 +853,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: ~.compute.TargetGrpcProxyList: @@ -690,6 +866,7 @@ def __call__( http_options = ( _BaseTargetGrpcProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetGrpcProxiesRestTransport._BaseList._get_transcoded_request( @@ -704,6 +881,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.compute_v1.TargetGrpcProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetGrpcProxiesRestTransport._List._get_response( self._host, @@ -724,7 +928,29 @@ def __call__( pb_resp = compute.TargetGrpcProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetGrpcProxyList.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.compute_v1.TargetGrpcProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -762,7 +988,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -774,8 +1000,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: ~.compute.Operation: @@ -802,6 +1030,7 @@ def __call__( http_options = ( _BaseTargetGrpcProxiesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseTargetGrpcProxiesRestTransport._BasePatch._get_transcoded_request( @@ -822,6 +1051,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.compute_v1.TargetGrpcProxiesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetGrpcProxiesRestTransport._Patch._get_response( self._host, @@ -843,7 +1099,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetGrpcProxiesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetGrpcProxies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/client.py index fa82cb8844cf..4c667adfc271 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_http_proxies import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.TargetHttpProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "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.compute.v1.TargetHttpProxies", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project. To prevent @@ -686,8 +723,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_http_proxies.pagers.AggregatedListPager: @@ -758,7 +797,7 @@ def delete_unary( target_http_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetHttpProxy resource. @@ -809,8 +848,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -876,7 +917,7 @@ def delete( target_http_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetHttpProxy resource. @@ -927,8 +968,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1018,7 +1061,7 @@ def get( target_http_proxy: 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]]] = (), ) -> compute.TargetHttpProxy: r"""Returns the specified TargetHttpProxy resource. @@ -1069,8 +1112,10 @@ def sample_get(): 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.compute_v1.types.TargetHttpProxy: @@ -1150,7 +1195,7 @@ def insert_unary( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetHttpProxy resource in the specified project using the data included in the request. @@ -1199,8 +1244,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1261,7 +1308,7 @@ def insert( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetHttpProxy resource in the specified project using the data included in the request. @@ -1310,8 +1357,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1395,7 +1444,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of TargetHttpProxy resources available to the specified project. @@ -1440,8 +1489,10 @@ def sample_list(): 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.compute_v1.services.target_http_proxies.pagers.ListPager: @@ -1515,7 +1566,7 @@ def patch_unary( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified TargetHttpProxy resource with the data included in the request. This method supports @@ -1574,8 +1625,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1646,7 +1699,7 @@ def patch( target_http_proxy_resource: Optional[compute.TargetHttpProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified TargetHttpProxy resource with the data included in the request. This method supports @@ -1705,8 +1758,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1801,7 +1856,7 @@ def set_url_map_unary( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> compute.Operation: r"""Changes the URL map for TargetHttpProxy. @@ -1857,8 +1912,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -1929,7 +1986,7 @@ def set_url_map( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the URL map for TargetHttpProxy. @@ -1985,8 +2042,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/pagers.py index 60fbdbb33e1b..c50e0b107468 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/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 = compute.AggregatedListTargetHttpProxiesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetHttpProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/transports/rest.py index 73a15b008f07..612fc456e2b8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_http_proxies/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 @@ -37,6 +37,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, @@ -125,9 +133,10 @@ def post_set_url_map(self, response): def pre_aggregated_list( self, request: compute.AggregatedListTargetHttpProxiesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListTargetHttpProxiesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListTargetHttpProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -150,8 +159,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -171,8 +182,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -192,8 +205,10 @@ def post_get(self, response: compute.TargetHttpProxy) -> compute.TargetHttpProxy def pre_insert( self, request: compute.InsertTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -213,8 +228,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetHttpProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetHttpProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetHttpProxiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -236,8 +253,10 @@ def post_list( def pre_patch( self, request: compute.PatchTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -257,8 +276,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_url_map( self, request: compute.SetUrlMapTargetHttpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetUrlMapTargetHttpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetUrlMapTargetHttpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_url_map Override in a subclass to manipulate the request or metadata @@ -401,7 +422,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]]] = (), ) -> compute.TargetHttpProxyAggregatedList: r"""Call the aggregated list method over HTTP. @@ -413,8 +434,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: ~.compute.TargetHttpProxyAggregatedList: @@ -424,6 +447,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetHttpProxiesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -434,6 +458,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 = 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.compute_v1.TargetHttpProxiesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._AggregatedList._get_response( self._host, @@ -454,7 +505,31 @@ def __call__( pb_resp = compute.TargetHttpProxyAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpProxyAggregatedList.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.compute_v1.TargetHttpProxiesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -491,7 +566,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -503,8 +578,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: ~.compute.Operation: @@ -531,6 +608,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetHttpProxiesRestTransport._BaseDelete._get_transcoded_request( @@ -545,6 +623,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.compute_v1.TargetHttpProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._Delete._get_response( self._host, @@ -565,7 +670,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetHttpProxiesRestTransport._BaseGet, TargetHttpProxiesRestStub): @@ -600,7 +727,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]]] = (), ) -> compute.TargetHttpProxy: r"""Call the get method over HTTP. @@ -612,8 +739,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: ~.compute.TargetHttpProxy: @@ -639,6 +768,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetHttpProxiesRestTransport._BaseGet._get_transcoded_request( @@ -653,6 +783,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.compute_v1.TargetHttpProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._Get._get_response( self._host, @@ -673,7 +830,29 @@ def __call__( pb_resp = compute.TargetHttpProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpProxy.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.compute_v1.TargetHttpProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -711,7 +890,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -723,8 +902,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: ~.compute.Operation: @@ -751,6 +932,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetHttpProxiesRestTransport._BaseInsert._get_transcoded_request( @@ -771,6 +953,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.compute_v1.TargetHttpProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._Insert._get_response( self._host, @@ -792,7 +1001,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -829,7 +1060,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]]] = (), ) -> compute.TargetHttpProxyList: r"""Call the list method over HTTP. @@ -841,8 +1072,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: ~.compute.TargetHttpProxyList: @@ -852,6 +1085,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetHttpProxiesRestTransport._BaseList._get_transcoded_request( @@ -866,6 +1100,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.compute_v1.TargetHttpProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._List._get_response( self._host, @@ -886,7 +1147,29 @@ def __call__( pb_resp = compute.TargetHttpProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpProxyList.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.compute_v1.TargetHttpProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -924,7 +1207,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -936,8 +1219,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: ~.compute.Operation: @@ -964,6 +1249,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseTargetHttpProxiesRestTransport._BasePatch._get_transcoded_request( @@ -984,6 +1270,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.compute_v1.TargetHttpProxiesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._Patch._get_response( self._host, @@ -1005,7 +1318,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpProxiesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUrlMap( @@ -1043,7 +1378,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]]] = (), ) -> compute.Operation: r"""Call the set url map method over HTTP. @@ -1055,8 +1390,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: ~.compute.Operation: @@ -1083,6 +1420,7 @@ def __call__( http_options = ( _BaseTargetHttpProxiesRestTransport._BaseSetUrlMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_url_map(request, metadata) transcoded_request = _BaseTargetHttpProxiesRestTransport._BaseSetUrlMap._get_transcoded_request( http_options, request @@ -1097,6 +1435,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 = 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.compute_v1.TargetHttpProxiesClient.SetUrlMap", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "SetUrlMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpProxiesRestTransport._SetUrlMap._get_response( self._host, @@ -1118,7 +1483,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_url_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpProxiesClient.set_url_map", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpProxies", + "rpcName": "SetUrlMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/client.py index aa470a359be4..1f3b423297db 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_https_proxies import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.TargetHttpsProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "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.compute.v1.TargetHttpsProxies", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. To prevent @@ -686,8 +723,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_https_proxies.pagers.AggregatedListPager: @@ -758,7 +797,7 @@ def delete_unary( target_https_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetHttpsProxy resource. @@ -809,8 +848,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -876,7 +917,7 @@ def delete( target_https_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetHttpsProxy resource. @@ -927,8 +968,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1018,7 +1061,7 @@ def get( target_https_proxy: 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]]] = (), ) -> compute.TargetHttpsProxy: r"""Returns the specified TargetHttpsProxy resource. @@ -1069,8 +1112,10 @@ def sample_get(): 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.compute_v1.types.TargetHttpsProxy: @@ -1079,11 +1124,11 @@ def sample_get(): [Global](/compute/docs/reference/rest/v1/targetHttpsProxies) \* [Regional](/compute/docs/reference/rest/v1/regionTargetHttpsProxies) - A target HTTPS proxy is a component of GCP HTTPS load - balancers. \* targetHttpProxies are used by global - external Application Load Balancers, classic Application - Load Balancers, cross-region internal Application Load - Balancers, and Traffic Director. \* + A target HTTPS proxy is a component of Google Cloud + HTTPS load balancers. \* targetHttpProxies are used by + global external Application Load Balancers, classic + Application Load Balancers, cross-region internal + Application Load Balancers, and Traffic Director. \* regionTargetHttpProxies are used by regional internal Application Load Balancers and regional external Application Load Balancers. Forwarding rules reference a @@ -1150,7 +1195,7 @@ def insert_unary( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetHttpsProxy resource in the specified project using the data included in the request. @@ -1199,8 +1244,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1261,7 +1308,7 @@ def insert( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetHttpsProxy resource in the specified project using the data included in the request. @@ -1310,8 +1357,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1395,7 +1444,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of TargetHttpsProxy resources available to the specified project. @@ -1440,8 +1489,10 @@ def sample_list(): 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.compute_v1.services.target_https_proxies.pagers.ListPager: @@ -1515,7 +1566,7 @@ def patch_unary( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports @@ -1574,8 +1625,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1646,7 +1699,7 @@ def patch( target_https_proxy_resource: Optional[compute.TargetHttpsProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports @@ -1705,8 +1758,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1805,7 +1860,7 @@ def set_certificate_map_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the Certificate Map for TargetHttpsProxy. @@ -1863,8 +1918,10 @@ def sample_set_certificate_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -1945,7 +2002,7 @@ def set_certificate_map( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the Certificate Map for TargetHttpsProxy. @@ -2003,8 +2060,10 @@ def sample_set_certificate_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -2109,7 +2168,7 @@ def set_quic_override_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the QUIC override policy for TargetHttpsProxy. @@ -2166,8 +2225,10 @@ def sample_set_quic_override(): 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.api_core.extended_operation.ExtendedOperation: @@ -2248,7 +2309,7 @@ def set_quic_override( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the QUIC override policy for TargetHttpsProxy. @@ -2305,8 +2366,10 @@ def sample_set_quic_override(): 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.api_core.extended_operation.ExtendedOperation: @@ -2411,7 +2474,7 @@ def set_ssl_certificates_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Replaces SslCertificates for TargetHttpsProxy. @@ -2467,8 +2530,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -2549,7 +2614,7 @@ def set_ssl_certificates( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Replaces SslCertificates for TargetHttpsProxy. @@ -2605,8 +2670,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -2709,7 +2776,7 @@ def set_ssl_policy_unary( ssl_policy_reference_resource: Optional[compute.SslPolicyReference] = 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]]] = (), ) -> compute.Operation: r"""Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL @@ -2771,8 +2838,10 @@ def sample_set_ssl_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.api_core.extended_operation.ExtendedOperation: @@ -2845,7 +2914,7 @@ def set_ssl_policy( ssl_policy_reference_resource: Optional[compute.SslPolicyReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL @@ -2907,8 +2976,10 @@ def sample_set_ssl_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.api_core.extended_operation.ExtendedOperation: @@ -3003,7 +3074,7 @@ def set_url_map_unary( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> compute.Operation: r"""Changes the URL map for TargetHttpsProxy. @@ -3059,8 +3130,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -3131,7 +3204,7 @@ def set_url_map( url_map_reference_resource: Optional[compute.UrlMapReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the URL map for TargetHttpsProxy. @@ -3187,8 +3260,10 @@ def sample_set_url_map(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/pagers.py index 441787781740..467f55218132 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/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 = compute.AggregatedListTargetHttpsProxiesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetHttpsProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/transports/rest.py index a87797ebaad9..a8e15f2f9cf4 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_https_proxies/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 @@ -37,6 +37,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, @@ -157,9 +165,10 @@ def post_set_url_map(self, response): def pre_aggregated_list( self, request: compute.AggregatedListTargetHttpsProxiesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListTargetHttpsProxiesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListTargetHttpsProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -182,8 +191,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetHttpsProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -203,8 +214,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetHttpsProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -224,8 +237,10 @@ def post_get(self, response: compute.TargetHttpsProxy) -> compute.TargetHttpsPro def pre_insert( self, request: compute.InsertTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetHttpsProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -245,8 +260,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetHttpsProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetHttpsProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetHttpsProxiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -268,8 +285,10 @@ def post_list( def pre_patch( self, request: compute.PatchTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.PatchTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.PatchTargetHttpsProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -289,9 +308,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: def pre_set_certificate_map( self, request: compute.SetCertificateMapTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetCertificateMapTargetHttpsProxyRequest, Sequence[Tuple[str, str]] + compute.SetCertificateMapTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_certificate_map @@ -314,9 +334,10 @@ def post_set_certificate_map( def pre_set_quic_override( self, request: compute.SetQuicOverrideTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetQuicOverrideTargetHttpsProxyRequest, Sequence[Tuple[str, str]] + compute.SetQuicOverrideTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_quic_override @@ -337,9 +358,10 @@ def post_set_quic_override(self, response: compute.Operation) -> compute.Operati def pre_set_ssl_certificates( self, request: compute.SetSslCertificatesTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetSslCertificatesTargetHttpsProxyRequest, Sequence[Tuple[str, str]] + compute.SetSslCertificatesTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_ssl_certificates @@ -362,8 +384,11 @@ def post_set_ssl_certificates( def pre_set_ssl_policy( self, request: compute.SetSslPolicyTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetSslPolicyTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetSslPolicyTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_ssl_policy Override in a subclass to manipulate the request or metadata @@ -383,8 +408,11 @@ def post_set_ssl_policy(self, response: compute.Operation) -> compute.Operation: def pre_set_url_map( self, request: compute.SetUrlMapTargetHttpsProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetUrlMapTargetHttpsProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetUrlMapTargetHttpsProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_url_map Override in a subclass to manipulate the request or metadata @@ -527,7 +555,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]]] = (), ) -> compute.TargetHttpsProxyAggregatedList: r"""Call the aggregated list method over HTTP. @@ -539,8 +567,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: ~.compute.TargetHttpsProxyAggregatedList: @@ -550,6 +580,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetHttpsProxiesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -560,6 +591,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 = 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.compute_v1.TargetHttpsProxiesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._AggregatedList._get_response( self._host, @@ -580,7 +638,31 @@ def __call__( pb_resp = compute.TargetHttpsProxyAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpsProxyAggregatedList.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.compute_v1.TargetHttpsProxiesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -617,7 +699,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -629,8 +711,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: ~.compute.Operation: @@ -657,6 +741,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = _BaseTargetHttpsProxiesRestTransport._BaseDelete._get_transcoded_request( http_options, request @@ -669,6 +754,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.compute_v1.TargetHttpsProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._Delete._get_response( self._host, @@ -689,7 +801,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get( @@ -726,7 +860,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]]] = (), ) -> compute.TargetHttpsProxy: r"""Call the get method over HTTP. @@ -738,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: ~.compute.TargetHttpsProxy: @@ -748,11 +884,11 @@ def __call__( `Global `__ \* `Regional `__ - A target HTTPS proxy is a component of GCP HTTPS load - balancers. \* targetHttpProxies are used by global - external Application Load Balancers, classic Application - Load Balancers, cross-region internal Application Load - Balancers, and Traffic Director. \* + A target HTTPS proxy is a component of Google Cloud + HTTPS load balancers. \* targetHttpProxies are used by + global external Application Load Balancers, classic + Application Load Balancers, cross-region internal + Application Load Balancers, and Traffic Director. \* regionTargetHttpProxies are used by regional internal Application Load Balancers and regional external Application Load Balancers. Forwarding rules reference a @@ -765,6 +901,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetHttpsProxiesRestTransport._BaseGet._get_transcoded_request( @@ -779,6 +916,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.compute_v1.TargetHttpsProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._Get._get_response( self._host, @@ -799,7 +963,29 @@ def __call__( pb_resp = compute.TargetHttpsProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpsProxy.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.compute_v1.TargetHttpsProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -837,7 +1023,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -849,8 +1035,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: ~.compute.Operation: @@ -877,6 +1065,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = _BaseTargetHttpsProxiesRestTransport._BaseInsert._get_transcoded_request( http_options, request @@ -895,6 +1084,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.compute_v1.TargetHttpsProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._Insert._get_response( self._host, @@ -916,7 +1132,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -953,7 +1191,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]]] = (), ) -> compute.TargetHttpsProxyList: r"""Call the list method over HTTP. @@ -965,8 +1203,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: ~.compute.TargetHttpsProxyList: @@ -978,6 +1218,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetHttpsProxiesRestTransport._BaseList._get_transcoded_request( @@ -992,6 +1233,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.compute_v1.TargetHttpsProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._List._get_response( self._host, @@ -1012,7 +1280,29 @@ def __call__( pb_resp = compute.TargetHttpsProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetHttpsProxyList.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.compute_v1.TargetHttpsProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch( @@ -1050,7 +1340,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1062,8 +1352,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: ~.compute.Operation: @@ -1090,6 +1382,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BasePatch._get_http_options() ) + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseTargetHttpsProxiesRestTransport._BasePatch._get_transcoded_request( @@ -1110,6 +1403,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.compute_v1.TargetHttpsProxiesClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._Patch._get_response( self._host, @@ -1131,7 +1451,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetCertificateMap( @@ -1170,7 +1512,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]]] = (), ) -> compute.Operation: r"""Call the set certificate map method over HTTP. @@ -1182,8 +1524,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: ~.compute.Operation: @@ -1210,6 +1554,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseSetCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_certificate_map( request, metadata ) @@ -1226,6 +1571,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 = 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.compute_v1.TargetHttpsProxiesClient.SetCertificateMap", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._SetCertificateMap._get_response( self._host, @@ -1247,7 +1619,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.set_certificate_map", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetQuicOverride( @@ -1286,7 +1680,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]]] = (), ) -> compute.Operation: r"""Call the set quic override method over HTTP. @@ -1298,8 +1692,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: ~.compute.Operation: @@ -1326,6 +1722,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseSetQuicOverride._get_http_options() ) + request, metadata = self._interceptor.pre_set_quic_override( request, metadata ) @@ -1342,6 +1739,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 = 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.compute_v1.TargetHttpsProxiesClient.SetQuicOverride", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetQuicOverride", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._SetQuicOverride._get_response( self._host, @@ -1363,7 +1787,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_quic_override(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.set_quic_override", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetQuicOverride", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSslCertificates( @@ -1402,7 +1848,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]]] = (), ) -> compute.Operation: r"""Call the set ssl certificates method over HTTP. @@ -1414,8 +1860,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: ~.compute.Operation: @@ -1442,6 +1890,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseSetSslCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_set_ssl_certificates( request, metadata ) @@ -1458,6 +1907,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 = 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.compute_v1.TargetHttpsProxiesClient.SetSslCertificates", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetSslCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TargetHttpsProxiesRestTransport._SetSslCertificates._get_response( @@ -1481,7 +1957,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_ssl_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.set_ssl_certificates", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetSslCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSslPolicy( @@ -1520,7 +2018,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]]] = (), ) -> compute.Operation: r"""Call the set ssl policy method over HTTP. @@ -1532,8 +2030,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: ~.compute.Operation: @@ -1560,6 +2060,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseSetSslPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_ssl_policy(request, metadata) transcoded_request = _BaseTargetHttpsProxiesRestTransport._BaseSetSslPolicy._get_transcoded_request( http_options, request @@ -1574,6 +2075,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 = 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.compute_v1.TargetHttpsProxiesClient.SetSslPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetSslPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._SetSslPolicy._get_response( self._host, @@ -1595,7 +2123,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_ssl_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.set_ssl_policy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetSslPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUrlMap( @@ -1633,7 +2183,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]]] = (), ) -> compute.Operation: r"""Call the set url map method over HTTP. @@ -1645,8 +2195,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: ~.compute.Operation: @@ -1673,6 +2225,7 @@ def __call__( http_options = ( _BaseTargetHttpsProxiesRestTransport._BaseSetUrlMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_url_map(request, metadata) transcoded_request = _BaseTargetHttpsProxiesRestTransport._BaseSetUrlMap._get_transcoded_request( http_options, request @@ -1687,6 +2240,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 = 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.compute_v1.TargetHttpsProxiesClient.SetUrlMap", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetUrlMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetHttpsProxiesRestTransport._SetUrlMap._get_response( self._host, @@ -1708,7 +2288,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_url_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetHttpsProxiesClient.set_url_map", + extra={ + "serviceName": "google.cloud.compute.v1.TargetHttpsProxies", + "rpcName": "SetUrlMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/client.py index 35b3296d45d6..e04a462113be 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_instances import pagers @@ -560,6 +570,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( @@ -625,6 +639,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.compute_v1.TargetInstancesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "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.compute.v1.TargetInstances", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -634,7 +671,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of target instances. To prevent failure, Google recommends that you set the @@ -680,8 +717,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_instances.pagers.AggregatedListPager: @@ -753,7 +792,7 @@ def delete_unary( target_instance: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetInstance resource. @@ -812,8 +851,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -883,7 +924,7 @@ def delete( target_instance: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetInstance resource. @@ -942,8 +983,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1038,7 +1081,7 @@ def get( target_instance: 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]]] = (), ) -> compute.TargetInstance: r"""Returns the specified TargetInstance resource. @@ -1097,8 +1140,10 @@ def sample_get(): 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.compute_v1.types.TargetInstance: @@ -1174,7 +1219,7 @@ def insert_unary( target_instance_resource: Optional[compute.TargetInstance] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetInstance resource in the specified project and zone using the data included in the request. @@ -1231,8 +1276,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1301,7 +1348,7 @@ def insert( target_instance_resource: Optional[compute.TargetInstance] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetInstance resource in the specified project and zone using the data included in the request. @@ -1358,8 +1405,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1452,7 +1501,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of TargetInstance resources available to the specified project and zone. @@ -1505,8 +1554,10 @@ def sample_list(): 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.compute_v1.services.target_instances.pagers.ListPager: @@ -1592,7 +1643,7 @@ def set_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Google Cloud Armor security policy for the specified target instance. For more information, see @@ -1659,8 +1710,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -1741,7 +1794,7 @@ def set_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Google Cloud Armor security policy for the specified target instance. For more information, see @@ -1808,8 +1861,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/pagers.py index 5697526c60c1..67febeb55fb5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/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 = compute.AggregatedListTargetInstancesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetInstancesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/transports/rest.py index b32d7145028f..95de85e6a359 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_instances/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 @@ -37,6 +37,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, @@ -117,8 +125,11 @@ def post_set_security_policy(self, response): def pre_aggregated_list( self, request: compute.AggregatedListTargetInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListTargetInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListTargetInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -140,8 +151,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -161,8 +174,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -182,8 +197,10 @@ def post_get(self, response: compute.TargetInstance) -> compute.TargetInstance: def pre_insert( self, request: compute.InsertTargetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -203,8 +220,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -226,9 +245,10 @@ def post_list( def pre_set_security_policy( self, request: compute.SetSecurityPolicyTargetInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetSecurityPolicyTargetInstanceRequest, Sequence[Tuple[str, str]] + compute.SetSecurityPolicyTargetInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_security_policy @@ -373,7 +393,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]]] = (), ) -> compute.TargetInstanceAggregatedList: r"""Call the aggregated list method over HTTP. @@ -385,8 +405,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: ~.compute.TargetInstanceAggregatedList: @@ -396,6 +418,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetInstancesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -406,6 +429,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 = 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.compute_v1.TargetInstancesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._AggregatedList._get_response( self._host, @@ -426,7 +476,31 @@ def __call__( pb_resp = compute.TargetInstanceAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetInstanceAggregatedList.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.compute_v1.TargetInstancesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -463,7 +537,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -475,8 +549,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: ~.compute.Operation: @@ -503,6 +579,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetInstancesRestTransport._BaseDelete._get_transcoded_request( @@ -517,6 +594,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.compute_v1.TargetInstancesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._Delete._get_response( self._host, @@ -537,7 +641,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetInstancesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetInstancesRestTransport._BaseGet, TargetInstancesRestStub): @@ -572,7 +698,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]]] = (), ) -> compute.TargetInstance: r"""Call the get method over HTTP. @@ -584,8 +710,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: ~.compute.TargetInstance: @@ -603,6 +731,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetInstancesRestTransport._BaseGet._get_transcoded_request( @@ -617,6 +746,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.compute_v1.TargetInstancesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._Get._get_response( self._host, @@ -637,7 +793,29 @@ def __call__( pb_resp = compute.TargetInstance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetInstance.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.compute_v1.TargetInstancesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -675,7 +853,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -687,8 +865,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: ~.compute.Operation: @@ -715,6 +895,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetInstancesRestTransport._BaseInsert._get_transcoded_request( @@ -733,6 +914,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.compute_v1.TargetInstancesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._Insert._get_response( self._host, @@ -754,7 +962,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetInstancesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseTargetInstancesRestTransport._BaseList, TargetInstancesRestStub): @@ -789,7 +1019,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]]] = (), ) -> compute.TargetInstanceList: r"""Call the list method over HTTP. @@ -801,8 +1031,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: ~.compute.TargetInstanceList: @@ -814,6 +1046,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetInstancesRestTransport._BaseList._get_transcoded_request( @@ -828,6 +1061,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.compute_v1.TargetInstancesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._List._get_response( self._host, @@ -848,7 +1108,29 @@ def __call__( pb_resp = compute.TargetInstanceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetInstanceList.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.compute_v1.TargetInstancesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSecurityPolicy( @@ -887,7 +1169,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]]] = (), ) -> compute.Operation: r"""Call the set security policy method over HTTP. @@ -899,8 +1181,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: ~.compute.Operation: @@ -927,6 +1211,7 @@ def __call__( http_options = ( _BaseTargetInstancesRestTransport._BaseSetSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_security_policy( request, metadata ) @@ -943,6 +1228,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 = 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.compute_v1.TargetInstancesClient.SetSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "SetSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetInstancesRestTransport._SetSecurityPolicy._get_response( self._host, @@ -964,7 +1276,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetInstancesClient.set_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetInstances", + "rpcName": "SetSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/client.py index 3be7e5490ca8..0c1117991183 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_pools import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.TargetPoolsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "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.compute.v1.TargetPools", + "credentialsType": None, + }, + ) + def add_health_check_unary( self, request: Optional[Union[compute.AddHealthCheckTargetPoolRequest, dict]] = None, @@ -630,7 +667,7 @@ def add_health_check_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds health check URLs to a target pool. @@ -694,8 +731,10 @@ def sample_add_health_check(): 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.api_core.extended_operation.ExtendedOperation: @@ -779,7 +818,7 @@ def add_health_check( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds health check URLs to a target pool. @@ -843,8 +882,10 @@ def sample_add_health_check(): 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.api_core.extended_operation.ExtendedOperation: @@ -953,7 +994,7 @@ def add_instance_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Adds an instance to a target pool. @@ -1017,8 +1058,10 @@ def sample_add_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -1097,7 +1140,7 @@ def add_instance( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Adds an instance to a target pool. @@ -1161,8 +1204,10 @@ def sample_add_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -1261,7 +1306,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of target pools. To prevent failure, Google recommends that you set the @@ -1307,8 +1352,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_pools.pagers.AggregatedListPager: @@ -1380,7 +1427,7 @@ def delete_unary( target_pool: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified target pool. @@ -1439,8 +1486,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1510,7 +1559,7 @@ def delete( target_pool: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified target pool. @@ -1569,8 +1618,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1665,7 +1716,7 @@ def get( target_pool: 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]]] = (), ) -> compute.TargetPool: r"""Returns the specified target pool. @@ -1724,8 +1775,10 @@ def sample_get(): 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.compute_v1.types.TargetPool: @@ -1802,7 +1855,7 @@ def get_health( instance_reference_resource: Optional[compute.InstanceReference] = 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]]] = (), ) -> compute.TargetPoolInstanceHealth: r"""Gets the most recent health check results for each IP for the instance that is referenced by the given target @@ -1868,8 +1921,10 @@ def sample_get_health(): 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.compute_v1.types.TargetPoolInstanceHealth: @@ -1941,7 +1996,7 @@ def insert_unary( target_pool_resource: Optional[compute.TargetPool] = 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]]] = (), ) -> compute.Operation: r"""Creates a target pool in the specified project and region using the data included in the request. @@ -1998,8 +2053,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2068,7 +2125,7 @@ def insert( target_pool_resource: Optional[compute.TargetPool] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a target pool in the specified project and region using the data included in the request. @@ -2125,8 +2182,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -2219,7 +2278,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of target pools available to the specified project and region. @@ -2272,8 +2331,10 @@ def sample_list(): 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.compute_v1.services.target_pools.pagers.ListPager: @@ -2359,7 +2420,7 @@ def remove_health_check_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes health check URL from a target pool. @@ -2421,8 +2482,10 @@ def sample_remove_health_check(): 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.api_core.extended_operation.ExtendedOperation: @@ -2508,7 +2571,7 @@ def remove_health_check( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes health check URL from a target pool. @@ -2570,8 +2633,10 @@ def sample_remove_health_check(): 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.api_core.extended_operation.ExtendedOperation: @@ -2680,7 +2745,7 @@ def remove_instance_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Removes instance URL from a target pool. @@ -2744,8 +2809,10 @@ def sample_remove_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -2829,7 +2896,7 @@ def remove_instance( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Removes instance URL from a target pool. @@ -2893,8 +2960,10 @@ def sample_remove_instance(): 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.api_core.extended_operation.ExtendedOperation: @@ -3001,7 +3070,7 @@ def set_backup_unary( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> compute.Operation: r"""Changes a backup target pool's configurations. @@ -3065,8 +3134,10 @@ def sample_set_backup(): 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.api_core.extended_operation.ExtendedOperation: @@ -3141,7 +3212,7 @@ def set_backup( target_reference_resource: Optional[compute.TargetReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes a backup target pool's configurations. @@ -3205,8 +3276,10 @@ def sample_set_backup(): 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.api_core.extended_operation.ExtendedOperation: @@ -3310,7 +3383,7 @@ def set_security_policy_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the Google Cloud Armor security policy for the specified target pool. For more information, see Google @@ -3377,8 +3450,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: @@ -3459,7 +3534,7 @@ def set_security_policy( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the Google Cloud Armor security policy for the specified target pool. For more information, see Google @@ -3526,8 +3601,10 @@ def sample_set_security_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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/pagers.py index add0f57d2d7a..a73c8d456098 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/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 = compute.AggregatedListTargetPoolsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetPoolsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/transports/rest.py index 2d6dc843ce05..7797dad159a8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_pools/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 @@ -37,6 +37,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, @@ -165,8 +173,10 @@ def post_set_security_policy(self, response): def pre_add_health_check( self, request: compute.AddHealthCheckTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddHealthCheckTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddHealthCheckTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_health_check Override in a subclass to manipulate the request or metadata @@ -186,8 +196,10 @@ def post_add_health_check(self, response: compute.Operation) -> compute.Operatio def pre_add_instance( self, request: compute.AddInstanceTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AddInstanceTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AddInstanceTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for add_instance Override in a subclass to manipulate the request or metadata @@ -207,8 +219,11 @@ def post_add_instance(self, response: compute.Operation) -> compute.Operation: def pre_aggregated_list( self, request: compute.AggregatedListTargetPoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListTargetPoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListTargetPoolsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -230,8 +245,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -249,8 +266,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetTargetPoolRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetTargetPoolRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetTargetPoolRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -270,8 +289,10 @@ def post_get(self, response: compute.TargetPool) -> compute.TargetPool: def pre_get_health( self, request: compute.GetHealthTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetHealthTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetHealthTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_health Override in a subclass to manipulate the request or metadata @@ -293,8 +314,10 @@ def post_get_health( def pre_insert( self, request: compute.InsertTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -314,8 +337,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetPoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetPoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListTargetPoolsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -335,8 +358,11 @@ def post_list(self, response: compute.TargetPoolList) -> compute.TargetPoolList: def pre_remove_health_check( self, request: compute.RemoveHealthCheckTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveHealthCheckTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveHealthCheckTargetPoolRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for remove_health_check Override in a subclass to manipulate the request or metadata @@ -358,8 +384,10 @@ def post_remove_health_check( def pre_remove_instance( self, request: compute.RemoveInstanceTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.RemoveInstanceTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.RemoveInstanceTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for remove_instance Override in a subclass to manipulate the request or metadata @@ -379,8 +407,10 @@ def post_remove_instance(self, response: compute.Operation) -> compute.Operation def pre_set_backup( self, request: compute.SetBackupTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetBackupTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetBackupTargetPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_backup Override in a subclass to manipulate the request or metadata @@ -400,8 +430,11 @@ def post_set_backup(self, response: compute.Operation) -> compute.Operation: def pre_set_security_policy( self, request: compute.SetSecurityPolicyTargetPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetSecurityPolicyTargetPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetSecurityPolicyTargetPoolRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_security_policy Override in a subclass to manipulate the request or metadata @@ -546,7 +579,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]]] = (), ) -> compute.Operation: r"""Call the add health check method over HTTP. @@ -558,8 +591,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: ~.compute.Operation: @@ -586,6 +621,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseAddHealthCheck._get_http_options() ) + request, metadata = self._interceptor.pre_add_health_check( request, metadata ) @@ -602,6 +638,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 = 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.compute_v1.TargetPoolsClient.AddHealthCheck", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AddHealthCheck", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._AddHealthCheck._get_response( self._host, @@ -623,7 +686,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_health_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.add_health_check", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AddHealthCheck", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AddInstance( @@ -661,7 +746,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]]] = (), ) -> compute.Operation: r"""Call the add instance method over HTTP. @@ -673,8 +758,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: ~.compute.Operation: @@ -701,6 +788,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseAddInstance._get_http_options() ) + request, metadata = self._interceptor.pre_add_instance(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseAddInstance._get_transcoded_request( @@ -721,6 +809,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.compute_v1.TargetPoolsClient.AddInstance", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AddInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._AddInstance._get_response( self._host, @@ -742,7 +857,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_add_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.add_instance", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AddInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AggregatedList( @@ -779,7 +916,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]]] = (), ) -> compute.TargetPoolAggregatedList: r"""Call the aggregated list method over HTTP. @@ -791,8 +928,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: ~.compute.TargetPoolAggregatedList: @@ -802,6 +941,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetPoolsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -812,6 +952,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 = 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.compute_v1.TargetPoolsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._AggregatedList._get_response( self._host, @@ -832,7 +999,31 @@ def __call__( pb_resp = compute.TargetPoolAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetPoolAggregatedList.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.compute_v1.TargetPoolsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseTargetPoolsRestTransport._BaseDelete, TargetPoolsRestStub): @@ -867,7 +1058,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -879,8 +1070,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: ~.compute.Operation: @@ -905,6 +1098,7 @@ def __call__( """ http_options = _BaseTargetPoolsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseDelete._get_transcoded_request( @@ -919,6 +1113,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.compute_v1.TargetPoolsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._Delete._get_response( self._host, @@ -939,7 +1160,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetPoolsRestTransport._BaseGet, TargetPoolsRestStub): @@ -974,7 +1217,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]]] = (), ) -> compute.TargetPool: r"""Call the get method over HTTP. @@ -986,8 +1229,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: ~.compute.TargetPool: @@ -1003,6 +1248,7 @@ def __call__( """ http_options = _BaseTargetPoolsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseGet._get_transcoded_request( @@ -1017,6 +1263,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.compute_v1.TargetPoolsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._Get._get_response( self._host, @@ -1037,7 +1310,29 @@ def __call__( pb_resp = compute.TargetPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetPool.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.compute_v1.TargetPoolsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHealth(_BaseTargetPoolsRestTransport._BaseGetHealth, TargetPoolsRestStub): @@ -1073,7 +1368,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]]] = (), ) -> compute.TargetPoolInstanceHealth: r"""Call the get health method over HTTP. @@ -1085,8 +1380,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: ~.compute.TargetPoolInstanceHealth: @@ -1096,6 +1393,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseGetHealth._get_http_options() ) + request, metadata = self._interceptor.pre_get_health(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseGetHealth._get_transcoded_request( @@ -1114,6 +1412,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.compute_v1.TargetPoolsClient.GetHealth", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "GetHealth", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._GetHealth._get_response( self._host, @@ -1135,7 +1460,31 @@ def __call__( pb_resp = compute.TargetPoolInstanceHealth.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_health(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetPoolInstanceHealth.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.compute_v1.TargetPoolsClient.get_health", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "GetHealth", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseTargetPoolsRestTransport._BaseInsert, TargetPoolsRestStub): @@ -1171,7 +1520,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -1183,8 +1532,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: ~.compute.Operation: @@ -1209,6 +1560,7 @@ def __call__( """ http_options = _BaseTargetPoolsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseInsert._get_transcoded_request( @@ -1227,6 +1579,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.compute_v1.TargetPoolsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._Insert._get_response( self._host, @@ -1248,7 +1627,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseTargetPoolsRestTransport._BaseList, TargetPoolsRestStub): @@ -1283,7 +1684,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]]] = (), ) -> compute.TargetPoolList: r"""Call the list method over HTTP. @@ -1295,8 +1696,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: ~.compute.TargetPoolList: @@ -1306,6 +1709,7 @@ def __call__( """ http_options = _BaseTargetPoolsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseList._get_transcoded_request( @@ -1320,6 +1724,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.compute_v1.TargetPoolsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._List._get_response( self._host, @@ -1340,7 +1771,29 @@ def __call__( pb_resp = compute.TargetPoolList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetPoolList.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.compute_v1.TargetPoolsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveHealthCheck( @@ -1378,7 +1831,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]]] = (), ) -> compute.Operation: r"""Call the remove health check method over HTTP. @@ -1390,8 +1843,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: ~.compute.Operation: @@ -1418,6 +1873,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseRemoveHealthCheck._get_http_options() ) + request, metadata = self._interceptor.pre_remove_health_check( request, metadata ) @@ -1434,6 +1890,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 = 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.compute_v1.TargetPoolsClient.RemoveHealthCheck", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "RemoveHealthCheck", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._RemoveHealthCheck._get_response( self._host, @@ -1455,7 +1938,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_health_check(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.remove_health_check", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "RemoveHealthCheck", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RemoveInstance( @@ -1493,7 +1998,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]]] = (), ) -> compute.Operation: r"""Call the remove instance method over HTTP. @@ -1505,8 +2010,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: ~.compute.Operation: @@ -1533,6 +2040,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseRemoveInstance._get_http_options() ) + request, metadata = self._interceptor.pre_remove_instance(request, metadata) transcoded_request = _BaseTargetPoolsRestTransport._BaseRemoveInstance._get_transcoded_request( http_options, request @@ -1547,6 +2055,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 = 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.compute_v1.TargetPoolsClient.RemoveInstance", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "RemoveInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._RemoveInstance._get_response( self._host, @@ -1568,7 +2103,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_remove_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.remove_instance", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "RemoveInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetBackup(_BaseTargetPoolsRestTransport._BaseSetBackup, TargetPoolsRestStub): @@ -1604,7 +2161,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]]] = (), ) -> compute.Operation: r"""Call the set backup method over HTTP. @@ -1616,8 +2173,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: ~.compute.Operation: @@ -1644,6 +2203,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseSetBackup._get_http_options() ) + request, metadata = self._interceptor.pre_set_backup(request, metadata) transcoded_request = ( _BaseTargetPoolsRestTransport._BaseSetBackup._get_transcoded_request( @@ -1662,6 +2222,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.compute_v1.TargetPoolsClient.SetBackup", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "SetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._SetBackup._get_response( self._host, @@ -1683,7 +2270,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.set_backup", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "SetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSecurityPolicy( @@ -1721,7 +2330,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]]] = (), ) -> compute.Operation: r"""Call the set security policy method over HTTP. @@ -1733,8 +2342,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: ~.compute.Operation: @@ -1761,6 +2372,7 @@ def __call__( http_options = ( _BaseTargetPoolsRestTransport._BaseSetSecurityPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_security_policy( request, metadata ) @@ -1777,6 +2389,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 = 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.compute_v1.TargetPoolsClient.SetSecurityPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "SetSecurityPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetPoolsRestTransport._SetSecurityPolicy._get_response( self._host, @@ -1798,7 +2437,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_security_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetPoolsClient.set_security_policy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetPools", + "rpcName": "SetSecurityPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/client.py index 45690907b3b1..de9994658efa 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_ssl_proxies import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.TargetSslProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "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.compute.v1.TargetSslProxies", + "credentialsType": None, + }, + ) + def delete_unary( self, request: Optional[Union[compute.DeleteTargetSslProxyRequest, dict]] = None, @@ -634,7 +671,7 @@ def delete_unary( target_ssl_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetSslProxy resource. @@ -685,8 +722,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -752,7 +791,7 @@ def delete( target_ssl_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetSslProxy resource. @@ -803,8 +842,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -894,7 +935,7 @@ def get( target_ssl_proxy: 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]]] = (), ) -> compute.TargetSslProxy: r"""Returns the specified TargetSslProxy resource. @@ -945,8 +986,10 @@ def sample_get(): 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.compute_v1.types.TargetSslProxy: @@ -1018,7 +1061,7 @@ def insert_unary( target_ssl_proxy_resource: Optional[compute.TargetSslProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetSslProxy resource in the specified project using the data included in the request. @@ -1067,8 +1110,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1129,7 +1174,7 @@ def insert( target_ssl_proxy_resource: Optional[compute.TargetSslProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetSslProxy resource in the specified project using the data included in the request. @@ -1178,8 +1223,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1263,7 +1310,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of TargetSslProxy resources available to the specified project. @@ -1308,8 +1355,10 @@ def sample_list(): 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.compute_v1.services.target_ssl_proxies.pagers.ListPager: @@ -1387,7 +1436,7 @@ def set_backend_service_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the BackendService for TargetSslProxy. @@ -1444,8 +1493,10 @@ def sample_set_backend_service(): 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.api_core.extended_operation.ExtendedOperation: @@ -1526,7 +1577,7 @@ def set_backend_service( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the BackendService for TargetSslProxy. @@ -1583,8 +1634,10 @@ def sample_set_backend_service(): 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.api_core.extended_operation.ExtendedOperation: @@ -1689,7 +1742,7 @@ def set_certificate_map_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the Certificate Map for TargetSslProxy. @@ -1747,8 +1800,10 @@ def sample_set_certificate_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -1829,7 +1884,7 @@ def set_certificate_map( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the Certificate Map for TargetSslProxy. @@ -1887,8 +1942,10 @@ def sample_set_certificate_map(): 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.api_core.extended_operation.ExtendedOperation: @@ -1993,7 +2050,7 @@ def set_proxy_header_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the ProxyHeaderType for TargetSslProxy. @@ -2049,8 +2106,10 @@ def sample_set_proxy_header(): 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.api_core.extended_operation.ExtendedOperation: @@ -2131,7 +2190,7 @@ def set_proxy_header( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the ProxyHeaderType for TargetSslProxy. @@ -2187,8 +2246,10 @@ def sample_set_proxy_header(): 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.api_core.extended_operation.ExtendedOperation: @@ -2293,7 +2354,7 @@ def set_ssl_certificates_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes SslCertificates for TargetSslProxy. @@ -2350,8 +2411,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -2432,7 +2495,7 @@ def set_ssl_certificates( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes SslCertificates for TargetSslProxy. @@ -2489,8 +2552,10 @@ def sample_set_ssl_certificates(): 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.api_core.extended_operation.ExtendedOperation: @@ -2593,7 +2658,7 @@ def set_ssl_policy_unary( ssl_policy_reference_resource: Optional[compute.SslPolicyReference] = 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]]] = (), ) -> compute.Operation: r"""Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL @@ -2655,8 +2720,10 @@ def sample_set_ssl_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.api_core.extended_operation.ExtendedOperation: @@ -2729,7 +2796,7 @@ def set_ssl_policy( ssl_policy_reference_resource: Optional[compute.SslPolicyReference] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL @@ -2791,8 +2858,10 @@ def sample_set_ssl_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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/pagers.py index cc5e50bc70b9..e3976c2232f2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/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 = compute.ListTargetSslProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/transports/rest.py index 8026ad64534a..d726f94fc0a7 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_ssl_proxies/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 @@ -37,6 +37,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, @@ -141,8 +149,10 @@ def post_set_ssl_policy(self, response): def pre_delete( self, request: compute.DeleteTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetSslProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetSslProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -162,8 +172,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetSslProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetSslProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -183,8 +195,10 @@ def post_get(self, response: compute.TargetSslProxy) -> compute.TargetSslProxy: def pre_insert( self, request: compute.InsertTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetSslProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetSslProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -204,8 +218,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetSslProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetSslProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetSslProxiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -227,9 +243,10 @@ def post_list( def pre_set_backend_service( self, request: compute.SetBackendServiceTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetBackendServiceTargetSslProxyRequest, Sequence[Tuple[str, str]] + compute.SetBackendServiceTargetSslProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_backend_service @@ -252,9 +269,10 @@ def post_set_backend_service( def pre_set_certificate_map( self, request: compute.SetCertificateMapTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetCertificateMapTargetSslProxyRequest, Sequence[Tuple[str, str]] + compute.SetCertificateMapTargetSslProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_certificate_map @@ -277,8 +295,11 @@ def post_set_certificate_map( def pre_set_proxy_header( self, request: compute.SetProxyHeaderTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetProxyHeaderTargetSslProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetProxyHeaderTargetSslProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_proxy_header Override in a subclass to manipulate the request or metadata @@ -298,9 +319,10 @@ def post_set_proxy_header(self, response: compute.Operation) -> compute.Operatio def pre_set_ssl_certificates( self, request: compute.SetSslCertificatesTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetSslCertificatesTargetSslProxyRequest, Sequence[Tuple[str, str]] + compute.SetSslCertificatesTargetSslProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_ssl_certificates @@ -323,8 +345,11 @@ def post_set_ssl_certificates( def pre_set_ssl_policy( self, request: compute.SetSslPolicyTargetSslProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetSslPolicyTargetSslProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetSslPolicyTargetSslProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_ssl_policy Override in a subclass to manipulate the request or metadata @@ -466,7 +491,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -478,8 +503,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: ~.compute.Operation: @@ -506,6 +533,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetSslProxiesRestTransport._BaseDelete._get_transcoded_request( @@ -520,6 +548,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.compute_v1.TargetSslProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._Delete._get_response( self._host, @@ -540,7 +595,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetSslProxiesRestTransport._BaseGet, TargetSslProxiesRestStub): @@ -575,7 +652,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]]] = (), ) -> compute.TargetSslProxy: r"""Call the get method over HTTP. @@ -587,8 +664,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: ~.compute.TargetSslProxy: @@ -606,6 +685,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetSslProxiesRestTransport._BaseGet._get_transcoded_request( @@ -620,6 +700,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.compute_v1.TargetSslProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._Get._get_response( self._host, @@ -640,7 +747,29 @@ def __call__( pb_resp = compute.TargetSslProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetSslProxy.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.compute_v1.TargetSslProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -678,7 +807,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -690,8 +819,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: ~.compute.Operation: @@ -718,6 +849,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetSslProxiesRestTransport._BaseInsert._get_transcoded_request( @@ -738,6 +870,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.compute_v1.TargetSslProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._Insert._get_response( self._host, @@ -759,7 +918,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseTargetSslProxiesRestTransport._BaseList, TargetSslProxiesRestStub): @@ -794,7 +975,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]]] = (), ) -> compute.TargetSslProxyList: r"""Call the list method over HTTP. @@ -806,8 +987,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: ~.compute.TargetSslProxyList: @@ -819,6 +1002,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetSslProxiesRestTransport._BaseList._get_transcoded_request( @@ -833,6 +1017,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.compute_v1.TargetSslProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._List._get_response( self._host, @@ -853,7 +1064,29 @@ def __call__( pb_resp = compute.TargetSslProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetSslProxyList.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.compute_v1.TargetSslProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetBackendService( @@ -892,7 +1125,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]]] = (), ) -> compute.Operation: r"""Call the set backend service method over HTTP. @@ -904,8 +1137,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: ~.compute.Operation: @@ -932,6 +1167,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseSetBackendService._get_http_options() ) + request, metadata = self._interceptor.pre_set_backend_service( request, metadata ) @@ -948,6 +1184,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 = 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.compute_v1.TargetSslProxiesClient.SetBackendService", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetBackendService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._SetBackendService._get_response( self._host, @@ -969,7 +1232,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_backend_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.set_backend_service", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetBackendService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetCertificateMap( @@ -1008,7 +1293,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]]] = (), ) -> compute.Operation: r"""Call the set certificate map method over HTTP. @@ -1020,8 +1305,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: ~.compute.Operation: @@ -1048,6 +1335,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseSetCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_set_certificate_map( request, metadata ) @@ -1064,6 +1352,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 = 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.compute_v1.TargetSslProxiesClient.SetCertificateMap", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._SetCertificateMap._get_response( self._host, @@ -1085,7 +1400,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.set_certificate_map", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetProxyHeader( @@ -1123,7 +1460,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]]] = (), ) -> compute.Operation: r"""Call the set proxy header method over HTTP. @@ -1135,8 +1472,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: ~.compute.Operation: @@ -1163,6 +1502,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseSetProxyHeader._get_http_options() ) + request, metadata = self._interceptor.pre_set_proxy_header( request, metadata ) @@ -1179,6 +1519,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 = 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.compute_v1.TargetSslProxiesClient.SetProxyHeader", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetProxyHeader", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._SetProxyHeader._get_response( self._host, @@ -1200,7 +1567,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_proxy_header(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.set_proxy_header", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetProxyHeader", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSslCertificates( @@ -1239,7 +1628,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]]] = (), ) -> compute.Operation: r"""Call the set ssl certificates method over HTTP. @@ -1251,8 +1640,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: ~.compute.Operation: @@ -1279,6 +1670,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseSetSslCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_set_ssl_certificates( request, metadata ) @@ -1295,6 +1687,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 = 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.compute_v1.TargetSslProxiesClient.SetSslCertificates", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetSslCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._SetSslCertificates._get_response( self._host, @@ -1316,7 +1735,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_ssl_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.set_ssl_certificates", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetSslCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSslPolicy( @@ -1354,7 +1795,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]]] = (), ) -> compute.Operation: r"""Call the set ssl policy method over HTTP. @@ -1366,8 +1807,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: ~.compute.Operation: @@ -1394,6 +1837,7 @@ def __call__( http_options = ( _BaseTargetSslProxiesRestTransport._BaseSetSslPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_ssl_policy(request, metadata) transcoded_request = _BaseTargetSslProxiesRestTransport._BaseSetSslPolicy._get_transcoded_request( http_options, request @@ -1408,6 +1852,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 = 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.compute_v1.TargetSslProxiesClient.SetSslPolicy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetSslPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetSslProxiesRestTransport._SetSslPolicy._get_response( self._host, @@ -1429,7 +1900,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_ssl_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetSslProxiesClient.set_ssl_policy", + extra={ + "serviceName": "google.cloud.compute.v1.TargetSslProxies", + "rpcName": "SetSslPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/client.py index a7af51bee5ff..64f885819f99 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_tcp_proxies import pagers @@ -560,6 +570,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( @@ -626,6 +640,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.compute_v1.TargetTcpProxiesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "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.compute.v1.TargetTcpProxies", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -635,7 +672,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project. To prevent failure, @@ -684,8 +721,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_tcp_proxies.pagers.AggregatedListPager: @@ -756,7 +795,7 @@ def delete_unary( target_tcp_proxy: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified TargetTcpProxy resource. @@ -807,8 +846,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -874,7 +915,7 @@ def delete( target_tcp_proxy: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified TargetTcpProxy resource. @@ -925,8 +966,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1016,7 +1059,7 @@ def get( target_tcp_proxy: 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]]] = (), ) -> compute.TargetTcpProxy: r"""Returns the specified TargetTcpProxy resource. @@ -1067,8 +1110,10 @@ def sample_get(): 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.compute_v1.types.TargetTcpProxy: @@ -1140,7 +1185,7 @@ def insert_unary( target_tcp_proxy_resource: Optional[compute.TargetTcpProxy] = 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]]] = (), ) -> compute.Operation: r"""Creates a TargetTcpProxy resource in the specified project using the data included in the request. @@ -1189,8 +1234,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1251,7 +1298,7 @@ def insert( target_tcp_proxy_resource: Optional[compute.TargetTcpProxy] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a TargetTcpProxy resource in the specified project using the data included in the request. @@ -1300,8 +1347,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1385,7 +1434,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of TargetTcpProxy resources available to the specified project. @@ -1430,8 +1479,10 @@ def sample_list(): 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.compute_v1.services.target_tcp_proxies.pagers.ListPager: @@ -1509,7 +1560,7 @@ def set_backend_service_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the BackendService for TargetTcpProxy. @@ -1566,8 +1617,10 @@ def sample_set_backend_service(): 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.api_core.extended_operation.ExtendedOperation: @@ -1648,7 +1701,7 @@ def set_backend_service( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the BackendService for TargetTcpProxy. @@ -1705,8 +1758,10 @@ def sample_set_backend_service(): 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.api_core.extended_operation.ExtendedOperation: @@ -1811,7 +1866,7 @@ def set_proxy_header_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Changes the ProxyHeaderType for TargetTcpProxy. @@ -1867,8 +1922,10 @@ def sample_set_proxy_header(): 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.api_core.extended_operation.ExtendedOperation: @@ -1949,7 +2006,7 @@ def set_proxy_header( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Changes the ProxyHeaderType for TargetTcpProxy. @@ -2005,8 +2062,10 @@ def sample_set_proxy_header(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/pagers.py index c7e5439f1115..1395206ec078 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/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 = compute.AggregatedListTargetTcpProxiesRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetTcpProxiesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/transports/rest.py index 919e8941c0f4..0a829769ab5f 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_tcp_proxies/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 @@ -37,6 +37,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, @@ -125,9 +133,10 @@ def post_set_proxy_header(self, response): def pre_aggregated_list( self, request: compute.AggregatedListTargetTcpProxiesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListTargetTcpProxiesRequest, Sequence[Tuple[str, str]] + compute.AggregatedListTargetTcpProxiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -150,8 +159,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetTcpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -171,8 +182,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetTcpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -192,8 +205,10 @@ def post_get(self, response: compute.TargetTcpProxy) -> compute.TargetTcpProxy: def pre_insert( self, request: compute.InsertTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetTcpProxyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -213,8 +228,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetTcpProxiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetTcpProxiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetTcpProxiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -236,9 +253,10 @@ def post_list( def pre_set_backend_service( self, request: compute.SetBackendServiceTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.SetBackendServiceTargetTcpProxyRequest, Sequence[Tuple[str, str]] + compute.SetBackendServiceTargetTcpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_backend_service @@ -261,8 +279,11 @@ def post_set_backend_service( def pre_set_proxy_header( self, request: compute.SetProxyHeaderTargetTcpProxyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetProxyHeaderTargetTcpProxyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetProxyHeaderTargetTcpProxyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_proxy_header Override in a subclass to manipulate the request or metadata @@ -404,7 +425,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]]] = (), ) -> compute.TargetTcpProxyAggregatedList: r"""Call the aggregated list method over HTTP. @@ -416,8 +437,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: ~.compute.TargetTcpProxyAggregatedList: @@ -427,6 +450,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetTcpProxiesRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -437,6 +461,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 = 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.compute_v1.TargetTcpProxiesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._AggregatedList._get_response( self._host, @@ -457,7 +508,31 @@ def __call__( pb_resp = compute.TargetTcpProxyAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetTcpProxyAggregatedList.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.compute_v1.TargetTcpProxiesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -494,7 +569,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -506,8 +581,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: ~.compute.Operation: @@ -534,6 +611,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetTcpProxiesRestTransport._BaseDelete._get_transcoded_request( @@ -548,6 +626,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.compute_v1.TargetTcpProxiesClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._Delete._get_response( self._host, @@ -568,7 +673,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetTcpProxiesClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetTcpProxiesRestTransport._BaseGet, TargetTcpProxiesRestStub): @@ -603,7 +730,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]]] = (), ) -> compute.TargetTcpProxy: r"""Call the get method over HTTP. @@ -615,8 +742,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: ~.compute.TargetTcpProxy: @@ -634,6 +763,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetTcpProxiesRestTransport._BaseGet._get_transcoded_request( @@ -648,6 +778,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.compute_v1.TargetTcpProxiesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._Get._get_response( self._host, @@ -668,7 +825,29 @@ def __call__( pb_resp = compute.TargetTcpProxy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetTcpProxy.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.compute_v1.TargetTcpProxiesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -706,7 +885,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -718,8 +897,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: ~.compute.Operation: @@ -746,6 +927,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetTcpProxiesRestTransport._BaseInsert._get_transcoded_request( @@ -766,6 +948,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.compute_v1.TargetTcpProxiesClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._Insert._get_response( self._host, @@ -787,7 +996,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetTcpProxiesClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseTargetTcpProxiesRestTransport._BaseList, TargetTcpProxiesRestStub): @@ -822,7 +1053,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]]] = (), ) -> compute.TargetTcpProxyList: r"""Call the list method over HTTP. @@ -834,8 +1065,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: ~.compute.TargetTcpProxyList: @@ -847,6 +1080,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetTcpProxiesRestTransport._BaseList._get_transcoded_request( @@ -861,6 +1095,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.compute_v1.TargetTcpProxiesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._List._get_response( self._host, @@ -881,7 +1142,29 @@ def __call__( pb_resp = compute.TargetTcpProxyList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetTcpProxyList.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.compute_v1.TargetTcpProxiesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetBackendService( @@ -920,7 +1203,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]]] = (), ) -> compute.Operation: r"""Call the set backend service method over HTTP. @@ -932,8 +1215,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: ~.compute.Operation: @@ -960,6 +1245,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseSetBackendService._get_http_options() ) + request, metadata = self._interceptor.pre_set_backend_service( request, metadata ) @@ -976,6 +1262,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 = 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.compute_v1.TargetTcpProxiesClient.SetBackendService", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "SetBackendService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._SetBackendService._get_response( self._host, @@ -997,7 +1310,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_backend_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetTcpProxiesClient.set_backend_service", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "SetBackendService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetProxyHeader( @@ -1035,7 +1370,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]]] = (), ) -> compute.Operation: r"""Call the set proxy header method over HTTP. @@ -1047,8 +1382,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: ~.compute.Operation: @@ -1075,6 +1412,7 @@ def __call__( http_options = ( _BaseTargetTcpProxiesRestTransport._BaseSetProxyHeader._get_http_options() ) + request, metadata = self._interceptor.pre_set_proxy_header( request, metadata ) @@ -1091,6 +1429,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 = 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.compute_v1.TargetTcpProxiesClient.SetProxyHeader", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "SetProxyHeader", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetTcpProxiesRestTransport._SetProxyHeader._get_response( self._host, @@ -1112,7 +1477,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_proxy_header(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetTcpProxiesClient.set_proxy_header", + extra={ + "serviceName": "google.cloud.compute.v1.TargetTcpProxies", + "rpcName": "SetProxyHeader", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/client.py index 2f1ac9316952..62d4ce13bace 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.target_vpn_gateways import pagers @@ -562,6 +572,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( @@ -628,6 +642,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.compute_v1.TargetVpnGatewaysClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "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.compute.v1.TargetVpnGateways", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[ @@ -637,7 +674,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of target VPN gateways. To prevent failure, Google recommends that you set the @@ -683,8 +720,10 @@ def sample_aggregated_list(): 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.compute_v1.services.target_vpn_gateways.pagers.AggregatedListPager: @@ -756,7 +795,7 @@ def delete_unary( target_vpn_gateway: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified target VPN gateway. @@ -813,8 +852,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -884,7 +925,7 @@ def delete( target_vpn_gateway: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified target VPN gateway. @@ -941,8 +982,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1037,7 +1080,7 @@ def get( target_vpn_gateway: 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]]] = (), ) -> compute.TargetVpnGateway: r"""Returns the specified target VPN gateway. @@ -1094,8 +1137,10 @@ def sample_get(): 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.compute_v1.types.TargetVpnGateway: @@ -1168,7 +1213,7 @@ def insert_unary( target_vpn_gateway_resource: Optional[compute.TargetVpnGateway] = 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]]] = (), ) -> compute.Operation: r"""Creates a target VPN gateway in the specified project and region using the data included in the request. @@ -1223,8 +1268,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1293,7 +1340,7 @@ def insert( target_vpn_gateway_resource: Optional[compute.TargetVpnGateway] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a target VPN gateway in the specified project and region using the data included in the request. @@ -1348,8 +1395,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1442,7 +1491,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of target VPN gateways available to the specified project and region. @@ -1493,8 +1542,10 @@ def sample_list(): 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.compute_v1.services.target_vpn_gateways.pagers.ListPager: @@ -1578,7 +1629,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. @@ -1641,8 +1692,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1721,7 +1774,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. @@ -1784,8 +1837,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/pagers.py index 6f5df6042386..f23ed152d921 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/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 = compute.AggregatedListTargetVpnGatewaysRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListTargetVpnGatewaysRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/transports/rest.py index 607cd93f083c..9d8c80468517 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/target_vpn_gateways/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 @@ -37,6 +37,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, @@ -117,9 +125,10 @@ def post_set_labels(self, response): def pre_aggregated_list( self, request: compute.AggregatedListTargetVpnGatewaysRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - compute.AggregatedListTargetVpnGatewaysRequest, Sequence[Tuple[str, str]] + compute.AggregatedListTargetVpnGatewaysRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for aggregated_list @@ -142,8 +151,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteTargetVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteTargetVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteTargetVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -163,8 +174,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: def pre_get( self, request: compute.GetTargetVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetTargetVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetTargetVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -184,8 +197,10 @@ def post_get(self, response: compute.TargetVpnGateway) -> compute.TargetVpnGatew def pre_insert( self, request: compute.InsertTargetVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertTargetVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertTargetVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -205,8 +220,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListTargetVpnGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListTargetVpnGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListTargetVpnGatewaysRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -228,8 +245,11 @@ def post_list( def pre_set_labels( self, request: compute.SetLabelsTargetVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsTargetVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsTargetVpnGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -372,7 +392,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]]] = (), ) -> compute.TargetVpnGatewayAggregatedList: r"""Call the aggregated list method over HTTP. @@ -384,8 +404,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: ~.compute.TargetVpnGatewayAggregatedList: @@ -395,6 +417,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseTargetVpnGatewaysRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -405,6 +428,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 = 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.compute_v1.TargetVpnGatewaysClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._AggregatedList._get_response( self._host, @@ -425,7 +475,31 @@ def __call__( pb_resp = compute.TargetVpnGatewayAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetVpnGatewayAggregatedList.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.compute_v1.TargetVpnGatewaysClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete( @@ -462,7 +536,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -474,8 +548,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: ~.compute.Operation: @@ -502,6 +578,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseTargetVpnGatewaysRestTransport._BaseDelete._get_transcoded_request( @@ -516,6 +593,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.compute_v1.TargetVpnGatewaysClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._Delete._get_response( self._host, @@ -536,7 +640,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetVpnGatewaysClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseTargetVpnGatewaysRestTransport._BaseGet, TargetVpnGatewaysRestStub): @@ -571,7 +697,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]]] = (), ) -> compute.TargetVpnGateway: r"""Call the get method over HTTP. @@ -583,8 +709,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: ~.compute.TargetVpnGateway: @@ -599,6 +727,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseGet._get_http_options() ) + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseTargetVpnGatewaysRestTransport._BaseGet._get_transcoded_request( @@ -613,6 +742,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.compute_v1.TargetVpnGatewaysClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._Get._get_response( self._host, @@ -633,7 +789,29 @@ def __call__( pb_resp = compute.TargetVpnGateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetVpnGateway.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.compute_v1.TargetVpnGatewaysClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert( @@ -671,7 +849,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -683,8 +861,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: ~.compute.Operation: @@ -711,6 +891,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseInsert._get_http_options() ) + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseTargetVpnGatewaysRestTransport._BaseInsert._get_transcoded_request( @@ -731,6 +912,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.compute_v1.TargetVpnGatewaysClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._Insert._get_response( self._host, @@ -752,7 +960,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetVpnGatewaysClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List( @@ -789,7 +1019,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]]] = (), ) -> compute.TargetVpnGatewayList: r"""Call the list method over HTTP. @@ -801,8 +1031,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: ~.compute.TargetVpnGatewayList: @@ -814,6 +1046,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseTargetVpnGatewaysRestTransport._BaseList._get_transcoded_request( @@ -828,6 +1061,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.compute_v1.TargetVpnGatewaysClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._List._get_response( self._host, @@ -848,7 +1108,29 @@ def __call__( pb_resp = compute.TargetVpnGatewayList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.TargetVpnGatewayList.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.compute_v1.TargetVpnGatewaysClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels( @@ -886,7 +1168,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -898,8 +1180,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: ~.compute.Operation: @@ -926,6 +1210,7 @@ def __call__( http_options = ( _BaseTargetVpnGatewaysRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = _BaseTargetVpnGatewaysRestTransport._BaseSetLabels._get_transcoded_request( http_options, request @@ -940,6 +1225,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 = 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.compute_v1.TargetVpnGatewaysClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TargetVpnGatewaysRestTransport._SetLabels._get_response( self._host, @@ -961,7 +1273,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.TargetVpnGatewaysClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.TargetVpnGateways", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/client.py index 8d3417f41f9e..d87b650b1423 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.url_maps import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.UrlMapsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "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.compute.v1.UrlMaps", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListUrlMapsRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves the list of all UrlMap resources, regional and global, available to the specified project. To prevent failure, Google @@ -674,8 +711,10 @@ def sample_aggregated_list(): 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.compute_v1.services.url_maps.pagers.AggregatedListPager: @@ -746,7 +785,7 @@ def delete_unary( url_map: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified UrlMap resource. @@ -796,8 +835,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -863,7 +904,7 @@ def delete( url_map: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified UrlMap resource. @@ -913,8 +954,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1004,7 +1047,7 @@ def get( url_map: 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]]] = (), ) -> compute.UrlMap: r"""Returns the specified UrlMap resource. @@ -1054,8 +1097,10 @@ def sample_get(): 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.compute_v1.types.UrlMap: @@ -1144,7 +1189,7 @@ def insert_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Creates a UrlMap resource in the specified project using the data included in the request. @@ -1192,8 +1237,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1254,7 +1301,7 @@ def insert( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a UrlMap resource in the specified project using the data included in the request. @@ -1302,8 +1349,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1391,7 +1440,7 @@ def invalidate_cache_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more @@ -1450,8 +1499,10 @@ def sample_invalidate_cache(): 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.api_core.extended_operation.ExtendedOperation: @@ -1524,7 +1575,7 @@ def invalidate_cache( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more @@ -1583,8 +1634,10 @@ def sample_invalidate_cache(): 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.api_core.extended_operation.ExtendedOperation: @@ -1677,7 +1730,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of UrlMap resources available to the specified project. @@ -1721,8 +1774,10 @@ def sample_list(): 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.compute_v1.services.url_maps.pagers.ListPager: @@ -1796,7 +1851,7 @@ def patch_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Patches the specified UrlMap resource with the data included in the request. This method supports PATCH @@ -1852,8 +1907,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -1922,7 +1979,7 @@ def patch( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Patches the specified UrlMap resource with the data included in the request. This method supports PATCH @@ -1978,8 +2035,10 @@ def sample_patch(): 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.api_core.extended_operation.ExtendedOperation: @@ -2072,7 +2131,7 @@ def update_unary( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> compute.Operation: r"""Updates the specified UrlMap resource with the data included in the request. @@ -2128,8 +2187,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2198,7 +2259,7 @@ def update( url_map_resource: Optional[compute.UrlMap] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Updates the specified UrlMap resource with the data included in the request. @@ -2254,8 +2315,10 @@ def sample_update(): 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.api_core.extended_operation.ExtendedOperation: @@ -2350,7 +2413,7 @@ def validate( ] = 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]]] = (), ) -> compute.UrlMapsValidateResponse: r"""Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling @@ -2408,8 +2471,10 @@ def sample_validate(): 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.compute_v1.types.UrlMapsValidateResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/pagers.py index 68dba97c88f1..a7fb2dbee288 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/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 = compute.AggregatedListUrlMapsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListUrlMapsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/transports/rest.py index ce9647dd6788..17e0523837ba 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/url_maps/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 @@ -37,6 +37,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, @@ -141,8 +149,10 @@ def post_validate(self, response): def pre_aggregated_list( self, request: compute.AggregatedListUrlMapsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListUrlMapsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListUrlMapsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -162,8 +172,10 @@ def post_aggregated_list( return response def pre_delete( - self, request: compute.DeleteUrlMapRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.DeleteUrlMapRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.DeleteUrlMapRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -181,8 +193,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetUrlMapRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetUrlMapRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetUrlMapRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -200,8 +214,10 @@ def post_get(self, response: compute.UrlMap) -> compute.UrlMap: return response def pre_insert( - self, request: compute.InsertUrlMapRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.InsertUrlMapRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.InsertUrlMapRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -221,8 +237,10 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_invalidate_cache( self, request: compute.InvalidateCacheUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InvalidateCacheUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InvalidateCacheUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for invalidate_cache Override in a subclass to manipulate the request or metadata @@ -240,8 +258,10 @@ def post_invalidate_cache(self, response: compute.Operation) -> compute.Operatio return response def pre_list( - self, request: compute.ListUrlMapsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListUrlMapsRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListUrlMapsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListUrlMapsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -259,8 +279,10 @@ def post_list(self, response: compute.UrlMapList) -> compute.UrlMapList: return response def pre_patch( - self, request: compute.PatchUrlMapRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.PatchUrlMapRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.PatchUrlMapRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.PatchUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for patch Override in a subclass to manipulate the request or metadata @@ -278,8 +300,10 @@ def post_patch(self, response: compute.Operation) -> compute.Operation: return response def pre_update( - self, request: compute.UpdateUrlMapRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.UpdateUrlMapRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.UpdateUrlMapRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.UpdateUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update Override in a subclass to manipulate the request or metadata @@ -299,8 +323,8 @@ def post_update(self, response: compute.Operation) -> compute.Operation: def pre_validate( self, request: compute.ValidateUrlMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ValidateUrlMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ValidateUrlMapRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for validate Override in a subclass to manipulate the request or metadata @@ -444,7 +468,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]]] = (), ) -> compute.UrlMapsAggregatedList: r"""Call the aggregated list method over HTTP. @@ -456,8 +480,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: ~.compute.UrlMapsAggregatedList: @@ -467,6 +493,7 @@ def __call__( http_options = ( _BaseUrlMapsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseAggregatedList._get_transcoded_request( @@ -481,6 +508,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.compute_v1.UrlMapsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._AggregatedList._get_response( self._host, @@ -501,7 +555,29 @@ def __call__( pb_resp = compute.UrlMapsAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMapsAggregatedList.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.compute_v1.UrlMapsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseUrlMapsRestTransport._BaseDelete, UrlMapsRestStub): @@ -536,7 +612,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -547,8 +623,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: ~.compute.Operation: @@ -573,6 +651,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseDelete._get_transcoded_request( @@ -585,6 +664,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 = 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.compute_v1.UrlMapsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Delete._get_response( self._host, @@ -605,7 +711,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.UrlMapsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseUrlMapsRestTransport._BaseGet, UrlMapsRestStub): @@ -640,7 +768,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]]] = (), ) -> compute.UrlMap: r"""Call the get method over HTTP. @@ -651,8 +779,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: ~.compute.UrlMap: @@ -685,6 +815,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseGet._get_transcoded_request( @@ -697,6 +828,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 = 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.compute_v1.UrlMapsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Get._get_response( self._host, @@ -717,7 +875,29 @@ def __call__( pb_resp = compute.UrlMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMap.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.compute_v1.UrlMapsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseUrlMapsRestTransport._BaseInsert, UrlMapsRestStub): @@ -753,7 +933,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -764,8 +944,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: ~.compute.Operation: @@ -790,6 +972,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseInsert._get_transcoded_request( @@ -806,6 +989,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 = 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.compute_v1.UrlMapsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Insert._get_response( self._host, @@ -827,7 +1037,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.UrlMapsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InvalidateCache( @@ -865,7 +1097,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]]] = (), ) -> compute.Operation: r"""Call the invalidate cache method over HTTP. @@ -877,8 +1109,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: ~.compute.Operation: @@ -905,6 +1139,7 @@ def __call__( http_options = ( _BaseUrlMapsRestTransport._BaseInvalidateCache._get_http_options() ) + request, metadata = self._interceptor.pre_invalidate_cache( request, metadata ) @@ -927,6 +1162,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.compute_v1.UrlMapsClient.InvalidateCache", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "InvalidateCache", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._InvalidateCache._get_response( self._host, @@ -948,7 +1210,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_invalidate_cache(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.UrlMapsClient.invalidate_cache", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "InvalidateCache", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseUrlMapsRestTransport._BaseList, UrlMapsRestStub): @@ -983,7 +1267,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]]] = (), ) -> compute.UrlMapList: r"""Call the list method over HTTP. @@ -994,8 +1278,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: ~.compute.UrlMapList: @@ -1003,6 +1289,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseList._get_transcoded_request( @@ -1015,6 +1302,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 = 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.compute_v1.UrlMapsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._List._get_response( self._host, @@ -1035,7 +1349,29 @@ def __call__( pb_resp = compute.UrlMapList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMapList.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.compute_v1.UrlMapsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Patch(_BaseUrlMapsRestTransport._BasePatch, UrlMapsRestStub): @@ -1071,7 +1407,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]]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. @@ -1082,8 +1418,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: ~.compute.Operation: @@ -1108,6 +1446,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BasePatch._get_http_options() + request, metadata = self._interceptor.pre_patch(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BasePatch._get_transcoded_request( @@ -1124,6 +1463,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 = 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.compute_v1.UrlMapsClient.Patch", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Patch", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Patch._get_response( self._host, @@ -1145,7 +1511,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_patch(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.UrlMapsClient.patch", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Patch", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Update(_BaseUrlMapsRestTransport._BaseUpdate, UrlMapsRestStub): @@ -1181,7 +1569,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]]] = (), ) -> compute.Operation: r"""Call the update method over HTTP. @@ -1192,8 +1580,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: ~.compute.Operation: @@ -1218,6 +1608,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseUpdate._get_http_options() + request, metadata = self._interceptor.pre_update(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseUpdate._get_transcoded_request( @@ -1234,6 +1625,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 = 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.compute_v1.UrlMapsClient.Update", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Update", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Update._get_response( self._host, @@ -1255,7 +1673,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.UrlMapsClient.update", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Update", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Validate(_BaseUrlMapsRestTransport._BaseValidate, UrlMapsRestStub): @@ -1291,7 +1731,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]]] = (), ) -> compute.UrlMapsValidateResponse: r"""Call the validate method over HTTP. @@ -1303,8 +1743,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: ~.compute.UrlMapsValidateResponse: @@ -1312,6 +1754,7 @@ def __call__( """ http_options = _BaseUrlMapsRestTransport._BaseValidate._get_http_options() + request, metadata = self._interceptor.pre_validate(request, metadata) transcoded_request = ( _BaseUrlMapsRestTransport._BaseValidate._get_transcoded_request( @@ -1330,6 +1773,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.compute_v1.UrlMapsClient.Validate", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Validate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UrlMapsRestTransport._Validate._get_response( self._host, @@ -1351,7 +1821,29 @@ def __call__( pb_resp = compute.UrlMapsValidateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.UrlMapsValidateResponse.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.compute_v1.UrlMapsClient.validate", + extra={ + "serviceName": "google.cloud.compute.v1.UrlMaps", + "rpcName": "Validate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/client.py index cfcae3e45681..5cbd8d054495 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.vpn_gateways import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.VpnGatewaysClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "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.compute.v1.VpnGateways", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListVpnGatewaysRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of VPN gateways. To prevent failure, Google recommends that you set the @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.vpn_gateways.pagers.AggregatedListPager: @@ -744,7 +783,7 @@ def delete_unary( vpn_gateway: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified VPN gateway. @@ -799,8 +838,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -870,7 +911,7 @@ def delete( vpn_gateway: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified VPN gateway. @@ -925,8 +966,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1021,7 +1064,7 @@ def get( vpn_gateway: 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]]] = (), ) -> compute.VpnGateway: r"""Returns the specified VPN gateway. @@ -1076,8 +1119,10 @@ def sample_get(): 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.compute_v1.types.VpnGateway: @@ -1154,7 +1199,7 @@ def get_status( vpn_gateway: 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]]] = (), ) -> compute.VpnGatewaysGetStatusResponse: r"""Returns the status for the specified VPN gateway. @@ -1209,8 +1254,10 @@ def sample_get_status(): 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.compute_v1.types.VpnGatewaysGetStatusResponse: @@ -1278,7 +1325,7 @@ def insert_unary( vpn_gateway_resource: Optional[compute.VpnGateway] = 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]]] = (), ) -> compute.Operation: r"""Creates a VPN gateway in the specified project and region using the data included in the request. @@ -1333,8 +1380,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1403,7 +1452,7 @@ def insert( vpn_gateway_resource: Optional[compute.VpnGateway] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a VPN gateway in the specified project and region using the data included in the request. @@ -1458,8 +1507,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1552,7 +1603,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of VPN gateways available to the specified project and region. @@ -1603,8 +1654,10 @@ def sample_list(): 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.compute_v1.services.vpn_gateways.pagers.ListPager: @@ -1688,7 +1741,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. @@ -1751,8 +1804,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1831,7 +1886,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. @@ -1894,8 +1949,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -2001,7 +2058,7 @@ def test_iam_permissions( ] = 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]]] = (), ) -> compute.TestPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. @@ -2066,8 +2123,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.cloud.compute_v1.types.TestPermissionsResponse: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/pagers.py index 6a6099b853a3..c6209248d9f8 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/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 = compute.AggregatedListVpnGatewaysRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListVpnGatewaysRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/transports/rest.py index 49bbaa601074..281b1961ab98 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_gateways/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 @@ -37,6 +37,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, @@ -133,8 +141,11 @@ def post_test_iam_permissions(self, response): def pre_aggregated_list( self, request: compute.AggregatedListVpnGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListVpnGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListVpnGatewaysRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -156,8 +167,10 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -175,8 +188,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetVpnGatewayRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetVpnGatewayRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetVpnGatewayRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -196,8 +211,10 @@ def post_get(self, response: compute.VpnGateway) -> compute.VpnGateway: def pre_get_status( self, request: compute.GetStatusVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetStatusVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetStatusVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_status Override in a subclass to manipulate the request or metadata @@ -219,8 +236,10 @@ def post_get_status( def pre_insert( self, request: compute.InsertVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.InsertVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -240,8 +259,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListVpnGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListVpnGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListVpnGatewaysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -261,8 +280,10 @@ def post_list(self, response: compute.VpnGatewayList) -> compute.VpnGatewayList: def pre_set_labels( self, request: compute.SetLabelsVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsVpnGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -282,8 +303,11 @@ def post_set_labels(self, response: compute.Operation) -> compute.Operation: def pre_test_iam_permissions( self, request: compute.TestIamPermissionsVpnGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.TestIamPermissionsVpnGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.TestIamPermissionsVpnGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -427,7 +451,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]]] = (), ) -> compute.VpnGatewayAggregatedList: r"""Call the aggregated list method over HTTP. @@ -439,8 +463,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: ~.compute.VpnGatewayAggregatedList: @@ -450,6 +476,7 @@ def __call__( http_options = ( _BaseVpnGatewaysRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseVpnGatewaysRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -460,6 +487,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 = 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.compute_v1.VpnGatewaysClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._AggregatedList._get_response( self._host, @@ -480,7 +534,31 @@ def __call__( pb_resp = compute.VpnGatewayAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnGatewayAggregatedList.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.compute_v1.VpnGatewaysClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseVpnGatewaysRestTransport._BaseDelete, VpnGatewaysRestStub): @@ -515,7 +593,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -527,8 +605,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: ~.compute.Operation: @@ -553,6 +633,7 @@ def __call__( """ http_options = _BaseVpnGatewaysRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseDelete._get_transcoded_request( @@ -567,6 +648,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.compute_v1.VpnGatewaysClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._Delete._get_response( self._host, @@ -587,7 +695,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnGatewaysClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseVpnGatewaysRestTransport._BaseGet, VpnGatewaysRestStub): @@ -622,7 +752,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]]] = (), ) -> compute.VpnGateway: r"""Call the get method over HTTP. @@ -634,8 +764,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: ~.compute.VpnGateway: @@ -652,6 +784,7 @@ def __call__( """ http_options = _BaseVpnGatewaysRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseGet._get_transcoded_request( @@ -666,6 +799,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.compute_v1.VpnGatewaysClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._Get._get_response( self._host, @@ -686,7 +846,29 @@ def __call__( pb_resp = compute.VpnGateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnGateway.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.compute_v1.VpnGatewaysClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStatus(_BaseVpnGatewaysRestTransport._BaseGetStatus, VpnGatewaysRestStub): @@ -721,7 +903,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]]] = (), ) -> compute.VpnGatewaysGetStatusResponse: r"""Call the get status method over HTTP. @@ -733,8 +915,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: ~.compute.VpnGatewaysGetStatusResponse: @@ -744,6 +928,7 @@ def __call__( http_options = ( _BaseVpnGatewaysRestTransport._BaseGetStatus._get_http_options() ) + request, metadata = self._interceptor.pre_get_status(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseGetStatus._get_transcoded_request( @@ -758,6 +943,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.compute_v1.VpnGatewaysClient.GetStatus", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "GetStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._GetStatus._get_response( self._host, @@ -778,7 +990,31 @@ def __call__( pb_resp = compute.VpnGatewaysGetStatusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnGatewaysGetStatusResponse.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.compute_v1.VpnGatewaysClient.get_status", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "GetStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseVpnGatewaysRestTransport._BaseInsert, VpnGatewaysRestStub): @@ -814,7 +1050,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -826,8 +1062,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: ~.compute.Operation: @@ -852,6 +1090,7 @@ def __call__( """ http_options = _BaseVpnGatewaysRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseInsert._get_transcoded_request( @@ -870,6 +1109,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.compute_v1.VpnGatewaysClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._Insert._get_response( self._host, @@ -891,7 +1157,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnGatewaysClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseVpnGatewaysRestTransport._BaseList, VpnGatewaysRestStub): @@ -926,7 +1214,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]]] = (), ) -> compute.VpnGatewayList: r"""Call the list method over HTTP. @@ -938,8 +1226,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: ~.compute.VpnGatewayList: @@ -949,6 +1239,7 @@ def __call__( """ http_options = _BaseVpnGatewaysRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseList._get_transcoded_request( @@ -963,6 +1254,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.compute_v1.VpnGatewaysClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._List._get_response( self._host, @@ -983,7 +1301,29 @@ def __call__( pb_resp = compute.VpnGatewayList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnGatewayList.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.compute_v1.VpnGatewaysClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseVpnGatewaysRestTransport._BaseSetLabels, VpnGatewaysRestStub): @@ -1019,7 +1359,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -1031,8 +1371,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: ~.compute.Operation: @@ -1059,6 +1401,7 @@ def __call__( http_options = ( _BaseVpnGatewaysRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseVpnGatewaysRestTransport._BaseSetLabels._get_transcoded_request( @@ -1077,6 +1420,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.compute_v1.VpnGatewaysClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._SetLabels._get_response( self._host, @@ -1098,7 +1468,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnGatewaysClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1136,7 +1528,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]]] = (), ) -> compute.TestPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1148,8 +1540,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: ~.compute.TestPermissionsResponse: @@ -1159,6 +1553,7 @@ def __call__( http_options = ( _BaseVpnGatewaysRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1175,6 +1570,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 = 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.compute_v1.VpnGatewaysClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnGatewaysRestTransport._TestIamPermissions._get_response( self._host, @@ -1196,7 +1618,29 @@ def __call__( pb_resp = compute.TestPermissionsResponse.pb(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 = compute.TestPermissionsResponse.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.compute_v1.VpnGatewaysClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.compute.v1.VpnGateways", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/client.py index 232f0698d33a..d1413f8e1425 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/client.py @@ -15,6 +15,7 @@ # from collections import OrderedDict import functools +import logging as std_logging import os import re from typing import ( @@ -49,6 +50,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.api_core import extended_operation # type: ignore from google.cloud.compute_v1.services.vpn_tunnels import pagers @@ -556,6 +566,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( @@ -618,6 +632,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.compute_v1.VpnTunnelsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "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.compute.v1.VpnTunnels", + "credentialsType": None, + }, + ) + def aggregated_list( self, request: Optional[Union[compute.AggregatedListVpnTunnelsRequest, dict]] = None, @@ -625,7 +662,7 @@ def aggregated_list( project: 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.AggregatedListPager: r"""Retrieves an aggregated list of VPN tunnels. To prevent failure, Google recommends that you set the ``returnPartialSuccess`` @@ -671,8 +708,10 @@ def sample_aggregated_list(): 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.compute_v1.services.vpn_tunnels.pagers.AggregatedListPager: @@ -744,7 +783,7 @@ def delete_unary( vpn_tunnel: 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]]] = (), ) -> compute.Operation: r"""Deletes the specified VpnTunnel resource. @@ -801,8 +840,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -872,7 +913,7 @@ def delete( vpn_tunnel: 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Deletes the specified VpnTunnel resource. @@ -929,8 +970,10 @@ def sample_delete(): 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.api_core.extended_operation.ExtendedOperation: @@ -1025,7 +1068,7 @@ def get( vpn_tunnel: 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]]] = (), ) -> compute.VpnTunnel: r"""Returns the specified VpnTunnel resource. @@ -1081,8 +1124,10 @@ def sample_get(): 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.compute_v1.types.VpnTunnel: @@ -1153,7 +1198,7 @@ def insert_unary( vpn_tunnel_resource: Optional[compute.VpnTunnel] = 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]]] = (), ) -> compute.Operation: r"""Creates a VpnTunnel resource in the specified project and region using the data included in the request. @@ -1208,8 +1253,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1278,7 +1325,7 @@ def insert( vpn_tunnel_resource: Optional[compute.VpnTunnel] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Creates a VpnTunnel resource in the specified project and region using the data included in the request. @@ -1333,8 +1380,10 @@ def sample_insert(): 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.api_core.extended_operation.ExtendedOperation: @@ -1427,7 +1476,7 @@ def list( region: 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.ListPager: r"""Retrieves a list of VpnTunnel resources contained in the specified project and region. @@ -1478,8 +1527,10 @@ def sample_list(): 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.compute_v1.services.vpn_tunnels.pagers.ListPager: @@ -1563,7 +1614,7 @@ def set_labels_unary( ] = 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]]] = (), ) -> compute.Operation: r"""Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. @@ -1626,8 +1677,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: @@ -1706,7 +1759,7 @@ def set_labels( ] = 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]]] = (), ) -> extended_operation.ExtendedOperation: r"""Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. @@ -1769,8 +1822,10 @@ def sample_set_labels(): 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.api_core.extended_operation.ExtendedOperation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/pagers.py index 9db6d72ed184..150e2aa0ad77 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/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 = compute.AggregatedListVpnTunnelsRequest(request) @@ -144,7 +146,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. @@ -158,8 +160,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 = compute.ListVpnTunnelsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/transports/rest.py index 27630a6ee551..22611696f5a3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/vpn_tunnels/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 @@ -37,6 +37,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, @@ -117,8 +125,10 @@ def post_set_labels(self, response): def pre_aggregated_list( self, request: compute.AggregatedListVpnTunnelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.AggregatedListVpnTunnelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListVpnTunnelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for aggregated_list Override in a subclass to manipulate the request or metadata @@ -140,8 +150,8 @@ def post_aggregated_list( def pre_delete( self, request: compute.DeleteVpnTunnelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteVpnTunnelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.DeleteVpnTunnelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -159,8 +169,10 @@ def post_delete(self, response: compute.Operation) -> compute.Operation: return response def pre_get( - self, request: compute.GetVpnTunnelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetVpnTunnelRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetVpnTunnelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetVpnTunnelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -180,8 +192,8 @@ def post_get(self, response: compute.VpnTunnel) -> compute.VpnTunnel: def pre_insert( self, request: compute.InsertVpnTunnelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.InsertVpnTunnelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.InsertVpnTunnelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for insert Override in a subclass to manipulate the request or metadata @@ -201,8 +213,8 @@ def post_insert(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListVpnTunnelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListVpnTunnelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListVpnTunnelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -222,8 +234,10 @@ def post_list(self, response: compute.VpnTunnelList) -> compute.VpnTunnelList: def pre_set_labels( self, request: compute.SetLabelsVpnTunnelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.SetLabelsVpnTunnelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.SetLabelsVpnTunnelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_labels Override in a subclass to manipulate the request or metadata @@ -365,7 +379,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]]] = (), ) -> compute.VpnTunnelAggregatedList: r"""Call the aggregated list method over HTTP. @@ -377,8 +391,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: ~.compute.VpnTunnelAggregatedList: @@ -388,6 +404,7 @@ def __call__( http_options = ( _BaseVpnTunnelsRestTransport._BaseAggregatedList._get_http_options() ) + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) transcoded_request = _BaseVpnTunnelsRestTransport._BaseAggregatedList._get_transcoded_request( http_options, request @@ -400,6 +417,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.compute_v1.VpnTunnelsClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._AggregatedList._get_response( self._host, @@ -420,7 +464,29 @@ def __call__( pb_resp = compute.VpnTunnelAggregatedList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnTunnelAggregatedList.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.compute_v1.VpnTunnelsClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Delete(_BaseVpnTunnelsRestTransport._BaseDelete, VpnTunnelsRestStub): @@ -455,7 +521,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]]] = (), ) -> compute.Operation: r"""Call the delete method over HTTP. @@ -467,8 +533,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: ~.compute.Operation: @@ -493,6 +561,7 @@ def __call__( """ http_options = _BaseVpnTunnelsRestTransport._BaseDelete._get_http_options() + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseVpnTunnelsRestTransport._BaseDelete._get_transcoded_request( @@ -507,6 +576,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.compute_v1.VpnTunnelsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._Delete._get_response( self._host, @@ -527,7 +623,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnTunnelsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseVpnTunnelsRestTransport._BaseGet, VpnTunnelsRestStub): @@ -562,7 +680,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]]] = (), ) -> compute.VpnTunnel: r"""Call the get method over HTTP. @@ -573,8 +691,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: ~.compute.VpnTunnel: @@ -585,6 +705,7 @@ def __call__( """ http_options = _BaseVpnTunnelsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseVpnTunnelsRestTransport._BaseGet._get_transcoded_request( @@ -597,6 +718,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 = 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.compute_v1.VpnTunnelsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._Get._get_response( self._host, @@ -617,7 +765,29 @@ def __call__( pb_resp = compute.VpnTunnel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnTunnel.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.compute_v1.VpnTunnelsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Insert(_BaseVpnTunnelsRestTransport._BaseInsert, VpnTunnelsRestStub): @@ -653,7 +823,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]]] = (), ) -> compute.Operation: r"""Call the insert method over HTTP. @@ -665,8 +835,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: ~.compute.Operation: @@ -691,6 +863,7 @@ def __call__( """ http_options = _BaseVpnTunnelsRestTransport._BaseInsert._get_http_options() + request, metadata = self._interceptor.pre_insert(request, metadata) transcoded_request = ( _BaseVpnTunnelsRestTransport._BaseInsert._get_transcoded_request( @@ -709,6 +882,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.compute_v1.VpnTunnelsClient.Insert", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Insert", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._Insert._get_response( self._host, @@ -730,7 +930,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_insert(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnTunnelsClient.insert", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "Insert", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseVpnTunnelsRestTransport._BaseList, VpnTunnelsRestStub): @@ -765,7 +987,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]]] = (), ) -> compute.VpnTunnelList: r"""Call the list method over HTTP. @@ -777,8 +999,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: ~.compute.VpnTunnelList: @@ -788,6 +1012,7 @@ def __call__( """ http_options = _BaseVpnTunnelsRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseVpnTunnelsRestTransport._BaseList._get_transcoded_request( @@ -802,6 +1027,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.compute_v1.VpnTunnelsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._List._get_response( self._host, @@ -822,7 +1074,29 @@ def __call__( pb_resp = compute.VpnTunnelList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.VpnTunnelList.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.compute_v1.VpnTunnelsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetLabels(_BaseVpnTunnelsRestTransport._BaseSetLabels, VpnTunnelsRestStub): @@ -858,7 +1132,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]]] = (), ) -> compute.Operation: r"""Call the set labels method over HTTP. @@ -870,8 +1144,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: ~.compute.Operation: @@ -898,6 +1174,7 @@ def __call__( http_options = ( _BaseVpnTunnelsRestTransport._BaseSetLabels._get_http_options() ) + request, metadata = self._interceptor.pre_set_labels(request, metadata) transcoded_request = ( _BaseVpnTunnelsRestTransport._BaseSetLabels._get_transcoded_request( @@ -916,6 +1193,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.compute_v1.VpnTunnelsClient.SetLabels", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "SetLabels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VpnTunnelsRestTransport._SetLabels._get_response( self._host, @@ -937,7 +1241,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_labels(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.VpnTunnelsClient.set_labels", + extra={ + "serviceName": "google.cloud.compute.v1.VpnTunnels", + "rpcName": "SetLabels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/client.py index 2269e94c2de7..25206835ba0d 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/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.compute_v1.services.zone_operations import pagers from google.cloud.compute_v1.types import compute @@ -555,6 +565,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( @@ -620,6 +634,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.compute_v1.ZoneOperationsClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "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.compute.v1.ZoneOperations", + "credentialsType": None, + }, + ) + def delete( self, request: Optional[Union[compute.DeleteZoneOperationRequest, dict]] = None, @@ -629,7 +666,7 @@ def delete( operation: 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]]] = (), ) -> compute.DeleteZoneOperationResponse: r"""Deletes the specified zone-specific Operations resource. @@ -688,8 +725,10 @@ def sample_delete(): 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.compute_v1.types.DeleteZoneOperationResponse: @@ -760,7 +799,7 @@ def get( operation: 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]]] = (), ) -> compute.Operation: r"""Retrieves the specified zone-specific Operations resource. @@ -819,8 +858,10 @@ def sample_get(): 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.compute_v1.types.Operation: @@ -904,7 +945,7 @@ def list( zone: 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.ListPager: r"""Retrieves a list of Operation resources contained within the specified zone. @@ -955,8 +996,10 @@ def sample_list(): 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.compute_v1.services.zone_operations.pagers.ListPager: @@ -1037,7 +1080,7 @@ def wait( operation: 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]]] = (), ) -> compute.Operation: r"""Waits for the specified Operation resource to return as ``DONE`` or for the request to approach the 2 minute deadline, and @@ -1106,8 +1149,10 @@ def sample_wait(): 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.compute_v1.types.Operation: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/pagers.py index 5108e52df97d..7581368fb764 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/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 = compute.ListZoneOperationsRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/transports/rest.py index a380b9cfa85a..669067058e57 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zone_operations/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 @@ -37,6 +37,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, @@ -101,8 +109,10 @@ def post_wait(self, response): def pre_delete( self, request: compute.DeleteZoneOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.DeleteZoneOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.DeleteZoneOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete Override in a subclass to manipulate the request or metadata @@ -124,8 +134,10 @@ def post_delete( def pre_get( self, request: compute.GetZoneOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.GetZoneOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.GetZoneOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -145,8 +157,10 @@ def post_get(self, response: compute.Operation) -> compute.Operation: def pre_list( self, request: compute.ListZoneOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.ListZoneOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.ListZoneOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_list(self, response: compute.OperationList) -> compute.OperationList: def pre_wait( self, request: compute.WaitZoneOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[compute.WaitZoneOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.WaitZoneOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for wait Override in a subclass to manipulate the request or metadata @@ -307,7 +323,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]]] = (), ) -> compute.DeleteZoneOperationResponse: r"""Call the delete method over HTTP. @@ -319,8 +335,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: ~.compute.DeleteZoneOperationResponse: @@ -333,6 +351,7 @@ def __call__( http_options = ( _BaseZoneOperationsRestTransport._BaseDelete._get_http_options() ) + request, metadata = self._interceptor.pre_delete(request, metadata) transcoded_request = ( _BaseZoneOperationsRestTransport._BaseDelete._get_transcoded_request( @@ -347,6 +366,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.compute_v1.ZoneOperationsClient.Delete", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Delete", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZoneOperationsRestTransport._Delete._get_response( self._host, @@ -367,7 +413,31 @@ def __call__( pb_resp = compute.DeleteZoneOperationResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.DeleteZoneOperationResponse.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.compute_v1.ZoneOperationsClient.delete", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Delete", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Get(_BaseZoneOperationsRestTransport._BaseGet, ZoneOperationsRestStub): @@ -402,7 +472,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]]] = (), ) -> compute.Operation: r"""Call the get method over HTTP. @@ -414,8 +484,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: ~.compute.Operation: @@ -440,6 +512,7 @@ def __call__( """ http_options = _BaseZoneOperationsRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseZoneOperationsRestTransport._BaseGet._get_transcoded_request( @@ -454,6 +527,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.compute_v1.ZoneOperationsClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZoneOperationsRestTransport._Get._get_response( self._host, @@ -474,7 +574,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ZoneOperationsClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseZoneOperationsRestTransport._BaseList, ZoneOperationsRestStub): @@ -509,7 +631,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]]] = (), ) -> compute.OperationList: r"""Call the list method over HTTP. @@ -521,8 +643,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: ~.compute.OperationList: @@ -534,6 +658,7 @@ def __call__( http_options = ( _BaseZoneOperationsRestTransport._BaseList._get_http_options() ) + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseZoneOperationsRestTransport._BaseList._get_transcoded_request( @@ -548,6 +673,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.compute_v1.ZoneOperationsClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZoneOperationsRestTransport._List._get_response( self._host, @@ -568,7 +720,29 @@ def __call__( pb_resp = compute.OperationList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.OperationList.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.compute_v1.ZoneOperationsClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Wait(_BaseZoneOperationsRestTransport._BaseWait, ZoneOperationsRestStub): @@ -603,7 +777,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]]] = (), ) -> compute.Operation: r"""Call the wait method over HTTP. @@ -615,8 +789,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: ~.compute.Operation: @@ -643,6 +819,7 @@ def __call__( http_options = ( _BaseZoneOperationsRestTransport._BaseWait._get_http_options() ) + request, metadata = self._interceptor.pre_wait(request, metadata) transcoded_request = ( _BaseZoneOperationsRestTransport._BaseWait._get_transcoded_request( @@ -657,6 +834,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.compute_v1.ZoneOperationsClient.Wait", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Wait", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZoneOperationsRestTransport._Wait._get_response( self._host, @@ -677,7 +881,29 @@ def __call__( pb_resp = compute.Operation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_wait(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Operation.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.compute_v1.ZoneOperationsClient.wait", + extra={ + "serviceName": "google.cloud.compute.v1.ZoneOperations", + "rpcName": "Wait", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/client.py index 19cd5b5b32ab..57a60c0dbd86 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/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.compute_v1.services.zones import pagers from google.cloud.compute_v1.types import compute @@ -553,6 +563,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( @@ -615,6 +629,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.compute_v1.ZonesClient`.", + extra={ + "serviceName": "google.cloud.compute.v1.Zones", + "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.compute.v1.Zones", + "credentialsType": None, + }, + ) + def get( self, request: Optional[Union[compute.GetZoneRequest, dict]] = None, @@ -623,7 +660,7 @@ def get( zone: 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]]] = (), ) -> compute.Zone: r"""Returns the specified Zone resource. @@ -671,8 +708,10 @@ def sample_get(): 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.compute_v1.types.Zone: @@ -741,7 +780,7 @@ def list( project: 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.ListPager: r"""Retrieves the list of Zone resources available to the specified project. @@ -785,8 +824,10 @@ def sample_list(): 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.compute_v1.services.zones.pagers.ListPager: diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/pagers.py index d9f2c47463d8..5516b11b511b 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/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 = compute.ListZonesRequest(request) diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/transports/rest.py index 34e7120035a7..9c3c7f7aceb2 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/zones/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 @@ -37,6 +37,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, @@ -83,8 +91,10 @@ def post_list(self, response): """ def pre_get( - self, request: compute.GetZoneRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.GetZoneRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.GetZoneRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.GetZoneRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get Override in a subclass to manipulate the request or metadata @@ -102,8 +112,10 @@ def post_get(self, response: compute.Zone) -> compute.Zone: return response def pre_list( - self, request: compute.ListZonesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[compute.ListZonesRequest, Sequence[Tuple[str, str]]]: + self, + request: compute.ListZonesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[compute.ListZonesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list Override in a subclass to manipulate the request or metadata @@ -243,7 +255,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]]] = (), ) -> compute.Zone: r"""Call the get method over HTTP. @@ -254,8 +266,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: ~.compute.Zone: @@ -269,6 +283,7 @@ def __call__( """ http_options = _BaseZonesRestTransport._BaseGet._get_http_options() + request, metadata = self._interceptor.pre_get(request, metadata) transcoded_request = ( _BaseZonesRestTransport._BaseGet._get_transcoded_request( @@ -281,6 +296,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 = 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.compute_v1.ZonesClient.Get", + extra={ + "serviceName": "google.cloud.compute.v1.Zones", + "rpcName": "Get", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZonesRestTransport._Get._get_response( self._host, @@ -301,7 +343,29 @@ def __call__( pb_resp = compute.Zone.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.Zone.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.compute_v1.ZonesClient.get", + extra={ + "serviceName": "google.cloud.compute.v1.Zones", + "rpcName": "Get", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _List(_BaseZonesRestTransport._BaseList, ZonesRestStub): @@ -336,7 +400,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]]] = (), ) -> compute.ZoneList: r"""Call the list method over HTTP. @@ -347,8 +411,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: ~.compute.ZoneList: @@ -356,6 +422,7 @@ def __call__( """ http_options = _BaseZonesRestTransport._BaseList._get_http_options() + request, metadata = self._interceptor.pre_list(request, metadata) transcoded_request = ( _BaseZonesRestTransport._BaseList._get_transcoded_request( @@ -368,6 +435,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 = 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.compute_v1.ZonesClient.List", + extra={ + "serviceName": "google.cloud.compute.v1.Zones", + "rpcName": "List", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ZonesRestTransport._List._get_response( self._host, @@ -388,7 +482,29 @@ def __call__( pb_resp = compute.ZoneList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = compute.ZoneList.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.compute_v1.ZonesClient.list", + extra={ + "serviceName": "google.cloud.compute.v1.Zones", + "rpcName": "List", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py index 10aa25c16145..a8b9f8257d40 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py @@ -424,6 +424,7 @@ GetNetworkEdgeSecurityServiceRequest, GetNetworkEndpointGroupRequest, GetNetworkFirewallPolicyRequest, + GetNetworkProfileRequest, GetNetworkRequest, GetNodeGroupRequest, GetNodeTemplateRequest, @@ -643,9 +644,14 @@ InstanceGroupManagersListPerInstanceConfigsResp, InstanceGroupManagersPatchPerInstanceConfigsReq, InstanceGroupManagersRecreateInstancesRequest, + InstanceGroupManagersResumeInstancesRequest, InstanceGroupManagersScopedList, InstanceGroupManagersSetInstanceTemplateRequest, InstanceGroupManagersSetTargetPoolsRequest, + InstanceGroupManagersStartInstancesRequest, + InstanceGroupManagersStopInstancesRequest, + InstanceGroupManagersSuspendInstancesRequest, + InstanceGroupManagerStandbyPolicy, InstanceGroupManagerStatus, InstanceGroupManagerStatusAllInstancesConfig, InstanceGroupManagerStatusStateful, @@ -785,6 +791,7 @@ ListNetworkEndpointsNetworkEndpointGroupsRequest, ListNetworkEndpointsRegionNetworkEndpointGroupsRequest, ListNetworkFirewallPoliciesRequest, + ListNetworkProfilesRequest, ListNetworksRequest, ListNodeGroupsRequest, ListNodesNodeGroupsRequest, @@ -906,6 +913,10 @@ NetworkList, NetworkPeering, NetworkPerformanceConfig, + NetworkProfile, + NetworkProfileLocation, + NetworkProfileNetworkFeatures, + NetworkProfilesListResponse, NetworkRoutingConfig, NetworksAddPeeringRequest, NetworksGetEffectiveFirewallsResponse, @@ -1057,8 +1068,12 @@ RegionInstanceGroupManagersListInstanceConfigsResp, RegionInstanceGroupManagersListInstancesResponse, RegionInstanceGroupManagersRecreateRequest, + RegionInstanceGroupManagersResumeInstancesRequest, RegionInstanceGroupManagersSetTargetPoolsRequest, RegionInstanceGroupManagersSetTemplateRequest, + RegionInstanceGroupManagersStartInstancesRequest, + RegionInstanceGroupManagersStopInstancesRequest, + RegionInstanceGroupManagersSuspendInstancesRequest, RegionInstanceGroupManagerUpdateInstanceConfigReq, RegionInstanceGroupsListInstances, RegionInstanceGroupsListInstancesRequest, @@ -1123,6 +1138,8 @@ ResourceStatus, ResourceStatusScheduling, ResumeInstanceRequest, + ResumeInstancesInstanceGroupManagerRequest, + ResumeInstancesRegionInstanceGroupManagerRequest, Route, RouteAsPath, RouteList, @@ -1253,6 +1270,7 @@ SetLabelsInterconnectRequest, SetLabelsRegionDiskRequest, SetLabelsRegionInstantSnapshotRequest, + SetLabelsRegionSecurityPolicyRequest, SetLabelsSecurityPolicyRequest, SetLabelsSnapshotRequest, SetLabelsTargetVpnGatewayRequest, @@ -1326,6 +1344,8 @@ StartAsyncReplicationDiskRequest, StartAsyncReplicationRegionDiskRequest, StartInstanceRequest, + StartInstancesInstanceGroupManagerRequest, + StartInstancesRegionInstanceGroupManagerRequest, StartWithEncryptionKeyInstanceRequest, StatefulPolicy, StatefulPolicyPreservedState, @@ -1337,6 +1357,8 @@ StopGroupAsyncReplicationDiskRequest, StopGroupAsyncReplicationRegionDiskRequest, StopInstanceRequest, + StopInstancesInstanceGroupManagerRequest, + StopInstancesRegionInstanceGroupManagerRequest, StoragePool, StoragePoolAggregatedList, StoragePoolDisk, @@ -1358,6 +1380,8 @@ SubnetworksSetPrivateIpGoogleAccessRequest, Subsetting, SuspendInstanceRequest, + SuspendInstancesInstanceGroupManagerRequest, + SuspendInstancesRegionInstanceGroupManagerRequest, SwitchToCustomModeNetworkRequest, Tags, TargetGrpcProxy, @@ -1926,6 +1950,7 @@ "GetNetworkEdgeSecurityServiceRequest", "GetNetworkEndpointGroupRequest", "GetNetworkFirewallPolicyRequest", + "GetNetworkProfileRequest", "GetNetworkRequest", "GetNodeGroupRequest", "GetNodeTemplateRequest", @@ -2145,9 +2170,14 @@ "InstanceGroupManagersListPerInstanceConfigsResp", "InstanceGroupManagersPatchPerInstanceConfigsReq", "InstanceGroupManagersRecreateInstancesRequest", + "InstanceGroupManagersResumeInstancesRequest", "InstanceGroupManagersScopedList", "InstanceGroupManagersSetInstanceTemplateRequest", "InstanceGroupManagersSetTargetPoolsRequest", + "InstanceGroupManagersStartInstancesRequest", + "InstanceGroupManagersStopInstancesRequest", + "InstanceGroupManagersSuspendInstancesRequest", + "InstanceGroupManagerStandbyPolicy", "InstanceGroupManagerStatus", "InstanceGroupManagerStatusAllInstancesConfig", "InstanceGroupManagerStatusStateful", @@ -2287,6 +2317,7 @@ "ListNetworkEndpointsNetworkEndpointGroupsRequest", "ListNetworkEndpointsRegionNetworkEndpointGroupsRequest", "ListNetworkFirewallPoliciesRequest", + "ListNetworkProfilesRequest", "ListNetworksRequest", "ListNodeGroupsRequest", "ListNodesNodeGroupsRequest", @@ -2408,6 +2439,10 @@ "NetworkList", "NetworkPeering", "NetworkPerformanceConfig", + "NetworkProfile", + "NetworkProfileLocation", + "NetworkProfileNetworkFeatures", + "NetworkProfilesListResponse", "NetworkRoutingConfig", "NetworksAddPeeringRequest", "NetworksGetEffectiveFirewallsResponse", @@ -2559,8 +2594,12 @@ "RegionInstanceGroupManagersListInstanceConfigsResp", "RegionInstanceGroupManagersListInstancesResponse", "RegionInstanceGroupManagersRecreateRequest", + "RegionInstanceGroupManagersResumeInstancesRequest", "RegionInstanceGroupManagersSetTargetPoolsRequest", "RegionInstanceGroupManagersSetTemplateRequest", + "RegionInstanceGroupManagersStartInstancesRequest", + "RegionInstanceGroupManagersStopInstancesRequest", + "RegionInstanceGroupManagersSuspendInstancesRequest", "RegionInstanceGroupManagerUpdateInstanceConfigReq", "RegionInstanceGroupsListInstances", "RegionInstanceGroupsListInstancesRequest", @@ -2625,6 +2664,8 @@ "ResourceStatus", "ResourceStatusScheduling", "ResumeInstanceRequest", + "ResumeInstancesInstanceGroupManagerRequest", + "ResumeInstancesRegionInstanceGroupManagerRequest", "Route", "RouteAsPath", "RouteList", @@ -2755,6 +2796,7 @@ "SetLabelsInterconnectRequest", "SetLabelsRegionDiskRequest", "SetLabelsRegionInstantSnapshotRequest", + "SetLabelsRegionSecurityPolicyRequest", "SetLabelsSecurityPolicyRequest", "SetLabelsSnapshotRequest", "SetLabelsTargetVpnGatewayRequest", @@ -2828,6 +2870,8 @@ "StartAsyncReplicationDiskRequest", "StartAsyncReplicationRegionDiskRequest", "StartInstanceRequest", + "StartInstancesInstanceGroupManagerRequest", + "StartInstancesRegionInstanceGroupManagerRequest", "StartWithEncryptionKeyInstanceRequest", "StatefulPolicy", "StatefulPolicyPreservedState", @@ -2839,6 +2883,8 @@ "StopGroupAsyncReplicationDiskRequest", "StopGroupAsyncReplicationRegionDiskRequest", "StopInstanceRequest", + "StopInstancesInstanceGroupManagerRequest", + "StopInstancesRegionInstanceGroupManagerRequest", "StoragePool", "StoragePoolAggregatedList", "StoragePoolDisk", @@ -2860,6 +2906,8 @@ "SubnetworksSetPrivateIpGoogleAccessRequest", "Subsetting", "SuspendInstanceRequest", + "SuspendInstancesInstanceGroupManagerRequest", + "SuspendInstancesRegionInstanceGroupManagerRequest", "SwitchToCustomModeNetworkRequest", "Tags", "TargetGrpcProxy", diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py b/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py index eb2b750cbbe2..70daefa6ed54 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py @@ -434,6 +434,7 @@ "GetNetworkEdgeSecurityServiceRequest", "GetNetworkEndpointGroupRequest", "GetNetworkFirewallPolicyRequest", + "GetNetworkProfileRequest", "GetNetworkRequest", "GetNodeGroupRequest", "GetNodeTemplateRequest", @@ -642,6 +643,7 @@ "InstanceGroupManagerResizeRequestStatus", "InstanceGroupManagerResizeRequestStatusLastAttempt", "InstanceGroupManagerResizeRequestsListResponse", + "InstanceGroupManagerStandbyPolicy", "InstanceGroupManagerStatus", "InstanceGroupManagerStatusAllInstancesConfig", "InstanceGroupManagerStatusStateful", @@ -659,9 +661,13 @@ "InstanceGroupManagersListPerInstanceConfigsResp", "InstanceGroupManagersPatchPerInstanceConfigsReq", "InstanceGroupManagersRecreateInstancesRequest", + "InstanceGroupManagersResumeInstancesRequest", "InstanceGroupManagersScopedList", "InstanceGroupManagersSetInstanceTemplateRequest", "InstanceGroupManagersSetTargetPoolsRequest", + "InstanceGroupManagersStartInstancesRequest", + "InstanceGroupManagersStopInstancesRequest", + "InstanceGroupManagersSuspendInstancesRequest", "InstanceGroupManagersUpdatePerInstanceConfigsReq", "InstanceGroupsAddInstancesRequest", "InstanceGroupsListInstances", @@ -794,6 +800,7 @@ "ListNetworkEndpointsNetworkEndpointGroupsRequest", "ListNetworkEndpointsRegionNetworkEndpointGroupsRequest", "ListNetworkFirewallPoliciesRequest", + "ListNetworkProfilesRequest", "ListNetworksRequest", "ListNodeGroupsRequest", "ListNodeTemplatesRequest", @@ -915,6 +922,10 @@ "NetworkList", "NetworkPeering", "NetworkPerformanceConfig", + "NetworkProfile", + "NetworkProfileLocation", + "NetworkProfileNetworkFeatures", + "NetworkProfilesListResponse", "NetworkRoutingConfig", "NetworksAddPeeringRequest", "NetworksGetEffectiveFirewallsResponse", @@ -1067,8 +1078,12 @@ "RegionInstanceGroupManagersListInstanceConfigsResp", "RegionInstanceGroupManagersListInstancesResponse", "RegionInstanceGroupManagersRecreateRequest", + "RegionInstanceGroupManagersResumeInstancesRequest", "RegionInstanceGroupManagersSetTargetPoolsRequest", "RegionInstanceGroupManagersSetTemplateRequest", + "RegionInstanceGroupManagersStartInstancesRequest", + "RegionInstanceGroupManagersStopInstancesRequest", + "RegionInstanceGroupManagersSuspendInstancesRequest", "RegionInstanceGroupsListInstances", "RegionInstanceGroupsListInstancesRequest", "RegionInstanceGroupsSetNamedPortsRequest", @@ -1132,6 +1147,8 @@ "ResourceStatus", "ResourceStatusScheduling", "ResumeInstanceRequest", + "ResumeInstancesInstanceGroupManagerRequest", + "ResumeInstancesRegionInstanceGroupManagerRequest", "Route", "RouteAsPath", "RouteList", @@ -1263,6 +1280,7 @@ "SetLabelsInterconnectRequest", "SetLabelsRegionDiskRequest", "SetLabelsRegionInstantSnapshotRequest", + "SetLabelsRegionSecurityPolicyRequest", "SetLabelsSecurityPolicyRequest", "SetLabelsSnapshotRequest", "SetLabelsTargetVpnGatewayRequest", @@ -1335,6 +1353,8 @@ "StartAsyncReplicationDiskRequest", "StartAsyncReplicationRegionDiskRequest", "StartInstanceRequest", + "StartInstancesInstanceGroupManagerRequest", + "StartInstancesRegionInstanceGroupManagerRequest", "StartWithEncryptionKeyInstanceRequest", "StatefulPolicy", "StatefulPolicyPreservedState", @@ -1346,6 +1366,8 @@ "StopGroupAsyncReplicationDiskRequest", "StopGroupAsyncReplicationRegionDiskRequest", "StopInstanceRequest", + "StopInstancesInstanceGroupManagerRequest", + "StopInstancesRegionInstanceGroupManagerRequest", "StoragePool", "StoragePoolAggregatedList", "StoragePoolDisk", @@ -1367,6 +1389,8 @@ "SubnetworksSetPrivateIpGoogleAccessRequest", "Subsetting", "SuspendInstanceRequest", + "SuspendInstancesInstanceGroupManagerRequest", + "SuspendInstancesRegionInstanceGroupManagerRequest", "SwitchToCustomModeNetworkRequest", "TCPHealthCheck", "Tags", @@ -14226,8 +14250,9 @@ class BackendBucketCdnPolicy(proto.Message): formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), - will not be cached. Check the CacheMode enum for the list of - possible values. + will not be cached. If no value is provided for + cdnPolicy.cacheMode, it defaults to CACHE_ALL_STATIC. Check + the CacheMode enum for the list of possible values. This field is a member of `oneof`_ ``_cache_mode``. client_ttl (int): @@ -14356,7 +14381,8 @@ class CacheMode(proto.Enum): cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content - (including HTML), will not be cached. + (including HTML), will not be cached. If no value is provided for + cdnPolicy.cacheMode, it defaults to CACHE_ALL_STATIC. Values: UNDEFINED_CACHE_MODE (0): @@ -15732,8 +15758,9 @@ class BackendServiceCdnPolicy(proto.Message): formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content (including HTML), - will not be cached. Check the CacheMode enum for the list of - possible values. + will not be cached. If no value is provided for + cdnPolicy.cacheMode, it defaults to CACHE_ALL_STATIC. Check + the CacheMode enum for the list of possible values. This field is a member of `oneof`_ ``_cache_mode``. client_ttl (int): @@ -15862,7 +15889,8 @@ class CacheMode(proto.Enum): cache static content, including common image formats, media (video and audio), and web assets (JavaScript and CSS). Requests and responses that are marked as uncacheable, as well as dynamic content - (including HTML), will not be cached. + (including HTML), will not be cached. If no value is provided for + cdnPolicy.cacheMode, it defaults to CACHE_ALL_STATIC. Values: UNDEFINED_CACHE_MODE (0): @@ -18661,6 +18689,12 @@ class Type(proto.Enum): No description available. MEMORY_OPTIMIZED_M3 (276301372): No description available. + MEMORY_OPTIMIZED_X4_16TB (183089120): + No description available. + MEMORY_OPTIMIZED_X4_24TB (183116989): + No description available. + MEMORY_OPTIMIZED_X4_32TB (183144858): + No description available. STORAGE_OPTIMIZED_Z3 (316796085): No description available. TYPE_UNSPECIFIED (437714322): @@ -18686,6 +18720,9 @@ class Type(proto.Enum): GRAPHICS_OPTIMIZED = 68500563 MEMORY_OPTIMIZED = 281753417 MEMORY_OPTIMIZED_M3 = 276301372 + MEMORY_OPTIMIZED_X4_16TB = 183089120 + MEMORY_OPTIMIZED_X4_24TB = 183116989 + MEMORY_OPTIMIZED_X4_32TB = 183144858 STORAGE_OPTIMIZED_Z3 = 316796085 TYPE_UNSPECIFIED = 437714322 @@ -32253,6 +32290,27 @@ class GetNetworkFirewallPolicyRequest(proto.Message): ) +class GetNetworkProfileRequest(proto.Message): + r"""A request message for NetworkProfiles.Get. See the method + description for details. + + Attributes: + network_profile (str): + Name of the network profile to return. + project (str): + Project ID for this request. + """ + + network_profile: str = proto.Field( + proto.STRING, + number=173112472, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + + class GetNetworkRequest(proto.Message): r"""A request message for Networks.Get. See the method description for details. @@ -33470,7 +33528,10 @@ class GetSerialPortOutputInstanceRequest(proto.Message): can also provide a negative start position, which translates to the most recent number of bytes written to the serial port. For example, -3 is interpreted as the most recent 3 - bytes written to the serial console. + bytes written to the serial console. Note that the negative + start is bounded by the retained buffer size, and the + returned serial console output will not exceed the max + buffer size. This field is a member of `oneof`_ ``_start``. zone (str): @@ -37198,12 +37259,8 @@ class HttpRouteRule(proto.Message): balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected - backend. If routeAction specifies any - weightedBackendServices, service must not be - set. Conversely if service is set, routeAction - cannot contain any weightedBackendServices. Only - one of urlRedirect, service or - routeAction.weightedBackendService must be set. + backend. Only one of urlRedirect, service or + routeAction.weightedBackendService can be set. URL maps for classic Application Load Balancers only support the urlRewrite action within a route rule's routeAction. @@ -37215,21 +37272,18 @@ class HttpRouteRule(proto.Message): this rule is matched. If routeAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request - to the backend. However, if service is - specified, routeAction cannot contain any - weightedBackendServices. Conversely, if - routeAction specifies any - weightedBackendServices, service must not be - specified. Only one of urlRedirect, service or - routeAction.weightedBackendService must be set. + to the backend. Only one of urlRedirect, service + or routeAction.weightedBackendService can be + set. This field is a member of `oneof`_ ``_service``. url_redirect (google.cloud.compute_v1.types.HttpRedirectAction): When this rule is matched, the request is - redirected to a URL specified by urlRedirect. If - urlRedirect is specified, service or routeAction - must not be set. Not supported when the URL map - is bound to a target gRPC proxy. + redirected to a URL specified by urlRedirect. + Only one of urlRedirect, service or + routeAction.weightedBackendService can be set. + Not supported when the URL map is bound to a + target gRPC proxy. This field is a member of `oneof`_ ``_url_redirect``. """ @@ -43338,6 +43392,11 @@ class InstanceGroupManager(proto.Message): server defines this URL. This field is a member of `oneof`_ ``_self_link``. + standby_policy (google.cloud.compute_v1.types.InstanceGroupManagerStandbyPolicy): + Standby policy for stopped and suspended + instances. + + This field is a member of `oneof`_ ``_standby_policy``. stateful_policy (google.cloud.compute_v1.types.StatefulPolicy): Stateful configuration for this Instanced Group Manager @@ -43361,6 +43420,25 @@ class InstanceGroupManager(proto.Message): Resizing the group also changes this number. This field is a member of `oneof`_ ``_target_size``. + target_stopped_size (int): + The target number of stopped instances for + this managed instance group. This number changes + when you: - Stop instance using the + stopInstances method or start instances using + the startInstances method. - Manually change the + targetStoppedSize using the update method. + + This field is a member of `oneof`_ ``_target_stopped_size``. + target_suspended_size (int): + The target number of suspended instances for + this managed instance group. This number changes + when you: - Suspend instance using the + suspendInstances method or resume instances + using the resumeInstances method. - Manually + change the targetSuspendedSize using the update + method. + + This field is a member of `oneof`_ ``_target_suspended_size``. update_policy (google.cloud.compute_v1.types.InstanceGroupManagerUpdatePolicy): The update policy for this managed instance group. @@ -43524,6 +43602,12 @@ class ListManagedInstancesResults(proto.Enum): number=456214797, optional=True, ) + standby_policy: "InstanceGroupManagerStandbyPolicy" = proto.Field( + proto.MESSAGE, + number=499352324, + optional=True, + message="InstanceGroupManagerStandbyPolicy", + ) stateful_policy: "StatefulPolicy" = proto.Field( proto.MESSAGE, number=47538565, @@ -43545,6 +43629,16 @@ class ListManagedInstancesResults(proto.Enum): number=62880239, optional=True, ) + target_stopped_size: int = proto.Field( + proto.INT32, + number=2419489, + optional=True, + ) + target_suspended_size: int = proto.Field( + proto.INT32, + number=308085843, + optional=True, + ) update_policy: "InstanceGroupManagerUpdatePolicy" = proto.Field( proto.MESSAGE, number=175809896, @@ -44412,6 +44506,63 @@ def raw_page(self): ) +class InstanceGroupManagerStandbyPolicy(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + initial_delay_sec (int): + Specifies the number of seconds that the MIG + should wait to suspend or stop a VM after that + VM was created. The initial delay gives the + initialization script the time to prepare your + VM for a quick scale out. The value of initial + delay must be between 0 and 3600 seconds. The + default value is 0. + + This field is a member of `oneof`_ ``_initial_delay_sec``. + mode (str): + Defines how a MIG resumes or starts VMs from a standby pool + when the group scales out. The default mode is ``MANUAL``. + Check the Mode enum for the list of possible values. + + This field is a member of `oneof`_ ``_mode``. + """ + + class Mode(proto.Enum): + r"""Defines how a MIG resumes or starts VMs from a standby pool when the + group scales out. The default mode is ``MANUAL``. + + Values: + UNDEFINED_MODE (0): + A value indicating that the enum field is not + set. + MANUAL (119397318): + MIG does not automatically resume or start + VMs in the standby pool when the group scales + out. + SCALE_OUT_POOL (635394): + MIG automatically resumes or starts VMs in + the standby pool when the group scales out, and + replenishes the standby pool afterwards. + """ + UNDEFINED_MODE = 0 + MANUAL = 119397318 + SCALE_OUT_POOL = 635394 + + initial_delay_sec: int = proto.Field( + proto.INT32, + number=263207002, + optional=True, + ) + mode: str = proto.Field( + proto.STRING, + number=3357091, + optional=True, + ) + + class InstanceGroupManagerStatus(proto.Message): r""" @@ -45260,6 +45411,22 @@ class InstanceGroupManagersRecreateInstancesRequest(proto.Message): ) +class InstanceGroupManagersResumeInstancesRequest(proto.Message): + r""" + + Attributes: + instances (MutableSequence[str]): + The URLs of one or more instances to resume. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + class InstanceGroupManagersScopedList(proto.Message): r""" @@ -45355,6 +45522,80 @@ class InstanceGroupManagersSetTargetPoolsRequest(proto.Message): ) +class InstanceGroupManagersStartInstancesRequest(proto.Message): + r""" + + Attributes: + instances (MutableSequence[str]): + The URLs of one or more instances to start. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + +class InstanceGroupManagersStopInstancesRequest(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + force_stop (bool): + If this flag is set to true, the Instance + Group Manager will proceed to stop the + instances, skipping initialization on them. + + This field is a member of `oneof`_ ``_force_stop``. + instances (MutableSequence[str]): + The URLs of one or more instances to stop. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + force_stop: bool = proto.Field( + proto.BOOL, + number=134762710, + optional=True, + ) + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + +class InstanceGroupManagersSuspendInstancesRequest(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + force_suspend (bool): + If this flag is set to true, the Instance + Group Manager will proceed to suspend the + instances, skipping initialization on them. + + This field is a member of `oneof`_ ``_force_suspend``. + instances (MutableSequence[str]): + The URLs of one or more instances to suspend. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + force_suspend: bool = proto.Field( + proto.BOOL, + number=27637480, + optional=True, + ) + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + class InstanceGroupManagersUpdatePerInstanceConfigsReq(proto.Message): r"""InstanceGroupManagers.updatePerInstanceConfigs @@ -49996,7 +50237,7 @@ class InterconnectLocation(proto.Message): available_features (MutableSequence[str]): [Output only] List of features available at this InterconnectLocation, which can take one of the following - values: - MACSEC Check the AvailableFeatures enum for the + values: - IF_MACSEC Check the AvailableFeatures enum for the list of possible values. available_link_types (MutableSequence[str]): [Output only] List of link types available at this @@ -51499,6 +51740,7 @@ class License(proto.Message): This field is a member of `oneof`_ ``_name``. resource_requirements (google.cloud.compute_v1.types.LicenseResourceRequirements): + [Input Only] Deprecated. This field is a member of `oneof`_ ``_resource_requirements``. self_link (str): @@ -51770,15 +52012,13 @@ class LicenseResourceRequirements(proto.Message): Attributes: min_guest_cpu_count (int): - Minimum number of guest cpus required to use - the Instance. Enforced at Instance creation and - Instance start. + [Input Only] Deprecated. This field no longer reflects the + minimum number of guest cpus required to use the Instance. This field is a member of `oneof`_ ``_min_guest_cpu_count``. min_memory_mb (int): - Minimum memory required to use the Instance. - Enforced at Instance creation and Instance - start. + [Input Only] Deprecated. This field no longer reflects the + minimum memory required to use the Instance. This field is a member of `oneof`_ ``_min_memory_mb``. """ @@ -58042,6 +58282,131 @@ class ListNetworkFirewallPoliciesRequest(proto.Message): ) +class ListNetworkProfilesRequest(proto.Message): + r"""A request message for NetworkProfiles.List. See the method + description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + filter (str): + A filter expression that filters resources listed in the + response. Most Compute resources support two types of filter + expressions: expressions that support regular expressions + and expressions that follow API improvement proposal + AIP-160. These two types of filter expressions cannot be + mixed in one request. If you want to use AIP-160, your + expression must specify the field name, an operator, and the + value that you want to use for filtering. The value must be + a string, a number, or a boolean. The operator must be + either ``=``, ``!=``, ``>``, ``<``, ``<=``, ``>=`` or ``:``. + For example, if you are filtering Compute Engine instances, + you can exclude instances named ``example-instance`` by + specifying ``name != example-instance``. The ``:*`` + comparison can be used to test whether a key has been + defined. For example, to find all objects with ``owner`` + label use: ``labels.owner:*`` You can also filter nested + fields. For example, you could specify + ``scheduling.automaticRestart = false`` to include instances + only if they are not scheduled for automatic restarts. You + can use filtering on nested fields to filter based on + resource labels. To filter on multiple expressions, provide + each separate expression within parentheses. For example: + ``(scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake")`` + By default, each expression is an ``AND`` expression. + However, you can include ``AND`` and ``OR`` expressions + explicitly. For example: + ``(cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)`` + If you want to use a regular expression, use the ``eq`` + (equal) or ``ne`` (not equal) operator against a single + un-parenthesized expression with or without quotes or + against multiple parenthesized expressions. Examples: + ``fieldname eq unquoted literal`` + ``fieldname eq 'single quoted literal'`` + ``fieldname eq "double quoted literal"`` + ``(fieldname1 eq literal) (fieldname2 ne "literal")`` The + literal value is interpreted as a regular expression using + Google RE2 library syntax. The literal value must match the + entire field. For example, to filter for instances that do + not end with name "instance", you would use + ``name ne .*instance``. You cannot combine constraints on + multiple fields using regular expressions. + + This field is a member of `oneof`_ ``_filter``. + max_results (int): + The maximum number of results per page that should be + returned. If the number of available results is larger than + ``maxResults``, Compute Engine returns a ``nextPageToken`` + that can be used to get the next page of results in + subsequent list requests. Acceptable values are ``0`` to + ``500``, inclusive. (Default: ``500``) + + This field is a member of `oneof`_ ``_max_results``. + order_by (str): + Sorts list results by a certain order. By default, results + are returned in alphanumerical order based on the resource + name. You can also sort results in descending order based on + the creation timestamp using + ``orderBy="creationTimestamp desc"``. This sorts results + based on the ``creationTimestamp`` field in reverse + chronological order (newest result first). Use this to sort + resources like operations so that the newest operation is + returned first. Currently, only sorting by ``name`` or + ``creationTimestamp desc`` is supported. + + This field is a member of `oneof`_ ``_order_by``. + page_token (str): + Specifies a page token to use. Set ``pageToken`` to the + ``nextPageToken`` returned by a previous list request to get + the next page of results. + + This field is a member of `oneof`_ ``_page_token``. + project (str): + Project ID for this request. + return_partial_success (bool): + Opt-in for partial success behavior which + provides partial results in case of failure. The + default value is false. For example, when + partial success behavior is enabled, + aggregatedList for a single zone scope either + returns all resources in the zone or no + resources, with an error code. + + This field is a member of `oneof`_ ``_return_partial_success``. + """ + + filter: str = proto.Field( + proto.STRING, + number=336120696, + optional=True, + ) + max_results: int = proto.Field( + proto.UINT32, + number=54715419, + optional=True, + ) + order_by: str = proto.Field( + proto.STRING, + number=160562920, + optional=True, + ) + page_token: str = proto.Field( + proto.STRING, + number=19994697, + optional=True, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + return_partial_success: bool = proto.Field( + proto.BOOL, + number=517198390, + optional=True, + ) + + class ListNetworksRequest(proto.Message): r"""A request message for Networks.List. See the method description for details. @@ -68700,6 +69065,15 @@ class Network(proto.Message): list of possible values. This field is a member of `oneof`_ ``_network_firewall_policy_enforcement_order``. + network_profile (str): + A full or partial URL of the network profile to apply to + this network. This field can be set only at resource + creation time. For example, the following are valid URLs: - + https://www.googleapis.com/compute/{api_version}/projects/{project_id}/global/networkProfiles/{network_profile_name} + - + projects/{project_id}/global/networkProfiles/{network_profile_name} + + This field is a member of `oneof`_ ``_network_profile``. peerings (MutableSequence[google.cloud.compute_v1.types.NetworkPeering]): [Output Only] A list of network peerings for the resource. routing_config (google.cloud.compute_v1.types.NetworkRoutingConfig): @@ -68806,6 +69180,11 @@ class NetworkFirewallPolicyEnforcementOrder(proto.Enum): number=6504784, optional=True, ) + network_profile: str = proto.Field( + proto.STRING, + number=173112472, + optional=True, + ) peerings: MutableSequence["NetworkPeering"] = proto.RepeatedField( proto.MESSAGE, number=69883187, @@ -70720,6 +71099,10 @@ class NicType(proto.Enum): GVNIC IDPF (2242641): IDPF + IRDMA (69927695): + IRDMA + MRDMA (73621779): + MRDMA UNSPECIFIED_NIC_TYPE (67411801): No type specified. VIRTIO_NET (452123481): @@ -70728,6 +71111,8 @@ class NicType(proto.Enum): UNDEFINED_NIC_TYPE = 0 GVNIC = 68209305 IDPF = 2242641 + IRDMA = 69927695 + MRDMA = 73621779 UNSPECIFIED_NIC_TYPE = 67411801 VIRTIO_NET = 452123481 @@ -71154,6 +71539,899 @@ class TotalEgressBandwidthTier(proto.Enum): ) +class NetworkProfile(proto.Message): + r"""NetworkProfile represents a Google managed network profile + resource. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + creation_timestamp (str): + [Output Only] Creation timestamp in RFC3339 text format. + + This field is a member of `oneof`_ ``_creation_timestamp``. + description (str): + [Output Only] An optional description of this resource. + + This field is a member of `oneof`_ ``_description``. + features (google.cloud.compute_v1.types.NetworkProfileNetworkFeatures): + [Output Only] Features supported by the network. + + This field is a member of `oneof`_ ``_features``. + id (int): + [Output Only] The unique identifier for the resource. This + identifier is defined by the server. + + This field is a member of `oneof`_ ``_id``. + kind (str): + [Output Only] Type of the resource. Always + compute#networkProfile for network profiles. + + This field is a member of `oneof`_ ``_kind``. + location (google.cloud.compute_v1.types.NetworkProfileLocation): + [Output Only] Location to which the network is restricted. + + This field is a member of `oneof`_ ``_location``. + name (str): + [Output Only] Name of the resource. + + This field is a member of `oneof`_ ``_name``. + self_link (str): + [Output Only] Server-defined URL for the resource. + + This field is a member of `oneof`_ ``_self_link``. + self_link_with_id (str): + [Output Only] Server-defined URL for this resource with the + resource id. + + This field is a member of `oneof`_ ``_self_link_with_id``. + zone (str): + [Output Only] Zone to which the network is restricted. + + This field is a member of `oneof`_ ``_zone``. + """ + + creation_timestamp: str = proto.Field( + proto.STRING, + number=30525366, + optional=True, + ) + description: str = proto.Field( + proto.STRING, + number=422937596, + optional=True, + ) + features: "NetworkProfileNetworkFeatures" = proto.Field( + proto.MESSAGE, + number=246211645, + optional=True, + message="NetworkProfileNetworkFeatures", + ) + id: int = proto.Field( + proto.UINT64, + number=3355, + optional=True, + ) + kind: str = proto.Field( + proto.STRING, + number=3292052, + optional=True, + ) + location: "NetworkProfileLocation" = proto.Field( + proto.MESSAGE, + number=290430901, + optional=True, + message="NetworkProfileLocation", + ) + name: str = proto.Field( + proto.STRING, + number=3373707, + optional=True, + ) + self_link: str = proto.Field( + proto.STRING, + number=456214797, + optional=True, + ) + self_link_with_id: str = proto.Field( + proto.STRING, + number=44520962, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + optional=True, + ) + + +class NetworkProfileLocation(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + + This field is a member of `oneof`_ ``_name``. + scope (str): + Check the Scope enum for the list of possible + values. + + This field is a member of `oneof`_ ``_scope``. + """ + + class Scope(proto.Enum): + r""" + + Values: + UNDEFINED_SCOPE (0): + A value indicating that the enum field is not + set. + REGION (266017524): + No description available. + ZONE (2759596): + No description available. + """ + UNDEFINED_SCOPE = 0 + REGION = 266017524 + ZONE = 2759596 + + name: str = proto.Field( + proto.STRING, + number=3373707, + optional=True, + ) + scope: str = proto.Field( + proto.STRING, + number=109264468, + optional=True, + ) + + +class NetworkProfileNetworkFeatures(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + address_purposes (MutableSequence[str]): + Specifies what address purposes are + supported. If empty, all address purposes are + supported. Check the AddressPurposes enum for + the list of possible values. + allow_alias_ip_ranges (str): + Specifies whether alias IP ranges (and + secondary address ranges) are allowed. Check the + AllowAliasIpRanges enum for the list of possible + values. + + This field is a member of `oneof`_ ``_allow_alias_ip_ranges``. + allow_auto_mode_subnet (str): + Specifies whether auto mode subnet creation + is allowed. Check the AllowAutoModeSubnet enum + for the list of possible values. + + This field is a member of `oneof`_ ``_allow_auto_mode_subnet``. + allow_class_d_firewalls (str): + Specifies whether firewalls for Class D + address ranges are supported. Check the + AllowClassDFirewalls enum for the list of + possible values. + + This field is a member of `oneof`_ ``_allow_class_d_firewalls``. + allow_cloud_nat (str): + Specifies whether cloud NAT creation is + allowed. Check the AllowCloudNat enum for the + list of possible values. + + This field is a member of `oneof`_ ``_allow_cloud_nat``. + allow_cloud_router (str): + Specifies whether cloud router creation is + allowed. Check the AllowCloudRouter enum for the + list of possible values. + + This field is a member of `oneof`_ ``_allow_cloud_router``. + allow_external_ip_access (str): + Specifies whether VMs are allowed to have + external IP access on network interfaces + connected to this VPC. Check the + AllowExternalIpAccess enum for the list of + possible values. + + This field is a member of `oneof`_ ``_allow_external_ip_access``. + allow_interconnect (str): + Specifies whether Cloud Interconnect creation + is allowed. Check the AllowInterconnect enum for + the list of possible values. + + This field is a member of `oneof`_ ``_allow_interconnect``. + allow_load_balancing (str): + Specifies whether cloud load balancing is + allowed. Check the AllowLoadBalancing enum for + the list of possible values. + + This field is a member of `oneof`_ ``_allow_load_balancing``. + allow_multi_nic_in_same_network (str): + Specifies whether multi-nic in the same + network is allowed. Check the + AllowMultiNicInSameNetwork enum for the list of + possible values. + + This field is a member of `oneof`_ ``_allow_multi_nic_in_same_network``. + allow_packet_mirroring (str): + Specifies whether Packet Mirroring 1.0 is + supported. Check the AllowPacketMirroring enum + for the list of possible values. + + This field is a member of `oneof`_ ``_allow_packet_mirroring``. + allow_private_google_access (str): + Specifies whether private Google access is + allowed. Check the AllowPrivateGoogleAccess enum + for the list of possible values. + + This field is a member of `oneof`_ ``_allow_private_google_access``. + allow_psc (str): + Specifies whether PSC creation is allowed. + Check the AllowPsc enum for the list of possible + values. + + This field is a member of `oneof`_ ``_allow_psc``. + allow_same_network_unicast (str): + Specifies whether unicast within the same + network is allowed. Check the + AllowSameNetworkUnicast enum for the list of + possible values. + + This field is a member of `oneof`_ ``_allow_same_network_unicast``. + allow_static_routes (str): + Specifies whether static route creation is + allowed. Check the AllowStaticRoutes enum for + the list of possible values. + + This field is a member of `oneof`_ ``_allow_static_routes``. + allow_sub_interfaces (str): + Specifies whether sub interfaces are allowed. + Check the AllowSubInterfaces enum for the list + of possible values. + + This field is a member of `oneof`_ ``_allow_sub_interfaces``. + allow_vpc_peering (str): + Specifies whether VPC peering is allowed. + Check the AllowVpcPeering enum for the list of + possible values. + + This field is a member of `oneof`_ ``_allow_vpc_peering``. + allow_vpn (str): + Specifies whether VPN creation is allowed. + Check the AllowVpn enum for the list of possible + values. + + This field is a member of `oneof`_ ``_allow_vpn``. + interface_types (MutableSequence[str]): + If set, limits the interface types that the + network supports. If empty, all interface types + are supported. Check the InterfaceTypes enum for + the list of possible values. + subnet_purposes (MutableSequence[str]): + Specifies which subnetwork purposes are + supported. Check the SubnetPurposes enum for the + list of possible values. + subnet_stack_types (MutableSequence[str]): + Specifies which subnetwork stack types are + supported. Check the SubnetStackTypes enum for + the list of possible values. + unicast (str): + Specifies which type of unicast is supported. + Check the Unicast enum for the list of possible + values. + + This field is a member of `oneof`_ ``_unicast``. + """ + + class AddressPurposes(proto.Enum): + r""" + + Values: + UNDEFINED_ADDRESS_PURPOSES (0): + A value indicating that the enum field is not + set. + DNS_RESOLVER (476114556): + DNS resolver address in the subnetwork. + GCE_ENDPOINT (230515243): + VM internal/alias IP, Internal LB service IP, + etc. + IPSEC_INTERCONNECT (340437251): + A regional internal IP address range reserved + for the VLAN attachment that is used in HA VPN + over Cloud Interconnect. This regional internal + IP address range must not overlap with any IP + address range of subnet/route in the VPC network + and its peering networks. After the VLAN + attachment is created with the reserved IP + address range, when creating a new VPN gateway, + its interface IP address is allocated from the + associated VLAN attachment’s IP address range. + NAT_AUTO (163666477): + External IP automatically reserved for Cloud + NAT. + PRIVATE_SERVICE_CONNECT (48134724): + A private network IP address that can be used + to configure Private Service Connect. This + purpose can be specified only for GLOBAL + addresses of Type INTERNAL + SERVERLESS (270492508): + A regional internal IP address range reserved + for Serverless. + SHARED_LOADBALANCER_VIP (294447572): + A private network IP address that can be + shared by multiple Internal Load Balancer + forwarding rules. + VPC_PEERING (400800170): + IP range for peer networks. + """ + UNDEFINED_ADDRESS_PURPOSES = 0 + DNS_RESOLVER = 476114556 + GCE_ENDPOINT = 230515243 + IPSEC_INTERCONNECT = 340437251 + NAT_AUTO = 163666477 + PRIVATE_SERVICE_CONNECT = 48134724 + SERVERLESS = 270492508 + SHARED_LOADBALANCER_VIP = 294447572 + VPC_PEERING = 400800170 + + class AllowAliasIpRanges(proto.Enum): + r"""Specifies whether alias IP ranges (and secondary address + ranges) are allowed. + + Values: + UNDEFINED_ALLOW_ALIAS_IP_RANGES (0): + A value indicating that the enum field is not + set. + ALIAS_IP_RANGES_ALLOWED (464867048): + No description available. + ALIAS_IP_RANGES_BLOCKED (281030444): + No description available. + """ + UNDEFINED_ALLOW_ALIAS_IP_RANGES = 0 + ALIAS_IP_RANGES_ALLOWED = 464867048 + ALIAS_IP_RANGES_BLOCKED = 281030444 + + class AllowAutoModeSubnet(proto.Enum): + r"""Specifies whether auto mode subnet creation is allowed. + + Values: + UNDEFINED_ALLOW_AUTO_MODE_SUBNET (0): + A value indicating that the enum field is not + set. + AUTO_MODE_SUBNET_ALLOWED (391042610): + No description available. + AUTO_MODE_SUBNET_BLOCKED (207206006): + No description available. + """ + UNDEFINED_ALLOW_AUTO_MODE_SUBNET = 0 + AUTO_MODE_SUBNET_ALLOWED = 391042610 + AUTO_MODE_SUBNET_BLOCKED = 207206006 + + class AllowClassDFirewalls(proto.Enum): + r"""Specifies whether firewalls for Class D address ranges are + supported. + + Values: + UNDEFINED_ALLOW_CLASS_D_FIREWALLS (0): + A value indicating that the enum field is not + set. + CLASS_D_FIREWALLS_ALLOWED (348219386): + No description available. + CLASS_D_FIREWALLS_BLOCKED (164382782): + No description available. + """ + UNDEFINED_ALLOW_CLASS_D_FIREWALLS = 0 + CLASS_D_FIREWALLS_ALLOWED = 348219386 + CLASS_D_FIREWALLS_BLOCKED = 164382782 + + class AllowCloudNat(proto.Enum): + r"""Specifies whether cloud NAT creation is allowed. + + Values: + UNDEFINED_ALLOW_CLOUD_NAT (0): + A value indicating that the enum field is not + set. + CLOUD_NAT_ALLOWED (245931296): + No description available. + CLOUD_NAT_BLOCKED (62094692): + No description available. + """ + UNDEFINED_ALLOW_CLOUD_NAT = 0 + CLOUD_NAT_ALLOWED = 245931296 + CLOUD_NAT_BLOCKED = 62094692 + + class AllowCloudRouter(proto.Enum): + r"""Specifies whether cloud router creation is allowed. + + Values: + UNDEFINED_ALLOW_CLOUD_ROUTER (0): + A value indicating that the enum field is not + set. + CLOUD_ROUTER_ALLOWED (365388284): + No description available. + CLOUD_ROUTER_BLOCKED (181551680): + No description available. + """ + UNDEFINED_ALLOW_CLOUD_ROUTER = 0 + CLOUD_ROUTER_ALLOWED = 365388284 + CLOUD_ROUTER_BLOCKED = 181551680 + + class AllowExternalIpAccess(proto.Enum): + r"""Specifies whether VMs are allowed to have external IP access + on network interfaces connected to this VPC. + + Values: + UNDEFINED_ALLOW_EXTERNAL_IP_ACCESS (0): + A value indicating that the enum field is not + set. + EXTERNAL_IP_ACCESS_ALLOWED (109530193): + No description available. + EXTERNAL_IP_ACCESS_BLOCKED (462564501): + No description available. + """ + UNDEFINED_ALLOW_EXTERNAL_IP_ACCESS = 0 + EXTERNAL_IP_ACCESS_ALLOWED = 109530193 + EXTERNAL_IP_ACCESS_BLOCKED = 462564501 + + class AllowInterconnect(proto.Enum): + r"""Specifies whether Cloud Interconnect creation is allowed. + + Values: + UNDEFINED_ALLOW_INTERCONNECT (0): + A value indicating that the enum field is not + set. + INTERCONNECT_ALLOWED (162845399): + No description available. + INTERCONNECT_BLOCKED (515879707): + No description available. + """ + UNDEFINED_ALLOW_INTERCONNECT = 0 + INTERCONNECT_ALLOWED = 162845399 + INTERCONNECT_BLOCKED = 515879707 + + class AllowLoadBalancing(proto.Enum): + r"""Specifies whether cloud load balancing is allowed. + + Values: + UNDEFINED_ALLOW_LOAD_BALANCING (0): + A value indicating that the enum field is not + set. + LOAD_BALANCING_ALLOWED (28407977): + No description available. + LOAD_BALANCING_BLOCKED (381442285): + No description available. + """ + UNDEFINED_ALLOW_LOAD_BALANCING = 0 + LOAD_BALANCING_ALLOWED = 28407977 + LOAD_BALANCING_BLOCKED = 381442285 + + class AllowMultiNicInSameNetwork(proto.Enum): + r"""Specifies whether multi-nic in the same network is allowed. + + Values: + UNDEFINED_ALLOW_MULTI_NIC_IN_SAME_NETWORK (0): + A value indicating that the enum field is not + set. + MULTI_NIC_IN_SAME_NETWORK_ALLOWED (457555419): + No description available. + MULTI_NIC_IN_SAME_NETWORK_BLOCKED (273718815): + No description available. + """ + UNDEFINED_ALLOW_MULTI_NIC_IN_SAME_NETWORK = 0 + MULTI_NIC_IN_SAME_NETWORK_ALLOWED = 457555419 + MULTI_NIC_IN_SAME_NETWORK_BLOCKED = 273718815 + + class AllowPacketMirroring(proto.Enum): + r"""Specifies whether Packet Mirroring 1.0 is supported. + + Values: + UNDEFINED_ALLOW_PACKET_MIRRORING (0): + A value indicating that the enum field is not + set. + PACKET_MIRRORING_ALLOWED (92416245): + No description available. + PACKET_MIRRORING_BLOCKED (445450553): + No description available. + """ + UNDEFINED_ALLOW_PACKET_MIRRORING = 0 + PACKET_MIRRORING_ALLOWED = 92416245 + PACKET_MIRRORING_BLOCKED = 445450553 + + class AllowPrivateGoogleAccess(proto.Enum): + r"""Specifies whether private Google access is allowed. + + Values: + UNDEFINED_ALLOW_PRIVATE_GOOGLE_ACCESS (0): + A value indicating that the enum field is not + set. + PRIVATE_GOOGLE_ACCESS_ALLOWED (220787351): + No description available. + PRIVATE_GOOGLE_ACCESS_BLOCKED (36950747): + No description available. + """ + UNDEFINED_ALLOW_PRIVATE_GOOGLE_ACCESS = 0 + PRIVATE_GOOGLE_ACCESS_ALLOWED = 220787351 + PRIVATE_GOOGLE_ACCESS_BLOCKED = 36950747 + + class AllowPsc(proto.Enum): + r"""Specifies whether PSC creation is allowed. + + Values: + UNDEFINED_ALLOW_PSC (0): + A value indicating that the enum field is not + set. + PSC_ALLOWED (171559657): + No description available. + PSC_BLOCKED (524593965): + No description available. + """ + UNDEFINED_ALLOW_PSC = 0 + PSC_ALLOWED = 171559657 + PSC_BLOCKED = 524593965 + + class AllowSameNetworkUnicast(proto.Enum): + r"""Specifies whether unicast within the same network is allowed. + + Values: + UNDEFINED_ALLOW_SAME_NETWORK_UNICAST (0): + A value indicating that the enum field is not + set. + SAME_NETWORK_UNICAST_ALLOWED (159732814): + No description available. + SAME_NETWORK_UNICAST_BLOCKED (512767122): + No description available. + """ + UNDEFINED_ALLOW_SAME_NETWORK_UNICAST = 0 + SAME_NETWORK_UNICAST_ALLOWED = 159732814 + SAME_NETWORK_UNICAST_BLOCKED = 512767122 + + class AllowStaticRoutes(proto.Enum): + r"""Specifies whether static route creation is allowed. + + Values: + UNDEFINED_ALLOW_STATIC_ROUTES (0): + A value indicating that the enum field is not + set. + STATIC_ROUTES_ALLOWED (409048964): + No description available. + STATIC_ROUTES_BLOCKED (225212360): + No description available. + """ + UNDEFINED_ALLOW_STATIC_ROUTES = 0 + STATIC_ROUTES_ALLOWED = 409048964 + STATIC_ROUTES_BLOCKED = 225212360 + + class AllowSubInterfaces(proto.Enum): + r"""Specifies whether sub interfaces are allowed. + + Values: + UNDEFINED_ALLOW_SUB_INTERFACES (0): + A value indicating that the enum field is not + set. + SUBINTERFACES_ALLOWED (158685891): + No description available. + SUBINTERFACES_BLOCKED (511720199): + No description available. + """ + UNDEFINED_ALLOW_SUB_INTERFACES = 0 + SUBINTERFACES_ALLOWED = 158685891 + SUBINTERFACES_BLOCKED = 511720199 + + class AllowVpcPeering(proto.Enum): + r"""Specifies whether VPC peering is allowed. + + Values: + UNDEFINED_ALLOW_VPC_PEERING (0): + A value indicating that the enum field is not + set. + VPC_PEERING_ALLOWED (261465075): + No description available. + VPC_PEERING_BLOCKED (77628471): + No description available. + """ + UNDEFINED_ALLOW_VPC_PEERING = 0 + VPC_PEERING_ALLOWED = 261465075 + VPC_PEERING_BLOCKED = 77628471 + + class AllowVpn(proto.Enum): + r"""Specifies whether VPN creation is allowed. + + Values: + UNDEFINED_ALLOW_VPN (0): + A value indicating that the enum field is not + set. + VPN_ALLOWED (162163997): + No description available. + VPN_BLOCKED (515198305): + No description available. + """ + UNDEFINED_ALLOW_VPN = 0 + VPN_ALLOWED = 162163997 + VPN_BLOCKED = 515198305 + + class InterfaceTypes(proto.Enum): + r""" + + Values: + UNDEFINED_INTERFACE_TYPES (0): + A value indicating that the enum field is not + set. + GVNIC (68209305): + GVNIC + IDPF (2242641): + IDPF + IRDMA (69927695): + IRDMA + MRDMA (73621779): + MRDMA + UNSPECIFIED_NIC_TYPE (67411801): + No type specified. + VIRTIO_NET (452123481): + VIRTIO + """ + UNDEFINED_INTERFACE_TYPES = 0 + GVNIC = 68209305 + IDPF = 2242641 + IRDMA = 69927695 + MRDMA = 73621779 + UNSPECIFIED_NIC_TYPE = 67411801 + VIRTIO_NET = 452123481 + + class SubnetPurposes(proto.Enum): + r""" + + Values: + UNDEFINED_SUBNET_PURPOSES (0): + A value indicating that the enum field is not + set. + SUBNET_PURPOSE_CUSTOM_HARDWARE (283160275): + No description available. + SUBNET_PURPOSE_PRIVATE (404371008): + No description available. + """ + UNDEFINED_SUBNET_PURPOSES = 0 + SUBNET_PURPOSE_CUSTOM_HARDWARE = 283160275 + SUBNET_PURPOSE_PRIVATE = 404371008 + + class SubnetStackTypes(proto.Enum): + r""" + + Values: + UNDEFINED_SUBNET_STACK_TYPES (0): + A value indicating that the enum field is not + set. + SUBNET_STACK_TYPE_IPV4_IPV6 (41454485): + No description available. + SUBNET_STACK_TYPE_IPV4_ONLY (41631034): + No description available. + SUBNET_STACK_TYPE_IPV6_ONLY (98889336): + No description available. + """ + UNDEFINED_SUBNET_STACK_TYPES = 0 + SUBNET_STACK_TYPE_IPV4_IPV6 = 41454485 + SUBNET_STACK_TYPE_IPV4_ONLY = 41631034 + SUBNET_STACK_TYPE_IPV6_ONLY = 98889336 + + class Unicast(proto.Enum): + r"""Specifies which type of unicast is supported. + + Values: + UNDEFINED_UNICAST (0): + A value indicating that the enum field is not + set. + UNICAST_SDN (379954157): + No description available. + UNICAST_ULL (379956325): + No description available. + """ + UNDEFINED_UNICAST = 0 + UNICAST_SDN = 379954157 + UNICAST_ULL = 379956325 + + address_purposes: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=433024768, + ) + allow_alias_ip_ranges: str = proto.Field( + proto.STRING, + number=457984201, + optional=True, + ) + allow_auto_mode_subnet: str = proto.Field( + proto.STRING, + number=152191263, + optional=True, + ) + allow_class_d_firewalls: str = proto.Field( + proto.STRING, + number=131608987, + optional=True, + ) + allow_cloud_nat: str = proto.Field( + proto.STRING, + number=254831265, + optional=True, + ) + allow_cloud_router: str = proto.Field( + proto.STRING, + number=451110345, + optional=True, + ) + allow_external_ip_access: str = proto.Field( + proto.STRING, + number=131538110, + optional=True, + ) + allow_interconnect: str = proto.Field( + proto.STRING, + number=280512964, + optional=True, + ) + allow_load_balancing: str = proto.Field( + proto.STRING, + number=223366198, + optional=True, + ) + allow_multi_nic_in_same_network: str = proto.Field( + proto.STRING, + number=88251004, + optional=True, + ) + allow_packet_mirroring: str = proto.Field( + proto.STRING, + number=512227074, + optional=True, + ) + allow_private_google_access: str = proto.Field( + proto.STRING, + number=374702072, + optional=True, + ) + allow_psc: str = proto.Field( + proto.STRING, + number=372357322, + optional=True, + ) + allow_same_network_unicast: str = proto.Field( + proto.STRING, + number=167531643, + optional=True, + ) + allow_static_routes: str = proto.Field( + proto.STRING, + number=185257925, + optional=True, + ) + allow_sub_interfaces: str = proto.Field( + proto.STRING, + number=247208303, + optional=True, + ) + allow_vpc_peering: str = proto.Field( + proto.STRING, + number=115402228, + optional=True, + ) + allow_vpn: str = proto.Field( + proto.STRING, + number=372363006, + optional=True, + ) + interface_types: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=157981171, + ) + subnet_purposes: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=301338039, + ) + subnet_stack_types: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=521008672, + ) + unicast: str = proto.Field( + proto.STRING, + number=249841711, + optional=True, + ) + + +class NetworkProfilesListResponse(proto.Message): + r"""Contains a list of network profiles. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + etag (str): + + This field is a member of `oneof`_ ``_etag``. + id (str): + [Output Only] Unique identifier for the resource; defined by + the server. + + This field is a member of `oneof`_ ``_id``. + items (MutableSequence[google.cloud.compute_v1.types.NetworkProfile]): + A list of NetworkProfile resources. + kind (str): + [Output Only] Type of resource. Always + compute#networkProfileList for network profiles. + + This field is a member of `oneof`_ ``_kind``. + next_page_token (str): + [Output Only] This token allows you to get the next page of + results for list requests. If the number of results is + larger than maxResults, use the nextPageToken as a value for + the query parameter pageToken in the next list request. + Subsequent list requests will have their own nextPageToken + to continue paging through the results. + + This field is a member of `oneof`_ ``_next_page_token``. + self_link (str): + [Output Only] Server-defined URL for this resource. + + This field is a member of `oneof`_ ``_self_link``. + unreachables (MutableSequence[str]): + [Output Only] Unreachable resources. end_interface: + MixerListResponseWithEtagBuilder + warning (google.cloud.compute_v1.types.Warning): + [Output Only] Informational warning message. + + This field is a member of `oneof`_ ``_warning``. + """ + + @property + def raw_page(self): + return self + + etag: str = proto.Field( + proto.STRING, + number=3123477, + optional=True, + ) + id: str = proto.Field( + proto.STRING, + number=3355, + optional=True, + ) + items: MutableSequence["NetworkProfile"] = proto.RepeatedField( + proto.MESSAGE, + number=100526016, + message="NetworkProfile", + ) + kind: str = proto.Field( + proto.STRING, + number=3292052, + optional=True, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=79797525, + optional=True, + ) + self_link: str = proto.Field( + proto.STRING, + number=456214797, + optional=True, + ) + unreachables: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=243372063, + ) + warning: "Warning" = proto.Field( + proto.MESSAGE, + number=50704284, + optional=True, + message="Warning", + ) + + class NetworkRoutingConfig(proto.Message): r"""A routing configuration attached to a network resource. The message includes the list of routers associated with the @@ -71164,6 +72442,30 @@ class NetworkRoutingConfig(proto.Message): .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: + bgp_always_compare_med (bool): + Enable comparison of Multi-Exit + Discriminators (MED) across routes with + different neighbor ASNs when using the STANDARD + BGP best path selection algorithm. + + This field is a member of `oneof`_ ``_bgp_always_compare_med``. + bgp_best_path_selection_mode (str): + The BGP best path selection algorithm to be + employed within this network for dynamic routes + learned by Cloud Routers. Can be LEGACY + (default) or STANDARD. Check the + BgpBestPathSelectionMode enum for the list of + possible values. + + This field is a member of `oneof`_ ``_bgp_best_path_selection_mode``. + bgp_inter_region_cost (str): + Allows to define a preferred approach for handling + inter-region cost in the selection process when using the + STANDARD BGP best path selection algorithm. Can be DEFAULT + or ADD_COST_TO_MED. Check the BgpInterRegionCost enum for + the list of possible values. + + This field is a member of `oneof`_ ``_bgp_inter_region_cost``. routing_mode (str): The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will @@ -71177,6 +72479,42 @@ class NetworkRoutingConfig(proto.Message): This field is a member of `oneof`_ ``_routing_mode``. """ + class BgpBestPathSelectionMode(proto.Enum): + r"""The BGP best path selection algorithm to be employed within + this network for dynamic routes learned by Cloud Routers. Can be + LEGACY (default) or STANDARD. + + Values: + UNDEFINED_BGP_BEST_PATH_SELECTION_MODE (0): + A value indicating that the enum field is not + set. + LEGACY (94234569): + No description available. + STANDARD (484642493): + No description available. + """ + UNDEFINED_BGP_BEST_PATH_SELECTION_MODE = 0 + LEGACY = 94234569 + STANDARD = 484642493 + + class BgpInterRegionCost(proto.Enum): + r"""Allows to define a preferred approach for handling inter-region cost + in the selection process when using the STANDARD BGP best path + selection algorithm. Can be DEFAULT or ADD_COST_TO_MED. + + Values: + UNDEFINED_BGP_INTER_REGION_COST (0): + A value indicating that the enum field is not + set. + ADD_COST_TO_MED (490583004): + No description available. + DEFAULT (115302945): + No description available. + """ + UNDEFINED_BGP_INTER_REGION_COST = 0 + ADD_COST_TO_MED = 490583004 + DEFAULT = 115302945 + class RoutingMode(proto.Enum): r"""The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will only advertise routes with @@ -71197,6 +72535,21 @@ class RoutingMode(proto.Enum): GLOBAL = 494663587 REGIONAL = 92288543 + bgp_always_compare_med: bool = proto.Field( + proto.BOOL, + number=213102902, + optional=True, + ) + bgp_best_path_selection_mode: str = proto.Field( + proto.STRING, + number=317816297, + optional=True, + ) + bgp_inter_region_cost: str = proto.Field( + proto.STRING, + number=462142689, + optional=True, + ) routing_mode: str = proto.Field( proto.STRING, number=475143548, @@ -77795,17 +79148,12 @@ class PathMatcher(proto.Message): balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected - backend. If defaultRouteAction specifies any - weightedBackendServices, defaultService must not - be set. Conversely if defaultService is set, - defaultRouteAction cannot contain any - weightedBackendServices. If defaultRouteAction - is specified, don't set defaultUrlRedirect. If - defaultRouteAction.weightedBackendServices is - specified, don't set defaultService. URL maps - for classic Application Load Balancers only - support the urlRewrite action within a path - matcher's defaultRouteAction. + backend. Only one of defaultUrlRedirect, + defaultService or + defaultRouteAction.weightedBackendService can be + set. URL maps for classic Application Load + Balancers only support the urlRewrite action + within a path matcher's defaultRouteAction. This field is a member of `oneof`_ ``_default_route_action``. default_service (str): @@ -77819,25 +79167,21 @@ class PathMatcher(proto.Message): - global/backendServices/backendService If defaultRouteAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending - the request to the backend. However, if defaultService is - specified, defaultRouteAction cannot contain any - weightedBackendServices. Conversely, if defaultRouteAction - specifies any weightedBackendServices, defaultService must - not be specified. If defaultService is specified, then set - either defaultUrlRedirect or - defaultRouteAction.weightedBackendService. Don't set both. - Authorization requires one or more of the following Google - IAM permissions on the specified resource default_service: - - compute.backendBuckets.use - compute.backendServices.use + the request to the backend. Only one of defaultUrlRedirect, + defaultService or defaultRouteAction.weightedBackendService + can be set. Authorization requires one or more of the + following Google IAM permissions on the specified resource + default_service: - compute.backendBuckets.use - + compute.backendServices.use This field is a member of `oneof`_ ``_default_service``. default_url_redirect (google.cloud.compute_v1.types.HttpRedirectAction): When none of the specified pathRules or routeRules match, the request is redirected to a - URL specified by defaultUrlRedirect. If - defaultUrlRedirect is specified, then set either - defaultService or defaultRouteAction. Don't set - both. Not supported when the URL map is bound to + URL specified by defaultUrlRedirect. Only one of + defaultUrlRedirect, defaultService or + defaultRouteAction.weightedBackendService can be + set. Not supported when the URL map is bound to a target gRPC proxy. This field is a member of `oneof`_ ``_default_url_redirect``. @@ -77984,11 +79328,8 @@ class PathRule(proto.Message): balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding the request to the selected - backend. If routeAction specifies any - weightedBackendServices, service must not be - set. Conversely if service is set, routeAction - cannot contain any weightedBackendServices. Only - one of routeAction or urlRedirect must be set. + backend. Only one of urlRedirect, service or + routeAction.weightedBackendService can be set. URL maps for classic Application Load Balancers only support the urlRewrite action within a path rule's routeAction. @@ -78000,21 +79341,18 @@ class PathRule(proto.Message): this rule is matched. If routeAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the request - to the backend. However, if service is - specified, routeAction cannot contain any - weightedBackendServices. Conversely, if - routeAction specifies any - weightedBackendServices, service must not be - specified. Only one of urlRedirect, service or - routeAction.weightedBackendService must be set. + to the backend. Only one of urlRedirect, service + or routeAction.weightedBackendService can be + set. This field is a member of `oneof`_ ``_service``. url_redirect (google.cloud.compute_v1.types.HttpRedirectAction): When a path pattern is matched, the request is redirected to a URL specified by urlRedirect. - If urlRedirect is specified, service or - routeAction must not be set. Not supported when - the URL map is bound to a target gRPC proxy. + Only one of urlRedirect, service or + routeAction.weightedBackendService can be set. + Not supported when the URL map is bound to a + target gRPC proxy. This field is a member of `oneof`_ ``_url_redirect``. """ @@ -78071,8 +79409,8 @@ class PerInstanceConfig(proto.Message): the same name exists then it will be updated, otherwise a new one will be created for the VM instance with the same name. An attempt to - create a per-instance configconfiguration for a - VM instance that either doesn't exist or is not + create a per-instance configuration for a VM + instance that either doesn't exist or is not part of the group will result in an error. This field is a member of `oneof`_ ``_name``. @@ -78700,8 +80038,8 @@ class Project(proto.Message): This field is a member of `oneof`_ ``_description``. enabled_features (MutableSequence[str]): - Restricted features enabled for use on this - project. + An optional list of restricted features + enabled for use on this project. id (int): [Output Only] The unique identifier for the resource. This identifier is defined by the server. This is *not* the @@ -78727,9 +80065,9 @@ class Project(proto.Message): This field is a member of `oneof`_ ``_self_link``. usage_export_location (google.cloud.compute_v1.types.UsageExportLocation): - The naming prefix for daily usage reports and - the Google Cloud Storage bucket where they are - stored. + An optional naming prefix for daily usage + reports and the Google Cloud Storage bucket + where they are stored. This field is a member of `oneof`_ ``_usage_export_location``. vm_dns_setting (str): @@ -80881,6 +82219,9 @@ class Code(proto.Enum): PARTIAL_SUCCESS (39966469): Success is reported, but some results may be missing due to errors + QUOTA_INFO_UNAVAILABLE (304294182): + Quota information is not available to client + requests (e.g: regions.list). REQUIRED_TOS_AGREEMENT (3745539): The user attempted to use a resource that requires a TOS they have not accepted. @@ -80925,6 +82266,7 @@ class Code(proto.Enum): NOT_CRITICAL_ERROR = 105763924 NO_RESULTS_ON_PAGE = 30036744 PARTIAL_SUCCESS = 39966469 + QUOTA_INFO_UNAVAILABLE = 304294182 REQUIRED_TOS_AGREEMENT = 3745539 RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641 RESOURCE_NOT_DELETED = 168598460 @@ -82109,6 +83451,22 @@ class RegionInstanceGroupManagersRecreateRequest(proto.Message): ) +class RegionInstanceGroupManagersResumeInstancesRequest(proto.Message): + r""" + + Attributes: + instances (MutableSequence[str]): + The URLs of one or more instances to resume. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + class RegionInstanceGroupManagersSetTargetPoolsRequest(proto.Message): r""" @@ -82160,6 +83518,80 @@ class RegionInstanceGroupManagersSetTemplateRequest(proto.Message): ) +class RegionInstanceGroupManagersStartInstancesRequest(proto.Message): + r""" + + Attributes: + instances (MutableSequence[str]): + The URLs of one or more instances to start. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + +class RegionInstanceGroupManagersStopInstancesRequest(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + force_stop (bool): + If this flag is set to true, the Instance + Group Manager will proceed to stop the + instances, skipping initialization on them. + + This field is a member of `oneof`_ ``_force_stop``. + instances (MutableSequence[str]): + The URLs of one or more instances to stop. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + force_stop: bool = proto.Field( + proto.BOOL, + number=134762710, + optional=True, + ) + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + +class RegionInstanceGroupManagersSuspendInstancesRequest(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + force_suspend (bool): + If this flag is set to true, the Instance + Group Manager will proceed to suspend the + instances, skipping initialization on them. + + This field is a member of `oneof`_ ``_force_suspend``. + instances (MutableSequence[str]): + The URLs of one or more instances to suspend. This can be a + full URL or a partial URL, such as + zones/[ZONE]/instances/[INSTANCE_NAME]. + """ + + force_suspend: bool = proto.Field( + proto.BOOL, + number=27637480, + optional=True, + ) + instances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=29097598, + ) + + class RegionInstanceGroupsListInstances(proto.Message): r""" @@ -85430,8 +86862,10 @@ class ResourceStatus(proto.Message): Attributes: physical_host (str): - [Output Only] An opaque ID of the host on which the VM is - running. + [Output Only] The precise location of your instance within + the zone's data center, including the block, sub-block, and + host. The field is formatted as follows: + blockId/subBlockId/hostId. This field is a member of `oneof`_ ``_physical_host``. scheduling (google.cloud.compute_v1.types.ResourceStatusScheduling): @@ -85537,6 +86971,128 @@ class ResumeInstanceRequest(proto.Message): ) +class ResumeInstancesInstanceGroupManagerRequest(proto.Message): + r"""A request message for InstanceGroupManagers.ResumeInstances. + See the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + The name of the managed instance group. + instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersResumeInstancesRequest): + The body resource for this request + project (str): + Project ID for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + zone (str): + The name of the zone where the managed + instance group is located. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + instance_group_managers_resume_instances_request_resource: "InstanceGroupManagersResumeInstancesRequest" = proto.Field( + proto.MESSAGE, + number=129015618, + message="InstanceGroupManagersResumeInstancesRequest", + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + ) + + +class ResumeInstancesRegionInstanceGroupManagerRequest(proto.Message): + r"""A request message for + RegionInstanceGroupManagers.ResumeInstances. See the method + description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + Name of the managed instance group. + project (str): + Project ID for this request. + region (str): + Name of the region scoping this request. + region_instance_group_managers_resume_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersResumeInstancesRequest): + The body resource for this request + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + region_instance_group_managers_resume_instances_request_resource: "RegionInstanceGroupManagersResumeInstancesRequest" = proto.Field( + proto.MESSAGE, + number=463471031, + message="RegionInstanceGroupManagersResumeInstancesRequest", + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + + class Route(proto.Message): r"""Represents a Route resource. A route defines a path from VM instances in the VPC network to a specific destination. This @@ -85634,6 +87190,13 @@ class Route(proto.Message): https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/ This field is a member of `oneof`_ ``_next_hop_instance``. + next_hop_inter_region_cost (int): + [Output only] Internal fixed region-to-region cost that + Google Cloud calculates based on factors such as network + performance, distance, and available bandwidth between + regions. + + This field is a member of `oneof`_ ``_next_hop_inter_region_cost``. next_hop_ip (str): The network IP address of an instance that should handle matching packets. Both IPv6 @@ -85647,11 +87210,24 @@ class Route(proto.Message): IPv4-mapped IPv6 address. This field is a member of `oneof`_ ``_next_hop_ip``. + next_hop_med (int): + [Output Only] Multi-Exit Discriminator, a BGP route metric + that indicates the desirability of a particular route in a + network. + + This field is a member of `oneof`_ ``_next_hop_med``. next_hop_network (str): The URL of the local network if it should handle matching packets. This field is a member of `oneof`_ ``_next_hop_network``. + next_hop_origin (str): + [Output Only] Indicates the origin of the route. Can be IGP + (Interior Gateway Protocol), EGP (Exterior Gateway + Protocol), or INCOMPLETE. Check the NextHopOrigin enum for + the list of possible values. + + This field is a member of `oneof`_ ``_next_hop_origin``. next_hop_peering (str): [Output Only] The network peering name that should handle matching packets, which should conform to RFC1035. @@ -85700,6 +87276,27 @@ class Route(proto.Message): messages. """ + class NextHopOrigin(proto.Enum): + r"""[Output Only] Indicates the origin of the route. Can be IGP + (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or + INCOMPLETE. + + Values: + UNDEFINED_NEXT_HOP_ORIGIN (0): + A value indicating that the enum field is not + set. + EGP (68590): + No description available. + IGP (72434): + No description available. + INCOMPLETE (11941214): + No description available. + """ + UNDEFINED_NEXT_HOP_ORIGIN = 0 + EGP = 68590 + IGP = 72434 + INCOMPLETE = 11941214 + class RouteStatus(proto.Enum): r"""[Output only] The status of the route. @@ -85814,16 +87411,31 @@ class RouteType(proto.Enum): number=393508247, optional=True, ) + next_hop_inter_region_cost: int = proto.Field( + proto.UINT32, + number=24442003, + optional=True, + ) next_hop_ip: str = proto.Field( proto.STRING, number=110319529, optional=True, ) + next_hop_med: int = proto.Field( + proto.UINT32, + number=198683530, + optional=True, + ) next_hop_network: str = proto.Field( proto.STRING, number=262295788, optional=True, ) + next_hop_origin: str = proto.Field( + proto.STRING, + number=48752808, + optional=True, + ) next_hop_peering: str = proto.Field( proto.STRING, number=412682750, @@ -90912,8 +92524,11 @@ class SecurityPolicyRuleRateLimitOptions(proto.Message): resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, - the key type defaults to IP. Check the EnforceOnKey enum for - the list of possible values. + the key type defaults to IP. - TLS_JA4_FINGERPRINT: JA4 + TLS/SSL fingerprint if the client connects using HTTPS, + HTTP/2 or HTTP/3. If not available, the key type defaults to + ALL. Check the EnforceOnKey enum for the list of possible + values. This field is a member of `oneof`_ ``_enforce_on_key``. enforce_on_key_configs (MutableSequence[google.cloud.compute_v1.types.SecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfig]): @@ -90984,7 +92599,9 @@ class EnforceOnKey(proto.Enum): client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key - type defaults to IP. + type defaults to IP. - TLS_JA4_FINGERPRINT: JA4 TLS/SSL fingerprint + if the client connects using HTTPS, HTTP/2 or HTTP/3. If not + available, the key type defaults to ALL. Values: UNDEFINED_ENFORCE_ON_KEY (0): @@ -91006,6 +92623,8 @@ class EnforceOnKey(proto.Enum): No description available. TLS_JA3_FINGERPRINT (327127933): No description available. + TLS_JA4_FINGERPRINT (33724926): + No description available. USER_IP (34009627): No description available. XFF_IP (438707118): @@ -91020,6 +92639,7 @@ class EnforceOnKey(proto.Enum): REGION_CODE = 79559768 SNI = 82254 TLS_JA3_FINGERPRINT = 327127933 + TLS_JA4_FINGERPRINT = 33724926 USER_IP = 34009627 XFF_IP = 438707118 @@ -91120,8 +92740,11 @@ class SecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfig(proto.Message): resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, - the key type defaults to IP. Check the EnforceOnKeyType enum - for the list of possible values. + the key type defaults to IP. - TLS_JA4_FINGERPRINT: JA4 + TLS/SSL fingerprint if the client connects using HTTPS, + HTTP/2 or HTTP/3. If not available, the key type defaults to + ALL. Check the EnforceOnKeyType enum for the list of + possible values. This field is a member of `oneof`_ ``_enforce_on_key_type``. """ @@ -91155,7 +92778,9 @@ class EnforceOnKeyType(proto.Enum): client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key - type defaults to IP. + type defaults to IP. - TLS_JA4_FINGERPRINT: JA4 TLS/SSL fingerprint + if the client connects using HTTPS, HTTP/2 or HTTP/3. If not + available, the key type defaults to ALL. Values: UNDEFINED_ENFORCE_ON_KEY_TYPE (0): @@ -91177,6 +92802,8 @@ class EnforceOnKeyType(proto.Enum): No description available. TLS_JA3_FINGERPRINT (327127933): No description available. + TLS_JA4_FINGERPRINT (33724926): + No description available. USER_IP (34009627): No description available. XFF_IP (438707118): @@ -91191,6 +92818,7 @@ class EnforceOnKeyType(proto.Enum): REGION_CODE = 79559768 SNI = 82254 TLS_JA3_FINGERPRINT = 327127933 + TLS_JA4_FINGERPRINT = 33724926 USER_IP = 34009627 XFF_IP = 438707118 @@ -94496,6 +96124,66 @@ class SetLabelsRegionInstantSnapshotRequest(proto.Message): ) +class SetLabelsRegionSecurityPolicyRequest(proto.Message): + r"""A request message for RegionSecurityPolicies.SetLabels. See + the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + project (str): + Project ID for this request. + region (str): + The region for this request. + region_set_labels_request_resource (google.cloud.compute_v1.types.RegionSetLabelsRequest): + The body resource for this request + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + resource (str): + Name or id of the resource for this request. + """ + + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + region_set_labels_request_resource: "RegionSetLabelsRequest" = proto.Field( + proto.MESSAGE, + number=259357782, + message="RegionSetLabelsRequest", + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + resource: str = proto.Field( + proto.STRING, + number=195806222, + ) + + class SetLabelsSecurityPolicyRequest(proto.Message): r"""A request message for SecurityPolicies.SetLabels. See the method description for details. @@ -99222,6 +100910,128 @@ class StartInstanceRequest(proto.Message): ) +class StartInstancesInstanceGroupManagerRequest(proto.Message): + r"""A request message for InstanceGroupManagers.StartInstances. + See the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + The name of the managed instance group. + instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStartInstancesRequest): + The body resource for this request + project (str): + Project ID for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + zone (str): + The name of the zone where the managed + instance group is located. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + instance_group_managers_start_instances_request_resource: "InstanceGroupManagersStartInstancesRequest" = proto.Field( + proto.MESSAGE, + number=261083819, + message="InstanceGroupManagersStartInstancesRequest", + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + ) + + +class StartInstancesRegionInstanceGroupManagerRequest(proto.Message): + r"""A request message for + RegionInstanceGroupManagers.StartInstances. See the method + description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + Name of the managed instance group. + project (str): + Project ID for this request. + region (str): + Name of the region scoping this request. + region_instance_group_managers_start_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStartInstancesRequest): + The body resource for this request + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + region_instance_group_managers_start_instances_request_resource: "RegionInstanceGroupManagersStartInstancesRequest" = proto.Field( + proto.MESSAGE, + number=497012118, + message="RegionInstanceGroupManagersStartInstancesRequest", + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + + class StartWithEncryptionKeyInstanceRequest(proto.Message): r"""A request message for Instances.StartWithEncryptionKey. See the method description for details. @@ -99522,9 +101332,240 @@ class StopAsyncReplicationDiskRequest(proto.Message): The name of the zone for this request. """ - disk: str = proto.Field( + disk: str = proto.Field( + proto.STRING, + number=3083677, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + ) + + +class StopAsyncReplicationRegionDiskRequest(proto.Message): + r"""A request message for RegionDisks.StopAsyncReplication. See + the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + disk (str): + The name of the persistent disk. + project (str): + Project ID for this request. + region (str): + The name of the region for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + """ + + disk: str = proto.Field( + proto.STRING, + number=3083677, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + + +class StopGroupAsyncReplicationDiskRequest(proto.Message): + r"""A request message for Disks.StopGroupAsyncReplication. See + the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + disks_stop_group_async_replication_resource_resource (google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource): + The body resource for this request + project (str): + Project ID for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + zone (str): + The name of the zone for this request. This + must be the zone of the primary or secondary + disks in the consistency group. + """ + + disks_stop_group_async_replication_resource_resource: "DisksStopGroupAsyncReplicationResource" = proto.Field( + proto.MESSAGE, + number=346815509, + message="DisksStopGroupAsyncReplicationResource", + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + ) + + +class StopGroupAsyncReplicationRegionDiskRequest(proto.Message): + r"""A request message for RegionDisks.StopGroupAsyncReplication. + See the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + disks_stop_group_async_replication_resource_resource (google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource): + The body resource for this request + project (str): + Project ID for this request. + region (str): + The name of the region for this request. This + must be the region of the primary or secondary + disks in the consistency group. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + """ + + disks_stop_group_async_replication_resource_resource: "DisksStopGroupAsyncReplicationResource" = proto.Field( + proto.MESSAGE, + number=346815509, + message="DisksStopGroupAsyncReplicationResource", + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + + +class StopInstanceRequest(proto.Message): + r"""A request message for Instances.Stop. See the method + description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + discard_local_ssd (bool): + This property is required if the instance has + any attached Local SSD disks. If false, Local + SSD data will be preserved when the instance is + suspended. If true, the contents of any attached + Local SSD disks will be discarded. + + This field is a member of `oneof`_ ``_discard_local_ssd``. + instance (str): + Name of the instance resource to stop. + project (str): + Project ID for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + zone (str): + The name of the zone for this request. + """ + + discard_local_ssd: bool = proto.Field( + proto.BOOL, + number=319517903, + optional=True, + ) + instance: str = proto.Field( proto.STRING, - number=3083677, + number=18257045, ) project: str = proto.Field( proto.STRING, @@ -99541,68 +101582,17 @@ class StopAsyncReplicationDiskRequest(proto.Message): ) -class StopAsyncReplicationRegionDiskRequest(proto.Message): - r"""A request message for RegionDisks.StopAsyncReplication. See - the method description for details. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - disk (str): - The name of the persistent disk. - project (str): - Project ID for this request. - region (str): - The name of the region for this request. - request_id (str): - An optional request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. For example, consider a situation - where you make an initial request and the - request times out. If you make the request again - with the same request ID, the server can check - if original operation with the same request ID - was received, and if so, will ignore the second - request. This prevents clients from accidentally - creating duplicate commitments. The request ID - must be a valid UUID with the exception that - zero UUID is not supported ( - 00000000-0000-0000-0000-000000000000). - - This field is a member of `oneof`_ ``_request_id``. - """ - - disk: str = proto.Field( - proto.STRING, - number=3083677, - ) - project: str = proto.Field( - proto.STRING, - number=227560217, - ) - region: str = proto.Field( - proto.STRING, - number=138946292, - ) - request_id: str = proto.Field( - proto.STRING, - number=37109963, - optional=True, - ) - - -class StopGroupAsyncReplicationDiskRequest(proto.Message): - r"""A request message for Disks.StopGroupAsyncReplication. See - the method description for details. +class StopInstancesInstanceGroupManagerRequest(proto.Message): + r"""A request message for InstanceGroupManagers.StopInstances. + See the method description for details. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: - disks_stop_group_async_replication_resource_resource (google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource): + instance_group_manager (str): + The name of the managed instance group. + instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersStopInstancesRequest): The body resource for this request project (str): Project ID for this request. @@ -99625,15 +101615,18 @@ class StopGroupAsyncReplicationDiskRequest(proto.Message): This field is a member of `oneof`_ ``_request_id``. zone (str): - The name of the zone for this request. This - must be the zone of the primary or secondary - disks in the consistency group. + The name of the zone where the managed + instance group is located. """ - disks_stop_group_async_replication_resource_resource: "DisksStopGroupAsyncReplicationResource" = proto.Field( + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + instance_group_managers_stop_instances_request_resource: "InstanceGroupManagersStopInstancesRequest" = proto.Field( proto.MESSAGE, - number=346815509, - message="DisksStopGroupAsyncReplicationResource", + number=37556877, + message="InstanceGroupManagersStopInstancesRequest", ) project: str = proto.Field( proto.STRING, @@ -99650,22 +101643,23 @@ class StopGroupAsyncReplicationDiskRequest(proto.Message): ) -class StopGroupAsyncReplicationRegionDiskRequest(proto.Message): - r"""A request message for RegionDisks.StopGroupAsyncReplication. - See the method description for details. +class StopInstancesRegionInstanceGroupManagerRequest(proto.Message): + r"""A request message for + RegionInstanceGroupManagers.StopInstances. See the method + description for details. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: - disks_stop_group_async_replication_resource_resource (google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource): - The body resource for this request + instance_group_manager (str): + The name of the managed instance group. project (str): Project ID for this request. region (str): - The name of the region for this request. This - must be the region of the primary or secondary - disks in the consistency group. + Name of the region scoping this request. + region_instance_group_managers_stop_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersStopInstancesRequest): + The body resource for this request request_id (str): An optional request ID to identify requests. Specify a unique request ID so that if you must @@ -99686,10 +101680,9 @@ class StopGroupAsyncReplicationRegionDiskRequest(proto.Message): This field is a member of `oneof`_ ``_request_id``. """ - disks_stop_group_async_replication_resource_resource: "DisksStopGroupAsyncReplicationResource" = proto.Field( - proto.MESSAGE, - number=346815509, - message="DisksStopGroupAsyncReplicationResource", + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, ) project: str = proto.Field( proto.STRING, @@ -99699,77 +101692,16 @@ class StopGroupAsyncReplicationRegionDiskRequest(proto.Message): proto.STRING, number=138946292, ) - request_id: str = proto.Field( - proto.STRING, - number=37109963, - optional=True, - ) - - -class StopInstanceRequest(proto.Message): - r"""A request message for Instances.Stop. See the method - description for details. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - discard_local_ssd (bool): - This property is required if the instance has - any attached Local SSD disks. If false, Local - SSD data will be preserved when the instance is - suspended. If true, the contents of any attached - Local SSD disks will be discarded. - - This field is a member of `oneof`_ ``_discard_local_ssd``. - instance (str): - Name of the instance resource to stop. - project (str): - Project ID for this request. - request_id (str): - An optional request ID to identify requests. - Specify a unique request ID so that if you must - retry your request, the server will know to - ignore the request if it has already been - completed. For example, consider a situation - where you make an initial request and the - request times out. If you make the request again - with the same request ID, the server can check - if original operation with the same request ID - was received, and if so, will ignore the second - request. This prevents clients from accidentally - creating duplicate commitments. The request ID - must be a valid UUID with the exception that - zero UUID is not supported ( - 00000000-0000-0000-0000-000000000000). - - This field is a member of `oneof`_ ``_request_id``. - zone (str): - The name of the zone for this request. - """ - - discard_local_ssd: bool = proto.Field( - proto.BOOL, - number=319517903, - optional=True, - ) - instance: str = proto.Field( - proto.STRING, - number=18257045, - ) - project: str = proto.Field( - proto.STRING, - number=227560217, + region_instance_group_managers_stop_instances_request_resource: "RegionInstanceGroupManagersStopInstancesRequest" = proto.Field( + proto.MESSAGE, + number=270306882, + message="RegionInstanceGroupManagersStopInstancesRequest", ) request_id: str = proto.Field( proto.STRING, number=37109963, optional=True, ) - zone: str = proto.Field( - proto.STRING, - number=3744684, - ) class StoragePool(proto.Message): @@ -101086,15 +103018,17 @@ class Subnetwork(proto.Message): purpose (str): The purpose of the resource. This field can be either PRIVATE, GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, - PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose - for user-created subnets or subnets that are automatically - created in auto mode networks. Subnets with purpose set to - GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are - user-created subnetworks that are reserved for Envoy-based - load balancers. A subnet with purpose set to - PRIVATE_SERVICE_CONNECT is used to publish services using - Private Service Connect. If unspecified, the subnet purpose - defaults to PRIVATE. The enableFlowLogs field isn't + PEER_MIGRATION or PRIVATE_SERVICE_CONNECT. PRIVATE is the + default purpose for user-created subnets or subnets that are + automatically created in auto mode networks. Subnets with + purpose set to GLOBAL_MANAGED_PROXY or + REGIONAL_MANAGED_PROXY are user-created subnetworks that are + reserved for Envoy-based load balancers. A subnet with + purpose set to PRIVATE_SERVICE_CONNECT is used to publish + services using Private Service Connect. A subnet with + purpose set to PEER_MIGRATION is used for subnet migration + from one peered VPC to another. If unspecified, the subnet + purpose defaults to PRIVATE. The enableFlowLogs field isn't supported if the subnet purpose field is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. Check the Purpose enum for the list of possible values. @@ -101207,17 +103141,18 @@ class PrivateIpv6GoogleAccess(proto.Enum): class Purpose(proto.Enum): r"""The purpose of the resource. This field can be either PRIVATE, - GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, - PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose for + GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, PEER_MIGRATION or + PRIVATE_SERVICE_CONNECT. PRIVATE is the default purpose for user-created subnets or subnets that are automatically created in auto mode networks. Subnets with purpose set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are user-created subnetworks that are reserved for Envoy-based load balancers. A subnet with purpose set to PRIVATE_SERVICE_CONNECT is used to publish services using Private - Service Connect. If unspecified, the subnet purpose defaults to - PRIVATE. The enableFlowLogs field isn't supported if the subnet - purpose field is set to GLOBAL_MANAGED_PROXY or - REGIONAL_MANAGED_PROXY. + Service Connect. A subnet with purpose set to PEER_MIGRATION is used + for subnet migration from one peered VPC to another. If unspecified, + the subnet purpose defaults to PRIVATE. The enableFlowLogs field + isn't supported if the subnet purpose field is set to + GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. Values: UNDEFINED_PURPOSE (0): @@ -101229,6 +103164,11 @@ class Purpose(proto.Enum): INTERNAL_HTTPS_LOAD_BALANCER (248748889): Subnet reserved for Internal HTTP(S) Load Balancing. This is a legacy purpose, please use REGIONAL_MANAGED_PROXY instead. + PEER_MIGRATION (491902225): + Subnetwork will be used for Migration from + one peered VPC to another. (a transient state of + subnetwork while migrating resources from one + project to another). PRIVATE (403485027): Regular user created or automatically created subnet. @@ -101248,6 +103188,7 @@ class Purpose(proto.Enum): UNDEFINED_PURPOSE = 0 GLOBAL_MANAGED_PROXY = 236463602 INTERNAL_HTTPS_LOAD_BALANCER = 248748889 + PEER_MIGRATION = 491902225 PRIVATE = 403485027 PRIVATE_NAT = 367764517 PRIVATE_RFC_1918 = 254902107 @@ -101992,6 +103933,128 @@ class SuspendInstanceRequest(proto.Message): ) +class SuspendInstancesInstanceGroupManagerRequest(proto.Message): + r"""A request message for InstanceGroupManagers.SuspendInstances. + See the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + The name of the managed instance group. + instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.InstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + project (str): + Project ID for this request. + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + zone (str): + The name of the zone where the managed + instance group is located. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + instance_group_managers_suspend_instances_request_resource: "InstanceGroupManagersSuspendInstancesRequest" = proto.Field( + proto.MESSAGE, + number=46679761, + message="InstanceGroupManagersSuspendInstancesRequest", + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + zone: str = proto.Field( + proto.STRING, + number=3744684, + ) + + +class SuspendInstancesRegionInstanceGroupManagerRequest(proto.Message): + r"""A request message for + RegionInstanceGroupManagers.SuspendInstances. See the method + description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + instance_group_manager (str): + Name of the managed instance group. + project (str): + Project ID for this request. + region (str): + Name of the region scoping this request. + region_instance_group_managers_suspend_instances_request_resource (google.cloud.compute_v1.types.RegionInstanceGroupManagersSuspendInstancesRequest): + The body resource for this request + request_id (str): + An optional request ID to identify requests. + Specify a unique request ID so that if you must + retry your request, the server will know to + ignore the request if it has already been + completed. For example, consider a situation + where you make an initial request and the + request times out. If you make the request again + with the same request ID, the server can check + if original operation with the same request ID + was received, and if so, will ignore the second + request. This prevents clients from accidentally + creating duplicate commitments. The request ID + must be a valid UUID with the exception that + zero UUID is not supported ( + 00000000-0000-0000-0000-000000000000). + + This field is a member of `oneof`_ ``_request_id``. + """ + + instance_group_manager: str = proto.Field( + proto.STRING, + number=249363395, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + region: str = proto.Field( + proto.STRING, + number=138946292, + ) + region_instance_group_managers_suspend_instances_request_resource: "RegionInstanceGroupManagersSuspendInstancesRequest" = proto.Field( + proto.MESSAGE, + number=214250236, + message="RegionInstanceGroupManagersSuspendInstancesRequest", + ) + request_id: str = proto.Field( + proto.STRING, + number=37109963, + optional=True, + ) + + class SwitchToCustomModeNetworkRequest(proto.Message): r"""A request message for Networks.SwitchToCustomMode. See the method description for details. @@ -102909,15 +104972,15 @@ class TargetHttpsProxy(proto.Message): two Target HTTPS Proxy resources: \* `Global `__ \* `Regional `__ - A target HTTPS proxy is a component of GCP HTTPS load balancers. \* - targetHttpProxies are used by global external Application Load - Balancers, classic Application Load Balancers, cross-region internal - Application Load Balancers, and Traffic Director. \* - regionTargetHttpProxies are used by regional internal Application - Load Balancers and regional external Application Load Balancers. - Forwarding rules reference a target HTTPS proxy, and the target - proxy then references a URL map. For more information, read Using - Target Proxies and Forwarding rule concepts. + A target HTTPS proxy is a component of Google Cloud HTTPS load + balancers. \* targetHttpProxies are used by global external + Application Load Balancers, classic Application Load Balancers, + cross-region internal Application Load Balancers, and Traffic + Director. \* regionTargetHttpProxies are used by regional internal + Application Load Balancers and regional external Application Load + Balancers. Forwarding rules reference a target HTTPS proxy, and the + target proxy then references a URL map. For more information, read + Using Target Proxies and Forwarding rule concepts. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields @@ -103201,11 +105264,21 @@ class TlsEarlyData(proto.Enum): query parameters. Requests that send Early Data with non-idempotent HTTP methods or with query parameters will be rejected with a HTTP 425. + UNRESTRICTED (457266100): + This enables TLS 1.3 Early Data for requests + with any HTTP method including non-idempotent + methods list POST. This mode does not enforce + any other limitations. This may be valuable for + gRPC use cases. However, we do not recommend + this method unless you have evaluated your + security stance and mitigated the risk of replay + attacks using other mechanisms. """ UNDEFINED_TLS_EARLY_DATA = 0 DISABLED = 516696700 PERMISSIVE = 504345247 STRICT = 308826825 + UNRESTRICTED = 457266100 authorization_policy: str = proto.Field( proto.STRING, @@ -108260,13 +110333,9 @@ class UrlMap(proto.Message): the hostRules match. The load balancer performs advanced routing actions, such as URL rewrites and header transformations, before forwarding - the request to the selected backend. If - defaultRouteAction specifies any - weightedBackendServices, defaultService must not - be set. Conversely if defaultService is set, - defaultRouteAction cannot contain any - weightedBackendServices. Only one of - defaultRouteAction or defaultUrlRedirect must be + the request to the selected backend. Only one of + defaultUrlRedirect, defaultService or + defaultRouteAction.weightedBackendService can be set. URL maps for classic Application Load Balancers only support the urlRewrite action within defaultRouteAction. defaultRouteAction @@ -108281,28 +110350,22 @@ class UrlMap(proto.Message): the hostRules match. If defaultRouteAction is also specified, advanced routing actions, such as URL rewrites, take effect before sending the - request to the backend. However, if - defaultService is specified, defaultRouteAction - cannot contain any - defaultRouteAction.weightedBackendServices. - Conversely, if defaultRouteAction specifies any - defaultRouteAction.weightedBackendServices, - defaultService must not be specified. If - defaultService is specified, then set either - defaultUrlRedirect , or - defaultRouteAction.weightedBackendService Don't - set both. defaultService has no effect when the - URL map is bound to a target gRPC proxy that has - the validateForProxyless field set to true. + request to the backend. Only one of + defaultUrlRedirect, defaultService or + defaultRouteAction.weightedBackendService can be + set. defaultService has no effect when the URL + map is bound to a target gRPC proxy that has the + validateForProxyless field set to true. This field is a member of `oneof`_ ``_default_service``. default_url_redirect (google.cloud.compute_v1.types.HttpRedirectAction): When none of the specified hostRules match, the request is redirected to a URL specified by - defaultUrlRedirect. If defaultUrlRedirect is - specified, defaultService or defaultRouteAction - must not be set. Not supported when the URL map - is bound to a target gRPC proxy. + defaultUrlRedirect. Only one of + defaultUrlRedirect, defaultService or + defaultRouteAction.weightedBackendService can be + set. Not supported when the URL map is bound to + a target gRPC proxy. This field is a member of `oneof`_ ``_default_url_redirect``. description (str): @@ -109023,15 +111086,17 @@ class UsableSubnetwork(proto.Message): purpose (str): The purpose of the resource. This field can be either PRIVATE, GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, - PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose - for user-created subnets or subnets that are automatically - created in auto mode networks. Subnets with purpose set to - GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are - user-created subnetworks that are reserved for Envoy-based - load balancers. A subnet with purpose set to - PRIVATE_SERVICE_CONNECT is used to publish services using - Private Service Connect. If unspecified, the subnet purpose - defaults to PRIVATE. The enableFlowLogs field isn't + PEER_MIGRATION or PRIVATE_SERVICE_CONNECT. PRIVATE is the + default purpose for user-created subnets or subnets that are + automatically created in auto mode networks. Subnets with + purpose set to GLOBAL_MANAGED_PROXY or + REGIONAL_MANAGED_PROXY are user-created subnetworks that are + reserved for Envoy-based load balancers. A subnet with + purpose set to PRIVATE_SERVICE_CONNECT is used to publish + services using Private Service Connect. A subnet with + purpose set to PEER_MIGRATION is used for subnet migration + from one peered VPC to another. If unspecified, the subnet + purpose defaults to PRIVATE. The enableFlowLogs field isn't supported if the subnet purpose field is set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. Check the Purpose enum for the list of possible values. @@ -109091,17 +111156,18 @@ class Ipv6AccessType(proto.Enum): class Purpose(proto.Enum): r"""The purpose of the resource. This field can be either PRIVATE, - GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, - PRIVATE_SERVICE_CONNECT, or PRIVATE is the default purpose for + GLOBAL_MANAGED_PROXY, REGIONAL_MANAGED_PROXY, PEER_MIGRATION or + PRIVATE_SERVICE_CONNECT. PRIVATE is the default purpose for user-created subnets or subnets that are automatically created in auto mode networks. Subnets with purpose set to GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY are user-created subnetworks that are reserved for Envoy-based load balancers. A subnet with purpose set to PRIVATE_SERVICE_CONNECT is used to publish services using Private - Service Connect. If unspecified, the subnet purpose defaults to - PRIVATE. The enableFlowLogs field isn't supported if the subnet - purpose field is set to GLOBAL_MANAGED_PROXY or - REGIONAL_MANAGED_PROXY. + Service Connect. A subnet with purpose set to PEER_MIGRATION is used + for subnet migration from one peered VPC to another. If unspecified, + the subnet purpose defaults to PRIVATE. The enableFlowLogs field + isn't supported if the subnet purpose field is set to + GLOBAL_MANAGED_PROXY or REGIONAL_MANAGED_PROXY. Values: UNDEFINED_PURPOSE (0): @@ -109113,6 +111179,11 @@ class Purpose(proto.Enum): INTERNAL_HTTPS_LOAD_BALANCER (248748889): Subnet reserved for Internal HTTP(S) Load Balancing. This is a legacy purpose, please use REGIONAL_MANAGED_PROXY instead. + PEER_MIGRATION (491902225): + Subnetwork will be used for Migration from + one peered VPC to another. (a transient state of + subnetwork while migrating resources from one + project to another). PRIVATE (403485027): Regular user created or automatically created subnet. @@ -109132,6 +111203,7 @@ class Purpose(proto.Enum): UNDEFINED_PURPOSE = 0 GLOBAL_MANAGED_PROXY = 236463602 INTERNAL_HTTPS_LOAD_BALANCER = 248748889 + PEER_MIGRATION = 491902225 PRIVATE = 403485027 PRIVATE_NAT = 367764517 PRIVATE_RFC_1918 = 254902107 @@ -111208,6 +113280,9 @@ class Code(proto.Enum): PARTIAL_SUCCESS (39966469): Success is reported, but some results may be missing due to errors + QUOTA_INFO_UNAVAILABLE (304294182): + Quota information is not available to client + requests (e.g: regions.list). REQUIRED_TOS_AGREEMENT (3745539): The user attempted to use a resource that requires a TOS they have not accepted. @@ -111252,6 +113327,7 @@ class Code(proto.Enum): NOT_CRITICAL_ERROR = 105763924 NO_RESULTS_ON_PAGE = 30036744 PARTIAL_SUCCESS = 39966469 + QUOTA_INFO_UNAVAILABLE = 304294182 REQUIRED_TOS_AGREEMENT = 3745539 RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641 RESOURCE_NOT_DELETED = 168598460 @@ -111376,6 +113452,9 @@ class Code(proto.Enum): PARTIAL_SUCCESS (39966469): Success is reported, but some results may be missing due to errors + QUOTA_INFO_UNAVAILABLE (304294182): + Quota information is not available to client + requests (e.g: regions.list). REQUIRED_TOS_AGREEMENT (3745539): The user attempted to use a resource that requires a TOS they have not accepted. @@ -111420,6 +113499,7 @@ class Code(proto.Enum): NOT_CRITICAL_ERROR = 105763924 NO_RESULTS_ON_PAGE = 30036744 PARTIAL_SUCCESS = 39966469 + QUOTA_INFO_UNAVAILABLE = 304294182 REQUIRED_TOS_AGREEMENT = 3745539 RESOURCE_IN_USE_BY_OTHER_RESOURCE_WARNING = 496728641 RESOURCE_NOT_DELETED = 168598460 diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_resume_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_resume_instances_sync.py new file mode 100644 index 000000000000..3c9f4baf79b3 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_resume_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_InstanceGroupManagers_ResumeInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_resume_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.ResumeInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.resume_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_InstanceGroupManagers_ResumeInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_start_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_start_instances_sync.py new file mode 100644 index 000000000000..afe9e20ab3aa --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_start_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_InstanceGroupManagers_StartInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_start_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_InstanceGroupManagers_StartInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_stop_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_stop_instances_sync.py new file mode 100644 index 000000000000..fd1352845764 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_stop_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_InstanceGroupManagers_StopInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_stop_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_InstanceGroupManagers_StopInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_suspend_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_suspend_instances_sync.py new file mode 100644 index 000000000000..99152b1b970a --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_instance_group_managers_suspend_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SuspendInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_InstanceGroupManagers_SuspendInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_suspend_instances(): + # Create a client + client = compute_v1.InstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + zone="zone_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_InstanceGroupManagers_SuspendInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_get_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_get_sync.py new file mode 100644 index 000000000000..3da75083b217 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_get_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Get +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_NetworkProfiles_Get_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_get(): + # Create a client + client = compute_v1.NetworkProfilesClient() + + # Initialize request argument(s) + request = compute_v1.GetNetworkProfileRequest( + network_profile="network_profile_value", + project="project_value", + ) + + # Make the request + response = client.get(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_NetworkProfiles_Get_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_list_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_list_sync.py new file mode 100644 index 000000000000..ced6affb06a1 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_profiles_list_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for List +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_NetworkProfiles_List_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_list(): + # Create a client + client = compute_v1.NetworkProfilesClient() + + # Initialize request argument(s) + request = compute_v1.ListNetworkProfilesRequest( + project="project_value", + ) + + # Make the request + page_result = client.list(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END compute_v1_generated_NetworkProfiles_List_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_resume_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_resume_instances_sync.py new file mode 100644 index 000000000000..8647ce546fbe --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_resume_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_RegionInstanceGroupManagers_ResumeInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_resume_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.ResumeInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.resume_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_RegionInstanceGroupManagers_ResumeInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_start_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_start_instances_sync.py new file mode 100644 index 000000000000..d897041bdb3c --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_start_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_RegionInstanceGroupManagers_StartInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_start_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StartInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.start_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_RegionInstanceGroupManagers_StartInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_stop_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_stop_instances_sync.py new file mode 100644 index 000000000000..f93f9295fcb2 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_stop_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_RegionInstanceGroupManagers_StopInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_stop_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.StopInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.stop_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_RegionInstanceGroupManagers_StopInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py new file mode 100644 index 000000000000..ddb7979a8023 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SuspendInstances +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_RegionInstanceGroupManagers_SuspendInstances_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_suspend_instances(): + # Create a client + client = compute_v1.RegionInstanceGroupManagersClient() + + # Initialize request argument(s) + request = compute_v1.SuspendInstancesRegionInstanceGroupManagerRequest( + instance_group_manager="instance_group_manager_value", + project="project_value", + region="region_value", + ) + + # Make the request + response = client.suspend_instances(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_RegionInstanceGroupManagers_SuspendInstances_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_security_policies_set_labels_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_security_policies_set_labels_sync.py new file mode 100644 index 000000000000..0edc1fe81517 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_region_security_policies_set_labels_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetLabels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-compute + + +# [START compute_v1_generated_RegionSecurityPolicies_SetLabels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import compute_v1 + + +def sample_set_labels(): + # Create a client + client = compute_v1.RegionSecurityPoliciesClient() + + # Initialize request argument(s) + request = compute_v1.SetLabelsRegionSecurityPolicyRequest( + project="project_value", + region="region_value", + resource="resource_value", + ) + + # Make the request + response = client.set_labels(request=request) + + # Handle the response + print(response) + +# [END compute_v1_generated_RegionSecurityPolicies_SetLabels_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json b/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json index c103fe7699b3..c1de369bea94 100644 --- a/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json +++ b/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-compute", - "version": "1.22.0" + "version": "0.1.0" }, "snippets": [ { @@ -46,7 +46,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.accelerator_types.pagers.AggregatedListPager", @@ -134,7 +134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.AcceleratorType", @@ -218,7 +218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.accelerator_types.pagers.ListPager", @@ -298,7 +298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.addresses.pagers.AggregatedListPager", @@ -386,7 +386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -474,7 +474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Address", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -646,7 +646,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.addresses.pagers.ListPager", @@ -738,7 +738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -830,7 +830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -910,7 +910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.autoscalers.pagers.AggregatedListPager", @@ -998,7 +998,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1086,7 +1086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Autoscaler", @@ -1174,7 +1174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.autoscalers.pagers.ListPager", @@ -1346,7 +1346,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1434,7 +1434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1522,7 +1522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1610,7 +1610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1694,7 +1694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -1778,7 +1778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -1862,7 +1862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.BackendBucket", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2026,7 +2026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.backend_buckets.pagers.ListPager", @@ -2114,7 +2114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2202,7 +2202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2290,7 +2290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -2378,7 +2378,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -2466,7 +2466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2554,7 +2554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2634,7 +2634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.backend_services.pagers.AggregatedListPager", @@ -2722,7 +2722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2806,7 +2806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -2894,7 +2894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.BackendServiceGroupHealth", @@ -2978,7 +2978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -3062,7 +3062,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.BackendService", @@ -3146,7 +3146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -3226,7 +3226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.backend_services.pagers.ListUsablePager", @@ -3306,7 +3306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.backend_services.pagers.ListPager", @@ -3394,7 +3394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -3482,7 +3482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -3570,7 +3570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -3658,7 +3658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -3746,7 +3746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -3834,7 +3834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -3914,7 +3914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.disk_types.pagers.AggregatedListPager", @@ -4002,7 +4002,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.DiskType", @@ -4086,7 +4086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.disk_types.pagers.ListPager", @@ -4178,7 +4178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -4258,7 +4258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.disks.pagers.AggregatedListPager", @@ -4346,7 +4346,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -4438,7 +4438,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -4526,7 +4526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -4614,7 +4614,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -4702,7 +4702,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Disk", @@ -4790,7 +4790,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -4874,7 +4874,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.disks.pagers.ListPager", @@ -4966,7 +4966,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5058,7 +5058,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5150,7 +5150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -5242,7 +5242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5334,7 +5334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5422,7 +5422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5510,7 +5510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5602,7 +5602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -5694,7 +5694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5778,7 +5778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -5862,7 +5862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ExternalVpnGateway", @@ -5946,7 +5946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6026,7 +6026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.external_vpn_gateways.pagers.ListPager", @@ -6114,7 +6114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6202,7 +6202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -6286,7 +6286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6370,7 +6370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6450,7 +6450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6530,7 +6530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -6610,7 +6610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyAssociation", @@ -6690,7 +6690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -6770,7 +6770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyRule", @@ -6850,7 +6850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicy", @@ -6934,7 +6934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7010,7 +7010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPoliciesListAssociationsResponse", @@ -7086,7 +7086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.firewall_policies.pagers.ListPager", @@ -7170,7 +7170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7254,7 +7254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7338,7 +7338,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7418,7 +7418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7498,7 +7498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7582,7 +7582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -7666,7 +7666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -7750,7 +7750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7834,7 +7834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Firewall", @@ -7918,7 +7918,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -7998,7 +7998,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.firewalls.pagers.ListPager", @@ -8086,7 +8086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8174,7 +8174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8254,7 +8254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.forwarding_rules.pagers.AggregatedListPager", @@ -8342,7 +8342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8430,7 +8430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ForwardingRule", @@ -8518,7 +8518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8602,7 +8602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.forwarding_rules.pagers.ListPager", @@ -8694,7 +8694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8786,7 +8786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8878,7 +8878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -8962,7 +8962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9046,7 +9046,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Address", @@ -9130,7 +9130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9210,7 +9210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_addresses.pagers.ListPager", @@ -9298,7 +9298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9386,7 +9386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9470,7 +9470,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9554,7 +9554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ForwardingRule", @@ -9638,7 +9638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9718,7 +9718,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_forwarding_rules.pagers.ListPager", @@ -9806,7 +9806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9894,7 +9894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -9982,7 +9982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -10070,7 +10070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -10154,7 +10154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -10242,7 +10242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -10326,7 +10326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NetworkEndpointGroup", @@ -10410,7 +10410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -10494,7 +10494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_network_endpoint_groups.pagers.ListNetworkEndpointsPager", @@ -10574,7 +10574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_network_endpoint_groups.pagers.ListPager", @@ -10654,7 +10654,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_operations.pagers.AggregatedListPager", @@ -10738,7 +10738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.DeleteGlobalOperationResponse", @@ -10822,7 +10822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -10902,7 +10902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_operations.pagers.ListPager", @@ -10986,7 +10986,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -11066,7 +11066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.DeleteGlobalOrganizationOperationResponse", @@ -11146,7 +11146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -11222,7 +11222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_organization_operations.pagers.ListPager", @@ -11306,7 +11306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -11390,7 +11390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.PublicDelegatedPrefix", @@ -11474,7 +11474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -11554,7 +11554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.global_public_delegated_prefixes.pagers.ListPager", @@ -11642,7 +11642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -11722,7 +11722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.health_checks.pagers.AggregatedListPager", @@ -11806,7 +11806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -11890,7 +11890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.HealthCheck", @@ -11974,7 +11974,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12054,7 +12054,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.health_checks.pagers.ListPager", @@ -12142,7 +12142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12230,7 +12230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12318,7 +12318,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ImageFamilyView", @@ -12402,7 +12402,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12490,7 +12490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12574,7 +12574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Image", @@ -12658,7 +12658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -12742,7 +12742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Image", @@ -12826,7 +12826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -12906,7 +12906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.images.pagers.ListPager", @@ -12994,7 +12994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13082,7 +13082,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -13170,7 +13170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13258,7 +13258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -13350,7 +13350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13442,7 +13442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13534,7 +13534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceGroupManagerResizeRequest", @@ -13626,7 +13626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13714,7 +13714,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_manager_resize_requests.pagers.ListPager", @@ -13806,7 +13806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -13886,7 +13886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_managers.pagers.AggregatedListPager", @@ -13978,7 +13978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14070,7 +14070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14162,7 +14162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14254,7 +14254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14342,7 +14342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14430,7 +14430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceGroupManager", @@ -14518,7 +14518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -14606,7 +14606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_managers.pagers.ListErrorsPager", @@ -14694,7 +14694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_managers.pagers.ListManagedInstancesPager", @@ -14782,7 +14782,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_managers.pagers.ListPerInstanceConfigsPager", @@ -14866,7 +14866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_group_managers.pagers.ListPager", @@ -14958,7 +14958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -15050,7 +15050,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -15142,7 +15142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -15234,7 +15234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -15286,19 +15286,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.set_instance_template", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.resume_instances", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.ResumeInstances", "service": { "fullName": "google.cloud.compute.v1.InstanceGroupManagers", "shortName": "InstanceGroupManagers" }, - "shortName": "SetInstanceTemplate" + "shortName": "ResumeInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ResumeInstancesInstanceGroupManagerRequest" }, { "name": "project", @@ -15313,8 +15313,8 @@ "type": "str" }, { - "name": "instance_group_managers_set_instance_template_request_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest" + "name": "instance_group_managers_resume_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersResumeInstancesRequest" }, { "name": "retry", @@ -15326,17 +15326,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_instance_template" + "shortName": "resume_instances" }, - "description": "Sample for SetInstanceTemplate", - "file": "compute_v1_generated_instance_group_managers_set_instance_template_sync.py", + "description": "Sample for ResumeInstances", + "file": "compute_v1_generated_instance_group_managers_resume_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_ResumeInstances_sync", "segments": [ { "end": 53, @@ -15369,7 +15369,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_group_managers_set_instance_template_sync.py" + "title": "compute_v1_generated_instance_group_managers_resume_instances_sync.py" }, { "canonical": true, @@ -15378,19 +15378,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.set_target_pools", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.set_instance_template", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetTargetPools", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetInstanceTemplate", "service": { "fullName": "google.cloud.compute.v1.InstanceGroupManagers", "shortName": "InstanceGroupManagers" }, - "shortName": "SetTargetPools" + "shortName": "SetInstanceTemplate" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.SetInstanceTemplateInstanceGroupManagerRequest" }, { "name": "project", @@ -15405,8 +15405,8 @@ "type": "str" }, { - "name": "instance_group_managers_set_target_pools_request_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest" + "name": "instance_group_managers_set_instance_template_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersSetInstanceTemplateRequest" }, { "name": "retry", @@ -15418,17 +15418,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_target_pools" + "shortName": "set_instance_template" }, - "description": "Sample for SetTargetPools", - "file": "compute_v1_generated_instance_group_managers_set_target_pools_sync.py", + "description": "Sample for SetInstanceTemplate", + "file": "compute_v1_generated_instance_group_managers_set_instance_template_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroupManagers_SetTargetPools_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_SetInstanceTemplate_sync", "segments": [ { "end": 53, @@ -15461,7 +15461,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_group_managers_set_target_pools_sync.py" + "title": "compute_v1_generated_instance_group_managers_set_instance_template_sync.py" }, { "canonical": true, @@ -15470,19 +15470,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.update_per_instance_configs", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.set_target_pools", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroupManagers.UpdatePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SetTargetPools", "service": { "fullName": "google.cloud.compute.v1.InstanceGroupManagers", "shortName": "InstanceGroupManagers" }, - "shortName": "UpdatePerInstanceConfigs" + "shortName": "SetTargetPools" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdatePerInstanceConfigsInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.SetTargetPoolsInstanceGroupManagerRequest" }, { "name": "project", @@ -15497,8 +15497,8 @@ "type": "str" }, { - "name": "instance_group_managers_update_per_instance_configs_req_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupManagersUpdatePerInstanceConfigsReq" + "name": "instance_group_managers_set_target_pools_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersSetTargetPoolsRequest" }, { "name": "retry", @@ -15510,17 +15510,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update_per_instance_configs" + "shortName": "set_target_pools" }, - "description": "Sample for UpdatePerInstanceConfigs", - "file": "compute_v1_generated_instance_group_managers_update_per_instance_configs_sync.py", + "description": "Sample for SetTargetPools", + "file": "compute_v1_generated_instance_group_managers_set_target_pools_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_SetTargetPools_sync", "segments": [ { "end": 53, @@ -15553,28 +15553,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_group_managers_update_per_instance_configs_sync.py" + "title": "compute_v1_generated_instance_group_managers_set_target_pools_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.InstanceGroupsClient", - "shortName": "InstanceGroupsClient" + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", + "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.add_instances", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.start_instances", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.AddInstances", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.StartInstances", "service": { - "fullName": "google.cloud.compute.v1.InstanceGroups", - "shortName": "InstanceGroups" + "fullName": "google.cloud.compute.v1.InstanceGroupManagers", + "shortName": "InstanceGroupManagers" }, - "shortName": "AddInstances" + "shortName": "StartInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AddInstancesInstanceGroupRequest" + "type": "google.cloud.compute_v1.types.StartInstancesInstanceGroupManagerRequest" }, { "name": "project", @@ -15585,12 +15585,12 @@ "type": "str" }, { - "name": "instance_group", + "name": "instance_group_manager", "type": "str" }, { - "name": "instance_groups_add_instances_request_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupsAddInstancesRequest" + "name": "instance_group_managers_start_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersStartInstancesRequest" }, { "name": "retry", @@ -15602,17 +15602,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "add_instances" + "shortName": "start_instances" }, - "description": "Sample for AddInstances", - "file": "compute_v1_generated_instance_groups_add_instances_sync.py", + "description": "Sample for StartInstances", + "file": "compute_v1_generated_instance_group_managers_start_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_AddInstances_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_StartInstances_sync", "segments": [ { "end": 53, @@ -15645,33 +15645,45 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_add_instances_sync.py" + "title": "compute_v1_generated_instance_group_managers_start_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.InstanceGroupsClient", - "shortName": "InstanceGroupsClient" + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", + "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.aggregated_list", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.stop_instances", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.AggregatedList", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.StopInstances", "service": { - "fullName": "google.cloud.compute.v1.InstanceGroups", - "shortName": "InstanceGroups" + "fullName": "google.cloud.compute.v1.InstanceGroupManagers", + "shortName": "InstanceGroupManagers" }, - "shortName": "AggregatedList" + "shortName": "StopInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AggregatedListInstanceGroupsRequest" + "type": "google.cloud.compute_v1.types.StopInstancesInstanceGroupManagerRequest" }, { "name": "project", "type": "str" }, + { + "name": "zone", + "type": "str" + }, + { + "name": "instance_group_manager", + "type": "str" + }, + { + "name": "instance_group_managers_stop_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersStopInstancesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -15682,25 +15694,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.AggregatedListPager", - "shortName": "aggregated_list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "stop_instances" }, - "description": "Sample for AggregatedList", - "file": "compute_v1_generated_instance_groups_aggregated_list_sync.py", + "description": "Sample for StopInstances", + "file": "compute_v1_generated_instance_group_managers_stop_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_AggregatedList_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_StopInstances_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -15710,43 +15722,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_aggregated_list_sync.py" + "title": "compute_v1_generated_instance_group_managers_stop_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.InstanceGroupsClient", - "shortName": "InstanceGroupsClient" + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", + "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.delete", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.suspend_instances", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.Delete", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.SuspendInstances", "service": { - "fullName": "google.cloud.compute.v1.InstanceGroups", - "shortName": "InstanceGroups" + "fullName": "google.cloud.compute.v1.InstanceGroupManagers", + "shortName": "InstanceGroupManagers" }, - "shortName": "Delete" + "shortName": "SuspendInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteInstanceGroupRequest" + "type": "google.cloud.compute_v1.types.SuspendInstancesInstanceGroupManagerRequest" }, { "name": "project", @@ -15757,9 +15769,13 @@ "type": "str" }, { - "name": "instance_group", + "name": "instance_group_manager", "type": "str" }, + { + "name": "instance_group_managers_suspend_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersSuspendInstancesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -15770,17 +15786,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "shortName": "suspend_instances" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_instance_groups_delete_sync.py", + "description": "Sample for SuspendInstances", + "file": "compute_v1_generated_instance_group_managers_suspend_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_Delete_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_SuspendInstances_sync", "segments": [ { "end": 53, @@ -15813,28 +15829,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_delete_sync.py" + "title": "compute_v1_generated_instance_group_managers_suspend_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.InstanceGroupsClient", - "shortName": "InstanceGroupsClient" + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient", + "shortName": "InstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.get", + "fullName": "google.cloud.compute_v1.InstanceGroupManagersClient.update_per_instance_configs", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.Get", + "fullName": "google.cloud.compute.v1.InstanceGroupManagers.UpdatePerInstanceConfigs", "service": { - "fullName": "google.cloud.compute.v1.InstanceGroups", - "shortName": "InstanceGroups" + "fullName": "google.cloud.compute.v1.InstanceGroupManagers", + "shortName": "InstanceGroupManagers" }, - "shortName": "Get" + "shortName": "UpdatePerInstanceConfigs" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetInstanceGroupRequest" + "type": "google.cloud.compute_v1.types.UpdatePerInstanceConfigsInstanceGroupManagerRequest" }, { "name": "project", @@ -15845,9 +15861,13 @@ "type": "str" }, { - "name": "instance_group", + "name": "instance_group_manager", "type": "str" }, + { + "name": "instance_group_managers_update_per_instance_configs_req_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManagersUpdatePerInstanceConfigsReq" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -15858,17 +15878,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.InstanceGroup", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "update_per_instance_configs" }, - "description": "Sample for Get", - "file": "compute_v1_generated_instance_groups_get_sync.py", + "description": "Sample for UpdatePerInstanceConfigs", + "file": "compute_v1_generated_instance_group_managers_update_per_instance_configs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_Get_sync", + "regionTag": "compute_v1_generated_InstanceGroupManagers_UpdatePerInstanceConfigs_sync", "segments": [ { "end": 53, @@ -15901,7 +15921,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_get_sync.py" + "title": "compute_v1_generated_instance_group_managers_update_per_instance_configs_sync.py" }, { "canonical": true, @@ -15910,19 +15930,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupsClient", "shortName": "InstanceGroupsClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.insert", + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.add_instances", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.Insert", + "fullName": "google.cloud.compute.v1.InstanceGroups.AddInstances", "service": { "fullName": "google.cloud.compute.v1.InstanceGroups", "shortName": "InstanceGroups" }, - "shortName": "Insert" + "shortName": "AddInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertInstanceGroupRequest" + "type": "google.cloud.compute_v1.types.AddInstancesInstanceGroupRequest" }, { "name": "project", @@ -15933,8 +15953,12 @@ "type": "str" }, { - "name": "instance_group_resource", - "type": "google.cloud.compute_v1.types.InstanceGroup" + "name": "instance_group", + "type": "str" + }, + { + "name": "instance_groups_add_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupsAddInstancesRequest" }, { "name": "retry", @@ -15946,25 +15970,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "shortName": "add_instances" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_instance_groups_insert_sync.py", + "description": "Sample for AddInstances", + "file": "compute_v1_generated_instance_groups_add_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_Insert_sync", + "regionTag": "compute_v1_generated_InstanceGroups_AddInstances_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -15974,22 +15998,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_insert_sync.py" + "title": "compute_v1_generated_instance_groups_add_instances_sync.py" }, { "canonical": true, @@ -15998,36 +16022,24 @@ "fullName": "google.cloud.compute_v1.InstanceGroupsClient", "shortName": "InstanceGroupsClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.list_instances", + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.aggregated_list", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.ListInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.AggregatedList", "service": { "fullName": "google.cloud.compute.v1.InstanceGroups", "shortName": "InstanceGroups" }, - "shortName": "ListInstances" + "shortName": "AggregatedList" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListInstancesInstanceGroupsRequest" + "type": "google.cloud.compute_v1.types.AggregatedListInstanceGroupsRequest" }, { "name": "project", "type": "str" }, - { - "name": "zone", - "type": "str" - }, - { - "name": "instance_group", - "type": "str" - }, - { - "name": "instance_groups_list_instances_request_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupsListInstancesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -16038,25 +16050,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.ListInstancesPager", - "shortName": "list_instances" + "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.AggregatedListPager", + "shortName": "aggregated_list" }, - "description": "Sample for ListInstances", - "file": "compute_v1_generated_instance_groups_list_instances_sync.py", + "description": "Sample for AggregatedList", + "file": "compute_v1_generated_instance_groups_aggregated_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_ListInstances_sync", + "regionTag": "compute_v1_generated_InstanceGroups_AggregatedList_sync", "segments": [ { - "end": 54, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 52, "start": 27, "type": "SHORT" }, @@ -16066,22 +16078,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 51, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_list_instances_sync.py" + "title": "compute_v1_generated_instance_groups_aggregated_list_sync.py" }, { "canonical": true, @@ -16090,19 +16102,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupsClient", "shortName": "InstanceGroupsClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.list", + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.delete", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.List", + "fullName": "google.cloud.compute.v1.InstanceGroups.Delete", "service": { "fullName": "google.cloud.compute.v1.InstanceGroups", "shortName": "InstanceGroups" }, - "shortName": "List" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListInstanceGroupsRequest" + "type": "google.cloud.compute_v1.types.DeleteInstanceGroupRequest" }, { "name": "project", @@ -16112,6 +16124,10 @@ "name": "zone", "type": "str" }, + { + "name": "instance_group", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -16122,17 +16138,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" }, - "description": "Sample for List", - "file": "compute_v1_generated_instance_groups_list_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_instance_groups_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_List_sync", + "regionTag": "compute_v1_generated_InstanceGroups_Delete_sync", "segments": [ { "end": 53, @@ -16150,22 +16166,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_instance_groups_list_sync.py" + "title": "compute_v1_generated_instance_groups_delete_sync.py" }, { "canonical": true, @@ -16174,19 +16190,19 @@ "fullName": "google.cloud.compute_v1.InstanceGroupsClient", "shortName": "InstanceGroupsClient" }, - "fullName": "google.cloud.compute_v1.InstanceGroupsClient.remove_instances", + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.get", "method": { - "fullName": "google.cloud.compute.v1.InstanceGroups.RemoveInstances", + "fullName": "google.cloud.compute.v1.InstanceGroups.Get", "service": { "fullName": "google.cloud.compute.v1.InstanceGroups", "shortName": "InstanceGroups" }, - "shortName": "RemoveInstances" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.RemoveInstancesInstanceGroupRequest" + "type": "google.cloud.compute_v1.types.GetInstanceGroupRequest" }, { "name": "project", @@ -16200,10 +16216,6 @@ "name": "instance_group", "type": "str" }, - { - "name": "instance_groups_remove_instances_request_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupsRemoveInstancesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -16214,17 +16226,373 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "remove_instances" + "resultType": "google.cloud.compute_v1.types.InstanceGroup", + "shortName": "get" }, - "description": "Sample for RemoveInstances", - "file": "compute_v1_generated_instance_groups_remove_instances_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_instance_groups_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_InstanceGroups_RemoveInstances_sync", + "regionTag": "compute_v1_generated_InstanceGroups_Get_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_instance_groups_get_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.InstanceGroupsClient", + "shortName": "InstanceGroupsClient" + }, + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.insert", + "method": { + "fullName": "google.cloud.compute.v1.InstanceGroups.Insert", + "service": { + "fullName": "google.cloud.compute.v1.InstanceGroups", + "shortName": "InstanceGroups" + }, + "shortName": "Insert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.InsertInstanceGroupRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" + }, + { + "name": "instance_group_resource", + "type": "google.cloud.compute_v1.types.InstanceGroup" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" + }, + "description": "Sample for Insert", + "file": "compute_v1_generated_instance_groups_insert_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_InstanceGroups_Insert_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_instance_groups_insert_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.InstanceGroupsClient", + "shortName": "InstanceGroupsClient" + }, + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.list_instances", + "method": { + "fullName": "google.cloud.compute.v1.InstanceGroups.ListInstances", + "service": { + "fullName": "google.cloud.compute.v1.InstanceGroups", + "shortName": "InstanceGroups" + }, + "shortName": "ListInstances" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.ListInstancesInstanceGroupsRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" + }, + { + "name": "instance_group", + "type": "str" + }, + { + "name": "instance_groups_list_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupsListInstancesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.ListInstancesPager", + "shortName": "list_instances" + }, + "description": "Sample for ListInstances", + "file": "compute_v1_generated_instance_groups_list_instances_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_InstanceGroups_ListInstances_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_instance_groups_list_instances_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.InstanceGroupsClient", + "shortName": "InstanceGroupsClient" + }, + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.list", + "method": { + "fullName": "google.cloud.compute.v1.InstanceGroups.List", + "service": { + "fullName": "google.cloud.compute.v1.InstanceGroups", + "shortName": "InstanceGroups" + }, + "shortName": "List" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.ListInstanceGroupsRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.services.instance_groups.pagers.ListPager", + "shortName": "list" + }, + "description": "Sample for List", + "file": "compute_v1_generated_instance_groups_list_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_InstanceGroups_List_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_instance_groups_list_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.InstanceGroupsClient", + "shortName": "InstanceGroupsClient" + }, + "fullName": "google.cloud.compute_v1.InstanceGroupsClient.remove_instances", + "method": { + "fullName": "google.cloud.compute.v1.InstanceGroups.RemoveInstances", + "service": { + "fullName": "google.cloud.compute.v1.InstanceGroups", + "shortName": "InstanceGroups" + }, + "shortName": "RemoveInstances" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.RemoveInstancesInstanceGroupRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" + }, + { + "name": "instance_group", + "type": "str" + }, + { + "name": "instance_groups_remove_instances_request_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupsRemoveInstancesRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "remove_instances" + }, + "description": "Sample for RemoveInstances", + "file": "compute_v1_generated_instance_groups_remove_instances_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_InstanceGroups_RemoveInstances_sync", "segments": [ { "end": 53, @@ -16306,7 +16674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -16390,7 +16758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceSettings", @@ -16478,7 +16846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -16558,7 +16926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_templates.pagers.AggregatedListPager", @@ -16642,7 +17010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -16726,7 +17094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -16810,7 +17178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceTemplate", @@ -16894,7 +17262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -16974,7 +17342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instance_templates.pagers.ListPager", @@ -17062,7 +17430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -17150,7 +17518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -17246,7 +17614,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17338,7 +17706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17418,7 +17786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instances.pagers.AggregatedListPager", @@ -17510,7 +17878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17598,7 +17966,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17694,7 +18062,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17782,7 +18150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17874,7 +18242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -17966,7 +18334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstancesGetEffectiveFirewallsResponse", @@ -18054,7 +18422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.GuestAttributes", @@ -18142,7 +18510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -18230,7 +18598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Screenshot", @@ -18318,7 +18686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SerialPortOutput", @@ -18406,7 +18774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ShieldedInstanceIdentity", @@ -18494,7 +18862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Instance", @@ -18582,7 +18950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -18670,7 +19038,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instances.pagers.ListReferrersPager", @@ -18754,7 +19122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instances.pagers.ListPager", @@ -18842,7 +19210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -18934,7 +19302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19022,7 +19390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19110,7 +19478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19198,7 +19566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SendDiagnosticInterruptInstanceResponse", @@ -19286,7 +19654,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19382,7 +19750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19474,7 +19842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -19566,7 +19934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19658,7 +20026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19750,7 +20118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19842,7 +20210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -19934,7 +20302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20026,7 +20394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20118,7 +20486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20210,7 +20578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20302,7 +20670,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20394,7 +20762,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20486,7 +20854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20574,7 +20942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20666,7 +21034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20754,7 +21122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20842,7 +21210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -20930,7 +21298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21022,7 +21390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -21118,7 +21486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21210,7 +21578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21306,7 +21674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21398,7 +21766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21490,7 +21858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21570,7 +21938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instant_snapshots.pagers.AggregatedListPager", @@ -21658,7 +22026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -21746,7 +22114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -21834,7 +22202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstantSnapshot", @@ -21922,7 +22290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22006,7 +22374,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.instant_snapshots.pagers.ListPager", @@ -22098,7 +22466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -22190,7 +22558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22282,7 +22650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -22362,7 +22730,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.interconnect_attachments.pagers.AggregatedListPager", @@ -22450,7 +22818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22538,7 +22906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InterconnectAttachment", @@ -22626,7 +22994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22710,7 +23078,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.interconnect_attachments.pagers.ListPager", @@ -22802,7 +23170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22894,7 +23262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -22978,7 +23346,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InterconnectLocation", @@ -23058,7 +23426,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.interconnect_locations.pagers.ListPager", @@ -23142,7 +23510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InterconnectRemoteLocation", @@ -23222,7 +23590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.interconnect_remote_locations.pagers.ListPager", @@ -23306,7 +23674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -23390,7 +23758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InterconnectsGetDiagnosticsResponse", @@ -23474,7 +23842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InterconnectsGetMacsecConfigResponse", @@ -23558,7 +23926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Interconnect", @@ -23642,7 +24010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -23722,7 +24090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.interconnects.pagers.ListPager", @@ -23810,7 +24178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -23898,7 +24266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -23982,7 +24350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.LicenseCode", @@ -24070,7 +24438,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -24154,7 +24522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -24238,7 +24606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -24322,7 +24690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.License", @@ -24406,7 +24774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -24486,7 +24854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.licenses.pagers.ListPager", @@ -24574,7 +24942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -24662,7 +25030,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -24746,7 +25114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -24830,7 +25198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -24914,7 +25282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.MachineImage", @@ -24998,7 +25366,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -25078,7 +25446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.machine_images.pagers.ListPager", @@ -25166,7 +25534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -25254,7 +25622,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -25334,7 +25702,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.machine_types.pagers.AggregatedListPager", @@ -25422,7 +25790,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.MachineType", @@ -25506,7 +25874,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.machine_types.pagers.ListPager", @@ -25586,7 +25954,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_attachments.pagers.AggregatedListPager", @@ -25674,7 +26042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -25762,7 +26130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -25850,7 +26218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NetworkAttachment", @@ -25938,7 +26306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26022,7 +26390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_attachments.pagers.ListPager", @@ -26114,7 +26482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26206,7 +26574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -26298,7 +26666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -26378,7 +26746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_edge_security_services.pagers.AggregatedListPager", @@ -26466,7 +26834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26554,7 +26922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NetworkEdgeSecurityService", @@ -26642,7 +27010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26734,7 +27102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26814,7 +27182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_endpoint_groups.pagers.AggregatedListPager", @@ -26906,7 +27274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -26994,7 +27362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27086,7 +27454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27174,7 +27542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NetworkEndpointGroup", @@ -27262,7 +27630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27354,7 +27722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_endpoint_groups.pagers.ListNetworkEndpointsPager", @@ -27438,7 +27806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_endpoint_groups.pagers.ListPager", @@ -27530,7 +27898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -27618,7 +27986,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27706,7 +28074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27790,7 +28158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27874,7 +28242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -27958,7 +28326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyAssociation", @@ -28042,7 +28410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -28126,7 +28494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyRule", @@ -28210,7 +28578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicy", @@ -28294,7 +28662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -28374,7 +28742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.network_firewall_policies.pagers.ListPager", @@ -28462,7 +28830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -28550,7 +28918,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -28634,7 +29002,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -28718,7 +29086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -28806,7 +29174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -28894,7 +29262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -28943,35 +29311,31 @@ "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.NetworksClient", - "shortName": "NetworksClient" + "fullName": "google.cloud.compute_v1.NetworkProfilesClient", + "shortName": "NetworkProfilesClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.add_peering", + "fullName": "google.cloud.compute_v1.NetworkProfilesClient.get", "method": { - "fullName": "google.cloud.compute.v1.Networks.AddPeering", + "fullName": "google.cloud.compute.v1.NetworkProfiles.Get", "service": { - "fullName": "google.cloud.compute.v1.Networks", - "shortName": "Networks" + "fullName": "google.cloud.compute.v1.NetworkProfiles", + "shortName": "NetworkProfiles" }, - "shortName": "AddPeering" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AddPeeringNetworkRequest" + "type": "google.cloud.compute_v1.types.GetNetworkProfileRequest" }, { "name": "project", "type": "str" }, { - "name": "network", + "name": "network_profile", "type": "str" }, - { - "name": "networks_add_peering_request_resource", - "type": "google.cloud.compute_v1.types.NetworksAddPeeringRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -28982,17 +29346,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "add_peering" + "resultType": "google.cloud.compute_v1.types.NetworkProfile", + "shortName": "get" }, - "description": "Sample for AddPeering", - "file": "compute_v1_generated_networks_add_peering_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_network_profiles_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_AddPeering_sync", + "regionTag": "compute_v1_generated_NetworkProfiles_Get_sync", "segments": [ { "end": 52, @@ -29025,37 +29389,33 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_add_peering_sync.py" + "title": "compute_v1_generated_network_profiles_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.NetworksClient", - "shortName": "NetworksClient" + "fullName": "google.cloud.compute_v1.NetworkProfilesClient", + "shortName": "NetworkProfilesClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.delete", + "fullName": "google.cloud.compute_v1.NetworkProfilesClient.list", "method": { - "fullName": "google.cloud.compute.v1.Networks.Delete", + "fullName": "google.cloud.compute.v1.NetworkProfiles.List", "service": { - "fullName": "google.cloud.compute.v1.Networks", - "shortName": "Networks" + "fullName": "google.cloud.compute.v1.NetworkProfiles", + "shortName": "NetworkProfiles" }, - "shortName": "Delete" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteNetworkRequest" + "type": "google.cloud.compute_v1.types.ListNetworkProfilesRequest" }, { "name": "project", "type": "str" }, - { - "name": "network", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29066,17 +29426,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "resultType": "google.cloud.compute_v1.services.network_profiles.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_networks_delete_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_network_profiles_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_Delete_sync", + "regionTag": "compute_v1_generated_NetworkProfiles_List_sync", "segments": [ { "end": 52, @@ -29094,22 +29454,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 50, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_delete_sync.py" + "title": "compute_v1_generated_network_profiles_list_sync.py" }, { "canonical": true, @@ -29118,19 +29478,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.get_effective_firewalls", + "fullName": "google.cloud.compute_v1.NetworksClient.add_peering", "method": { - "fullName": "google.cloud.compute.v1.Networks.GetEffectiveFirewalls", + "fullName": "google.cloud.compute.v1.Networks.AddPeering", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "GetEffectiveFirewalls" + "shortName": "AddPeering" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetEffectiveFirewallsNetworkRequest" + "type": "google.cloud.compute_v1.types.AddPeeringNetworkRequest" }, { "name": "project", @@ -29140,6 +29500,10 @@ "name": "network", "type": "str" }, + { + "name": "networks_add_peering_request_resource", + "type": "google.cloud.compute_v1.types.NetworksAddPeeringRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29150,17 +29514,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.NetworksGetEffectiveFirewallsResponse", - "shortName": "get_effective_firewalls" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "add_peering" }, - "description": "Sample for GetEffectiveFirewalls", - "file": "compute_v1_generated_networks_get_effective_firewalls_sync.py", + "description": "Sample for AddPeering", + "file": "compute_v1_generated_networks_add_peering_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_GetEffectiveFirewalls_sync", + "regionTag": "compute_v1_generated_Networks_AddPeering_sync", "segments": [ { "end": 52, @@ -29193,7 +29557,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_get_effective_firewalls_sync.py" + "title": "compute_v1_generated_networks_add_peering_sync.py" }, { "canonical": true, @@ -29202,19 +29566,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.get", + "fullName": "google.cloud.compute_v1.NetworksClient.delete", "method": { - "fullName": "google.cloud.compute.v1.Networks.Get", + "fullName": "google.cloud.compute.v1.Networks.Delete", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "Get" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetNetworkRequest" + "type": "google.cloud.compute_v1.types.DeleteNetworkRequest" }, { "name": "project", @@ -29234,17 +29598,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Network", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" }, - "description": "Sample for Get", - "file": "compute_v1_generated_networks_get_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_networks_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_Get_sync", + "regionTag": "compute_v1_generated_Networks_Delete_sync", "segments": [ { "end": 52, @@ -29277,7 +29641,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_get_sync.py" + "title": "compute_v1_generated_networks_delete_sync.py" }, { "canonical": true, @@ -29286,27 +29650,27 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.insert", + "fullName": "google.cloud.compute_v1.NetworksClient.get_effective_firewalls", "method": { - "fullName": "google.cloud.compute.v1.Networks.Insert", + "fullName": "google.cloud.compute.v1.Networks.GetEffectiveFirewalls", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "Insert" + "shortName": "GetEffectiveFirewalls" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertNetworkRequest" + "type": "google.cloud.compute_v1.types.GetEffectiveFirewallsNetworkRequest" }, { "name": "project", "type": "str" }, { - "name": "network_resource", - "type": "google.cloud.compute_v1.types.Network" + "name": "network", + "type": "str" }, { "name": "retry", @@ -29318,25 +29682,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "resultType": "google.cloud.compute_v1.types.NetworksGetEffectiveFirewallsResponse", + "shortName": "get_effective_firewalls" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_networks_insert_sync.py", + "description": "Sample for GetEffectiveFirewalls", + "file": "compute_v1_generated_networks_get_effective_firewalls_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_Insert_sync", + "regionTag": "compute_v1_generated_Networks_GetEffectiveFirewalls_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -29346,22 +29710,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_insert_sync.py" + "title": "compute_v1_generated_networks_get_effective_firewalls_sync.py" }, { "canonical": true, @@ -29370,19 +29734,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.list_peering_routes", + "fullName": "google.cloud.compute_v1.NetworksClient.get", "method": { - "fullName": "google.cloud.compute.v1.Networks.ListPeeringRoutes", + "fullName": "google.cloud.compute.v1.Networks.Get", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "ListPeeringRoutes" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListPeeringRoutesNetworksRequest" + "type": "google.cloud.compute_v1.types.GetNetworkRequest" }, { "name": "project", @@ -29402,25 +29766,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.networks.pagers.ListPeeringRoutesPager", - "shortName": "list_peering_routes" + "resultType": "google.cloud.compute_v1.types.Network", + "shortName": "get" }, - "description": "Sample for ListPeeringRoutes", - "file": "compute_v1_generated_networks_list_peering_routes_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_networks_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_ListPeeringRoutes_sync", + "regionTag": "compute_v1_generated_Networks_Get_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -29440,12 +29804,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 53, "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_list_peering_routes_sync.py" + "title": "compute_v1_generated_networks_get_sync.py" }, { "canonical": true, @@ -29454,24 +29818,28 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.list", + "fullName": "google.cloud.compute_v1.NetworksClient.insert", "method": { - "fullName": "google.cloud.compute.v1.Networks.List", + "fullName": "google.cloud.compute.v1.Networks.Insert", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "List" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListNetworksRequest" + "type": "google.cloud.compute_v1.types.InsertNetworkRequest" }, { "name": "project", "type": "str" }, + { + "name": "network_resource", + "type": "google.cloud.compute_v1.types.Network" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29482,25 +29850,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.networks.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" }, - "description": "Sample for List", - "file": "compute_v1_generated_networks_list_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_networks_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_List_sync", + "regionTag": "compute_v1_generated_Networks_Insert_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -29520,12 +29888,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_list_sync.py" + "title": "compute_v1_generated_networks_insert_sync.py" }, { "canonical": true, @@ -29534,19 +29902,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.patch", + "fullName": "google.cloud.compute_v1.NetworksClient.list_peering_routes", "method": { - "fullName": "google.cloud.compute.v1.Networks.Patch", + "fullName": "google.cloud.compute.v1.Networks.ListPeeringRoutes", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "Patch" + "shortName": "ListPeeringRoutes" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchNetworkRequest" + "type": "google.cloud.compute_v1.types.ListPeeringRoutesNetworksRequest" }, { "name": "project", @@ -29556,10 +29924,6 @@ "name": "network", "type": "str" }, - { - "name": "network_resource", - "type": "google.cloud.compute_v1.types.Network" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29570,25 +29934,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "resultType": "google.cloud.compute_v1.services.networks.pagers.ListPeeringRoutesPager", + "shortName": "list_peering_routes" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_networks_patch_sync.py", + "description": "Sample for ListPeeringRoutes", + "file": "compute_v1_generated_networks_list_peering_routes_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_Patch_sync", + "regionTag": "compute_v1_generated_Networks_ListPeeringRoutes_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -29608,12 +29972,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 54, "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_patch_sync.py" + "title": "compute_v1_generated_networks_list_peering_routes_sync.py" }, { "canonical": true, @@ -29622,32 +29986,24 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.remove_peering", + "fullName": "google.cloud.compute_v1.NetworksClient.list", "method": { - "fullName": "google.cloud.compute.v1.Networks.RemovePeering", + "fullName": "google.cloud.compute.v1.Networks.List", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "RemovePeering" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.RemovePeeringNetworkRequest" + "type": "google.cloud.compute_v1.types.ListNetworksRequest" }, { "name": "project", "type": "str" }, - { - "name": "network", - "type": "str" - }, - { - "name": "networks_remove_peering_request_resource", - "type": "google.cloud.compute_v1.types.NetworksRemovePeeringRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29658,17 +30014,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "remove_peering" + "resultType": "google.cloud.compute_v1.services.networks.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for RemovePeering", - "file": "compute_v1_generated_networks_remove_peering_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_networks_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_RemovePeering_sync", + "regionTag": "compute_v1_generated_Networks_List_sync", "segments": [ { "end": 52, @@ -29686,22 +30042,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 50, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_remove_peering_sync.py" + "title": "compute_v1_generated_networks_list_sync.py" }, { "canonical": true, @@ -29710,19 +30066,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.switch_to_custom_mode", + "fullName": "google.cloud.compute_v1.NetworksClient.patch", "method": { - "fullName": "google.cloud.compute.v1.Networks.SwitchToCustomMode", + "fullName": "google.cloud.compute.v1.Networks.Patch", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "SwitchToCustomMode" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SwitchToCustomModeNetworkRequest" + "type": "google.cloud.compute_v1.types.PatchNetworkRequest" }, { "name": "project", @@ -29732,6 +30088,10 @@ "name": "network", "type": "str" }, + { + "name": "network_resource", + "type": "google.cloud.compute_v1.types.Network" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29742,17 +30102,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "switch_to_custom_mode" + "shortName": "patch" }, - "description": "Sample for SwitchToCustomMode", - "file": "compute_v1_generated_networks_switch_to_custom_mode_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_networks_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_SwitchToCustomMode_sync", + "regionTag": "compute_v1_generated_Networks_Patch_sync", "segments": [ { "end": 52, @@ -29785,7 +30145,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_switch_to_custom_mode_sync.py" + "title": "compute_v1_generated_networks_patch_sync.py" }, { "canonical": true, @@ -29794,19 +30154,19 @@ "fullName": "google.cloud.compute_v1.NetworksClient", "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NetworksClient.update_peering", + "fullName": "google.cloud.compute_v1.NetworksClient.remove_peering", "method": { - "fullName": "google.cloud.compute.v1.Networks.UpdatePeering", + "fullName": "google.cloud.compute.v1.Networks.RemovePeering", "service": { "fullName": "google.cloud.compute.v1.Networks", "shortName": "Networks" }, - "shortName": "UpdatePeering" + "shortName": "RemovePeering" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdatePeeringNetworkRequest" + "type": "google.cloud.compute_v1.types.RemovePeeringNetworkRequest" }, { "name": "project", @@ -29817,8 +30177,8 @@ "type": "str" }, { - "name": "networks_update_peering_request_resource", - "type": "google.cloud.compute_v1.types.NetworksUpdatePeeringRequest" + "name": "networks_remove_peering_request_resource", + "type": "google.cloud.compute_v1.types.NetworksRemovePeeringRequest" }, { "name": "retry", @@ -29830,17 +30190,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update_peering" + "shortName": "remove_peering" }, - "description": "Sample for UpdatePeering", - "file": "compute_v1_generated_networks_update_peering_sync.py", + "description": "Sample for RemovePeering", + "file": "compute_v1_generated_networks_remove_peering_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_Networks_UpdatePeering_sync", + "regionTag": "compute_v1_generated_Networks_RemovePeering_sync", "segments": [ { "end": 52, @@ -29873,45 +30233,37 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_networks_update_peering_sync.py" + "title": "compute_v1_generated_networks_remove_peering_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.NodeGroupsClient", - "shortName": "NodeGroupsClient" + "fullName": "google.cloud.compute_v1.NetworksClient", + "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.add_nodes", + "fullName": "google.cloud.compute_v1.NetworksClient.switch_to_custom_mode", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.AddNodes", + "fullName": "google.cloud.compute.v1.Networks.SwitchToCustomMode", "service": { - "fullName": "google.cloud.compute.v1.NodeGroups", - "shortName": "NodeGroups" + "fullName": "google.cloud.compute.v1.Networks", + "shortName": "Networks" }, - "shortName": "AddNodes" + "shortName": "SwitchToCustomMode" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AddNodesNodeGroupRequest" + "type": "google.cloud.compute_v1.types.SwitchToCustomModeNetworkRequest" }, { "name": "project", "type": "str" }, { - "name": "zone", - "type": "str" - }, - { - "name": "node_group", + "name": "network", "type": "str" }, - { - "name": "node_groups_add_nodes_request_resource", - "type": "google.cloud.compute_v1.types.NodeGroupsAddNodesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -29922,25 +30274,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "add_nodes" + "shortName": "switch_to_custom_mode" }, - "description": "Sample for AddNodes", - "file": "compute_v1_generated_node_groups_add_nodes_sync.py", + "description": "Sample for SwitchToCustomMode", + "file": "compute_v1_generated_networks_switch_to_custom_mode_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_AddNodes_sync", + "regionTag": "compute_v1_generated_Networks_SwitchToCustomMode_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -29950,48 +30302,56 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_add_nodes_sync.py" + "title": "compute_v1_generated_networks_switch_to_custom_mode_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.NodeGroupsClient", - "shortName": "NodeGroupsClient" + "fullName": "google.cloud.compute_v1.NetworksClient", + "shortName": "NetworksClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.aggregated_list", + "fullName": "google.cloud.compute_v1.NetworksClient.update_peering", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.AggregatedList", + "fullName": "google.cloud.compute.v1.Networks.UpdatePeering", "service": { - "fullName": "google.cloud.compute.v1.NodeGroups", - "shortName": "NodeGroups" + "fullName": "google.cloud.compute.v1.Networks", + "shortName": "Networks" }, - "shortName": "AggregatedList" + "shortName": "UpdatePeering" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AggregatedListNodeGroupsRequest" + "type": "google.cloud.compute_v1.types.UpdatePeeringNetworkRequest" }, { "name": "project", "type": "str" }, + { + "name": "network", + "type": "str" + }, + { + "name": "networks_update_peering_request_resource", + "type": "google.cloud.compute_v1.types.NetworksUpdatePeeringRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -30002,17 +30362,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.node_groups.pagers.AggregatedListPager", - "shortName": "aggregated_list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "update_peering" }, - "description": "Sample for AggregatedList", - "file": "compute_v1_generated_node_groups_aggregated_list_sync.py", + "description": "Sample for UpdatePeering", + "file": "compute_v1_generated_networks_update_peering_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_AggregatedList_sync", + "regionTag": "compute_v1_generated_Networks_UpdatePeering_sync", "segments": [ { "end": 52, @@ -30030,22 +30390,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 49, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_aggregated_list_sync.py" + "title": "compute_v1_generated_networks_update_peering_sync.py" }, { "canonical": true, @@ -30054,19 +30414,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.delete_nodes", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.add_nodes", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.DeleteNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.AddNodes", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "DeleteNodes" + "shortName": "AddNodes" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteNodesNodeGroupRequest" + "type": "google.cloud.compute_v1.types.AddNodesNodeGroupRequest" }, { "name": "project", @@ -30081,8 +30441,8 @@ "type": "str" }, { - "name": "node_groups_delete_nodes_request_resource", - "type": "google.cloud.compute_v1.types.NodeGroupsDeleteNodesRequest" + "name": "node_groups_add_nodes_request_resource", + "type": "google.cloud.compute_v1.types.NodeGroupsAddNodesRequest" }, { "name": "retry", @@ -30094,17 +30454,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete_nodes" + "shortName": "add_nodes" }, - "description": "Sample for DeleteNodes", - "file": "compute_v1_generated_node_groups_delete_nodes_sync.py", + "description": "Sample for AddNodes", + "file": "compute_v1_generated_node_groups_add_nodes_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_DeleteNodes_sync", + "regionTag": "compute_v1_generated_NodeGroups_AddNodes_sync", "segments": [ { "end": 53, @@ -30137,7 +30497,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_delete_nodes_sync.py" + "title": "compute_v1_generated_node_groups_add_nodes_sync.py" }, { "canonical": true, @@ -30146,32 +30506,24 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.delete", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.aggregated_list", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.Delete", + "fullName": "google.cloud.compute.v1.NodeGroups.AggregatedList", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "Delete" + "shortName": "AggregatedList" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteNodeGroupRequest" + "type": "google.cloud.compute_v1.types.AggregatedListNodeGroupsRequest" }, { "name": "project", "type": "str" }, - { - "name": "zone", - "type": "str" - }, - { - "name": "node_group", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -30182,25 +30534,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "resultType": "google.cloud.compute_v1.services.node_groups.pagers.AggregatedListPager", + "shortName": "aggregated_list" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_node_groups_delete_sync.py", + "description": "Sample for AggregatedList", + "file": "compute_v1_generated_node_groups_aggregated_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_Delete_sync", + "regionTag": "compute_v1_generated_NodeGroups_AggregatedList_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -30210,22 +30562,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_delete_sync.py" + "title": "compute_v1_generated_node_groups_aggregated_list_sync.py" }, { "canonical": true, @@ -30234,19 +30586,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.get_iam_policy", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.delete_nodes", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.GetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.DeleteNodes", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "GetIamPolicy" + "shortName": "DeleteNodes" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetIamPolicyNodeGroupRequest" + "type": "google.cloud.compute_v1.types.DeleteNodesNodeGroupRequest" }, { "name": "project", @@ -30257,9 +30609,13 @@ "type": "str" }, { - "name": "resource", + "name": "node_group", "type": "str" }, + { + "name": "node_groups_delete_nodes_request_resource", + "type": "google.cloud.compute_v1.types.NodeGroupsDeleteNodesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -30270,17 +30626,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "get_iam_policy" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete_nodes" }, - "description": "Sample for GetIamPolicy", - "file": "compute_v1_generated_node_groups_get_iam_policy_sync.py", + "description": "Sample for DeleteNodes", + "file": "compute_v1_generated_node_groups_delete_nodes_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_GetIamPolicy_sync", + "regionTag": "compute_v1_generated_NodeGroups_DeleteNodes_sync", "segments": [ { "end": 53, @@ -30313,7 +30669,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_get_iam_policy_sync.py" + "title": "compute_v1_generated_node_groups_delete_nodes_sync.py" }, { "canonical": true, @@ -30322,19 +30678,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.get", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.delete", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.Get", + "fullName": "google.cloud.compute.v1.NodeGroups.Delete", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "Get" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetNodeGroupRequest" + "type": "google.cloud.compute_v1.types.DeleteNodeGroupRequest" }, { "name": "project", @@ -30358,17 +30714,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.NodeGroup", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" }, - "description": "Sample for Get", - "file": "compute_v1_generated_node_groups_get_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_node_groups_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_Get_sync", + "regionTag": "compute_v1_generated_NodeGroups_Delete_sync", "segments": [ { "end": 53, @@ -30401,7 +30757,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_get_sync.py" + "title": "compute_v1_generated_node_groups_delete_sync.py" }, { "canonical": true, @@ -30410,19 +30766,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.insert", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.get_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.Insert", + "fullName": "google.cloud.compute.v1.NodeGroups.GetIamPolicy", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "Insert" + "shortName": "GetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertNodeGroupRequest" + "type": "google.cloud.compute_v1.types.GetIamPolicyNodeGroupRequest" }, { "name": "project", @@ -30433,12 +30789,8 @@ "type": "str" }, { - "name": "initial_node_count", - "type": "int" - }, - { - "name": "node_group_resource", - "type": "google.cloud.compute_v1.types.NodeGroup" + "name": "resource", + "type": "str" }, { "name": "retry", @@ -30450,17 +30802,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "resultType": "google.cloud.compute_v1.types.Policy", + "shortName": "get_iam_policy" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_node_groups_insert_sync.py", + "description": "Sample for GetIamPolicy", + "file": "compute_v1_generated_node_groups_get_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_Insert_sync", + "regionTag": "compute_v1_generated_NodeGroups_GetIamPolicy_sync", "segments": [ { "end": 53, @@ -30493,7 +30845,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_insert_sync.py" + "title": "compute_v1_generated_node_groups_get_iam_policy_sync.py" }, { "canonical": true, @@ -30502,19 +30854,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.list_nodes", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.get", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.ListNodes", + "fullName": "google.cloud.compute.v1.NodeGroups.Get", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "ListNodes" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListNodesNodeGroupsRequest" + "type": "google.cloud.compute_v1.types.GetNodeGroupRequest" }, { "name": "project", @@ -30538,25 +30890,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.node_groups.pagers.ListNodesPager", - "shortName": "list_nodes" + "resultType": "google.cloud.compute_v1.types.NodeGroup", + "shortName": "get" }, - "description": "Sample for ListNodes", - "file": "compute_v1_generated_node_groups_list_nodes_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_node_groups_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_ListNodes_sync", + "regionTag": "compute_v1_generated_NodeGroups_Get_sync", "segments": [ { - "end": 54, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 53, "start": 27, "type": "SHORT" }, @@ -30576,12 +30928,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 55, + "end": 54, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_list_nodes_sync.py" + "title": "compute_v1_generated_node_groups_get_sync.py" }, { "canonical": true, @@ -30590,19 +30942,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.list", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.insert", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.List", + "fullName": "google.cloud.compute.v1.NodeGroups.Insert", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "List" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListNodeGroupsRequest" + "type": "google.cloud.compute_v1.types.InsertNodeGroupRequest" }, { "name": "project", @@ -30612,6 +30964,14 @@ "name": "zone", "type": "str" }, + { + "name": "initial_node_count", + "type": "int" + }, + { + "name": "node_group_resource", + "type": "google.cloud.compute_v1.types.NodeGroup" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -30622,17 +30982,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.node_groups.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" }, - "description": "Sample for List", - "file": "compute_v1_generated_node_groups_list_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_node_groups_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_List_sync", + "regionTag": "compute_v1_generated_NodeGroups_Insert_sync", "segments": [ { "end": 53, @@ -30650,22 +31010,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_list_sync.py" + "title": "compute_v1_generated_node_groups_insert_sync.py" }, { "canonical": true, @@ -30674,19 +31034,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.patch", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.list_nodes", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.Patch", + "fullName": "google.cloud.compute.v1.NodeGroups.ListNodes", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "Patch" + "shortName": "ListNodes" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchNodeGroupRequest" + "type": "google.cloud.compute_v1.types.ListNodesNodeGroupsRequest" }, { "name": "project", @@ -30701,8 +31061,88 @@ "type": "str" }, { - "name": "node_group_resource", - "type": "google.cloud.compute_v1.types.NodeGroup" + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.services.node_groups.pagers.ListNodesPager", + "shortName": "list_nodes" + }, + "description": "Sample for ListNodes", + "file": "compute_v1_generated_node_groups_list_nodes_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_NodeGroups_ListNodes_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_node_groups_list_nodes_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.NodeGroupsClient", + "shortName": "NodeGroupsClient" + }, + "fullName": "google.cloud.compute_v1.NodeGroupsClient.list", + "method": { + "fullName": "google.cloud.compute.v1.NodeGroups.List", + "service": { + "fullName": "google.cloud.compute.v1.NodeGroups", + "shortName": "NodeGroups" + }, + "shortName": "List" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.ListNodeGroupsRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" }, { "name": "retry", @@ -30714,17 +31154,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "resultType": "google.cloud.compute_v1.services.node_groups.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_node_groups_patch_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_node_groups_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_Patch_sync", + "regionTag": "compute_v1_generated_NodeGroups_List_sync", "segments": [ { "end": 53, @@ -30742,22 +31182,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_patch_sync.py" + "title": "compute_v1_generated_node_groups_list_sync.py" }, { "canonical": true, @@ -30766,19 +31206,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.perform_maintenance", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.patch", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.PerformMaintenance", + "fullName": "google.cloud.compute.v1.NodeGroups.Patch", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "PerformMaintenance" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PerformMaintenanceNodeGroupRequest" + "type": "google.cloud.compute_v1.types.PatchNodeGroupRequest" }, { "name": "project", @@ -30793,8 +31233,8 @@ "type": "str" }, { - "name": "node_groups_perform_maintenance_request_resource", - "type": "google.cloud.compute_v1.types.NodeGroupsPerformMaintenanceRequest" + "name": "node_group_resource", + "type": "google.cloud.compute_v1.types.NodeGroup" }, { "name": "retry", @@ -30806,17 +31246,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "perform_maintenance" + "shortName": "patch" }, - "description": "Sample for PerformMaintenance", - "file": "compute_v1_generated_node_groups_perform_maintenance_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_node_groups_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_PerformMaintenance_sync", + "regionTag": "compute_v1_generated_NodeGroups_Patch_sync", "segments": [ { "end": 53, @@ -30849,7 +31289,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_perform_maintenance_sync.py" + "title": "compute_v1_generated_node_groups_patch_sync.py" }, { "canonical": true, @@ -30858,19 +31298,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.set_iam_policy", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.perform_maintenance", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.SetIamPolicy", + "fullName": "google.cloud.compute.v1.NodeGroups.PerformMaintenance", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "SetIamPolicy" + "shortName": "PerformMaintenance" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetIamPolicyNodeGroupRequest" + "type": "google.cloud.compute_v1.types.PerformMaintenanceNodeGroupRequest" }, { "name": "project", @@ -30881,12 +31321,12 @@ "type": "str" }, { - "name": "resource", + "name": "node_group", "type": "str" }, { - "name": "zone_set_policy_request_resource", - "type": "google.cloud.compute_v1.types.ZoneSetPolicyRequest" + "name": "node_groups_perform_maintenance_request_resource", + "type": "google.cloud.compute_v1.types.NodeGroupsPerformMaintenanceRequest" }, { "name": "retry", @@ -30898,17 +31338,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "set_iam_policy" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "perform_maintenance" }, - "description": "Sample for SetIamPolicy", - "file": "compute_v1_generated_node_groups_set_iam_policy_sync.py", + "description": "Sample for PerformMaintenance", + "file": "compute_v1_generated_node_groups_perform_maintenance_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_SetIamPolicy_sync", + "regionTag": "compute_v1_generated_NodeGroups_PerformMaintenance_sync", "segments": [ { "end": 53, @@ -30941,7 +31381,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_set_iam_policy_sync.py" + "title": "compute_v1_generated_node_groups_perform_maintenance_sync.py" }, { "canonical": true, @@ -30950,19 +31390,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.set_node_template", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.set_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.SetNodeTemplate", + "fullName": "google.cloud.compute.v1.NodeGroups.SetIamPolicy", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "SetNodeTemplate" + "shortName": "SetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetNodeTemplateNodeGroupRequest" + "type": "google.cloud.compute_v1.types.SetIamPolicyNodeGroupRequest" }, { "name": "project", @@ -30973,12 +31413,12 @@ "type": "str" }, { - "name": "node_group", + "name": "resource", "type": "str" }, { - "name": "node_groups_set_node_template_request_resource", - "type": "google.cloud.compute_v1.types.NodeGroupsSetNodeTemplateRequest" + "name": "zone_set_policy_request_resource", + "type": "google.cloud.compute_v1.types.ZoneSetPolicyRequest" }, { "name": "retry", @@ -30990,17 +31430,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_node_template" + "resultType": "google.cloud.compute_v1.types.Policy", + "shortName": "set_iam_policy" }, - "description": "Sample for SetNodeTemplate", - "file": "compute_v1_generated_node_groups_set_node_template_sync.py", + "description": "Sample for SetIamPolicy", + "file": "compute_v1_generated_node_groups_set_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_SetNodeTemplate_sync", + "regionTag": "compute_v1_generated_NodeGroups_SetIamPolicy_sync", "segments": [ { "end": 53, @@ -31033,7 +31473,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_node_groups_set_node_template_sync.py" + "title": "compute_v1_generated_node_groups_set_iam_policy_sync.py" }, { "canonical": true, @@ -31042,19 +31482,19 @@ "fullName": "google.cloud.compute_v1.NodeGroupsClient", "shortName": "NodeGroupsClient" }, - "fullName": "google.cloud.compute_v1.NodeGroupsClient.simulate_maintenance_event", + "fullName": "google.cloud.compute_v1.NodeGroupsClient.set_node_template", "method": { - "fullName": "google.cloud.compute.v1.NodeGroups.SimulateMaintenanceEvent", + "fullName": "google.cloud.compute.v1.NodeGroups.SetNodeTemplate", "service": { "fullName": "google.cloud.compute.v1.NodeGroups", "shortName": "NodeGroups" }, - "shortName": "SimulateMaintenanceEvent" + "shortName": "SetNodeTemplate" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest" + "type": "google.cloud.compute_v1.types.SetNodeTemplateNodeGroupRequest" }, { "name": "project", @@ -31069,8 +31509,8 @@ "type": "str" }, { - "name": "node_groups_simulate_maintenance_event_request_resource", - "type": "google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest" + "name": "node_groups_set_node_template_request_resource", + "type": "google.cloud.compute_v1.types.NodeGroupsSetNodeTemplateRequest" }, { "name": "retry", @@ -31082,17 +31522,109 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "simulate_maintenance_event" + "shortName": "set_node_template" }, - "description": "Sample for SimulateMaintenanceEvent", - "file": "compute_v1_generated_node_groups_simulate_maintenance_event_sync.py", + "description": "Sample for SetNodeTemplate", + "file": "compute_v1_generated_node_groups_set_node_template_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_sync", + "regionTag": "compute_v1_generated_NodeGroups_SetNodeTemplate_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_node_groups_set_node_template_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.NodeGroupsClient", + "shortName": "NodeGroupsClient" + }, + "fullName": "google.cloud.compute_v1.NodeGroupsClient.simulate_maintenance_event", + "method": { + "fullName": "google.cloud.compute.v1.NodeGroups.SimulateMaintenanceEvent", + "service": { + "fullName": "google.cloud.compute.v1.NodeGroups", + "shortName": "NodeGroups" + }, + "shortName": "SimulateMaintenanceEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "zone", + "type": "str" + }, + { + "name": "node_group", + "type": "str" + }, + { + "name": "node_groups_simulate_maintenance_event_request_resource", + "type": "google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "simulate_maintenance_event" + }, + "description": "Sample for SimulateMaintenanceEvent", + "file": "compute_v1_generated_node_groups_simulate_maintenance_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_NodeGroups_SimulateMaintenanceEvent_sync", "segments": [ { "end": 53, @@ -31174,7 +31706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -31254,7 +31786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.node_templates.pagers.AggregatedListPager", @@ -31342,7 +31874,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -31430,7 +31962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -31518,7 +32050,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NodeTemplate", @@ -31606,7 +32138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -31690,7 +32222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.node_templates.pagers.ListPager", @@ -31782,7 +32314,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -31874,7 +32406,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -31954,7 +32486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.node_types.pagers.AggregatedListPager", @@ -32042,7 +32574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NodeType", @@ -32126,7 +32658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.node_types.pagers.ListPager", @@ -32206,7 +32738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.packet_mirrorings.pagers.AggregatedListPager", @@ -32294,7 +32826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -32382,7 +32914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.PacketMirroring", @@ -32470,7 +33002,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -32554,7 +33086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.packet_mirrorings.pagers.ListPager", @@ -32646,7 +33178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -32738,7 +33270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -32818,7 +33350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -32902,7 +33434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -32982,7 +33514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33066,7 +33598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33146,7 +33678,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Project", @@ -33226,7 +33758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.projects.pagers.GetXpnResourcesPager", @@ -33306,7 +33838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Project", @@ -33390,7 +33922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.projects.pagers.ListXpnHostsPager", @@ -33474,7 +34006,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33558,7 +34090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33642,7 +34174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33726,7 +34258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33810,7 +34342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33894,7 +34426,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -33978,7 +34510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34062,7 +34594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34146,7 +34678,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.PublicAdvertisedPrefix", @@ -34230,7 +34762,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34310,7 +34842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.public_advertised_prefixes.pagers.ListPager", @@ -34398,7 +34930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34482,7 +35014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34562,7 +35094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.public_delegated_prefixes.pagers.AggregatedListPager", @@ -34650,7 +35182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34738,7 +35270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34826,7 +35358,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.PublicDelegatedPrefix", @@ -34914,7 +35446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -34998,7 +35530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.public_delegated_prefixes.pagers.ListPager", @@ -35041,28 +35573,556 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_public_delegated_prefixes_list_sync.py" + "title": "compute_v1_generated_public_delegated_prefixes_list_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient", + "shortName": "PublicDelegatedPrefixesClient" + }, + "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient.patch", + "method": { + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Patch", + "service": { + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "shortName": "PublicDelegatedPrefixes" + }, + "shortName": "Patch" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.PatchPublicDelegatedPrefixeRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "public_delegated_prefix", + "type": "str" + }, + { + "name": "public_delegated_prefix_resource", + "type": "google.cloud.compute_v1.types.PublicDelegatedPrefix" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "patch" + }, + "description": "Sample for Patch", + "file": "compute_v1_generated_public_delegated_prefixes_patch_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Patch_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_public_delegated_prefixes_patch_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient", + "shortName": "PublicDelegatedPrefixesClient" + }, + "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient.withdraw", + "method": { + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Withdraw", + "service": { + "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes", + "shortName": "PublicDelegatedPrefixes" + }, + "shortName": "Withdraw" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.WithdrawPublicDelegatedPrefixeRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "public_delegated_prefix", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "withdraw" + }, + "description": "Sample for Withdraw", + "file": "compute_v1_generated_public_delegated_prefixes_withdraw_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Withdraw_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_public_delegated_prefixes_withdraw_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" + }, + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.delete", + "method": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Delete", + "service": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" + }, + "shortName": "Delete" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.DeleteRegionAutoscalerRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "autoscaler", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" + }, + "description": "Sample for Delete", + "file": "compute_v1_generated_region_autoscalers_delete_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionAutoscalers_Delete_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_autoscalers_delete_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" + }, + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.get", + "method": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Get", + "service": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" + }, + "shortName": "Get" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.GetRegionAutoscalerRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "autoscaler", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.types.Autoscaler", + "shortName": "get" + }, + "description": "Sample for Get", + "file": "compute_v1_generated_region_autoscalers_get_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionAutoscalers_Get_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_autoscalers_get_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" + }, + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.insert", + "method": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Insert", + "service": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" + }, + "shortName": "Insert" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.InsertRegionAutoscalerRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "autoscaler_resource", + "type": "google.cloud.compute_v1.types.Autoscaler" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" + }, + "description": "Sample for Insert", + "file": "compute_v1_generated_region_autoscalers_insert_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionAutoscalers_Insert_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_autoscalers_insert_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" + }, + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.list", + "method": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers.List", + "service": { + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" + }, + "shortName": "List" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.ListRegionAutoscalersRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.services.region_autoscalers.pagers.ListPager", + "shortName": "list" + }, + "description": "Sample for List", + "file": "compute_v1_generated_region_autoscalers_list_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionAutoscalers_List_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_autoscalers_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient", - "shortName": "PublicDelegatedPrefixesClient" + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" }, - "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient.patch", + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.patch", "method": { - "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Patch", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Patch", "service": { - "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes", - "shortName": "PublicDelegatedPrefixes" + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" }, "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchPublicDelegatedPrefixeRequest" + "type": "google.cloud.compute_v1.types.PatchRegionAutoscalerRequest" }, { "name": "project", @@ -35073,12 +36133,8 @@ "type": "str" }, { - "name": "public_delegated_prefix", - "type": "str" - }, - { - "name": "public_delegated_prefix_resource", - "type": "google.cloud.compute_v1.types.PublicDelegatedPrefix" + "name": "autoscaler_resource", + "type": "google.cloud.compute_v1.types.Autoscaler" }, { "name": "retry", @@ -35090,25 +36146,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", "shortName": "patch" }, "description": "Sample for Patch", - "file": "compute_v1_generated_public_delegated_prefixes_patch_sync.py", + "file": "compute_v1_generated_region_autoscalers_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Patch_sync", + "regionTag": "compute_v1_generated_RegionAutoscalers_Patch_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -35118,43 +36174,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_public_delegated_prefixes_patch_sync.py" + "title": "compute_v1_generated_region_autoscalers_patch_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient", - "shortName": "PublicDelegatedPrefixesClient" + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", + "shortName": "RegionAutoscalersClient" }, - "fullName": "google.cloud.compute_v1.PublicDelegatedPrefixesClient.withdraw", + "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.update", "method": { - "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes.Withdraw", + "fullName": "google.cloud.compute.v1.RegionAutoscalers.Update", "service": { - "fullName": "google.cloud.compute.v1.PublicDelegatedPrefixes", - "shortName": "PublicDelegatedPrefixes" + "fullName": "google.cloud.compute.v1.RegionAutoscalers", + "shortName": "RegionAutoscalers" }, - "shortName": "Withdraw" + "shortName": "Update" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.WithdrawPublicDelegatedPrefixeRequest" + "type": "google.cloud.compute_v1.types.UpdateRegionAutoscalerRequest" }, { "name": "project", @@ -35165,8 +36221,8 @@ "type": "str" }, { - "name": "public_delegated_prefix", - "type": "str" + "name": "autoscaler_resource", + "type": "google.cloud.compute_v1.types.Autoscaler" }, { "name": "retry", @@ -35178,25 +36234,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "withdraw" + "shortName": "update" }, - "description": "Sample for Withdraw", - "file": "compute_v1_generated_public_delegated_prefixes_withdraw_sync.py", + "description": "Sample for Update", + "file": "compute_v1_generated_region_autoscalers_update_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_PublicDelegatedPrefixes_Withdraw_sync", + "regionTag": "compute_v1_generated_RegionAutoscalers_Update_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -35206,43 +36262,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_public_delegated_prefixes_withdraw_sync.py" + "title": "compute_v1_generated_region_autoscalers_update_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.delete", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.delete", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.Delete", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Delete", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionAutoscalerRequest" + "type": "google.cloud.compute_v1.types.DeleteRegionBackendServiceRequest" }, { "name": "project", @@ -35253,7 +36309,7 @@ "type": "str" }, { - "name": "autoscaler", + "name": "backend_service", "type": "str" }, { @@ -35266,17 +36322,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", "shortName": "delete" }, "description": "Sample for Delete", - "file": "compute_v1_generated_region_autoscalers_delete_sync.py", + "file": "compute_v1_generated_region_backend_services_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_Delete_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_Delete_sync", "segments": [ { "end": 53, @@ -35309,28 +36365,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_delete_sync.py" + "title": "compute_v1_generated_region_backend_services_delete_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.get", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get_health", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.Get", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetHealth", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, - "shortName": "Get" + "shortName": "GetHealth" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionAutoscalerRequest" + "type": "google.cloud.compute_v1.types.GetHealthRegionBackendServiceRequest" }, { "name": "project", @@ -35341,9 +36397,13 @@ "type": "str" }, { - "name": "autoscaler", + "name": "backend_service", "type": "str" }, + { + "name": "resource_group_reference_resource", + "type": "google.cloud.compute_v1.types.ResourceGroupReference" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -35354,17 +36414,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Autoscaler", - "shortName": "get" + "resultType": "google.cloud.compute_v1.types.BackendServiceGroupHealth", + "shortName": "get_health" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_autoscalers_get_sync.py", + "description": "Sample for GetHealth", + "file": "compute_v1_generated_region_backend_services_get_health_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_Get_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_GetHealth_sync", "segments": [ { "end": 53, @@ -35397,28 +36457,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_get_sync.py" + "title": "compute_v1_generated_region_backend_services_get_health_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.insert", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.Insert", + "fullName": "google.cloud.compute.v1.RegionBackendServices.GetIamPolicy", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, - "shortName": "Insert" + "shortName": "GetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionAutoscalerRequest" + "type": "google.cloud.compute_v1.types.GetIamPolicyRegionBackendServiceRequest" }, { "name": "project", @@ -35429,8 +36489,8 @@ "type": "str" }, { - "name": "autoscaler_resource", - "type": "google.cloud.compute_v1.types.Autoscaler" + "name": "resource", + "type": "str" }, { "name": "retry", @@ -35442,25 +36502,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "resultType": "google.cloud.compute_v1.types.Policy", + "shortName": "get_iam_policy" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_autoscalers_insert_sync.py", + "description": "Sample for GetIamPolicy", + "file": "compute_v1_generated_region_backend_services_get_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_Insert_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_GetIamPolicy_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -35470,43 +36530,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_insert_sync.py" + "title": "compute_v1_generated_region_backend_services_get_iam_policy_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.list", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.List", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Get", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, - "shortName": "List" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionAutoscalersRequest" + "type": "google.cloud.compute_v1.types.GetRegionBackendServiceRequest" }, { "name": "project", @@ -35516,6 +36576,10 @@ "name": "region", "type": "str" }, + { + "name": "backend_service", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -35526,17 +36590,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_autoscalers.pagers.ListPager", - "shortName": "list" + "resultType": "google.cloud.compute_v1.types.BackendService", + "shortName": "get" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_autoscalers_list_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_backend_services_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_List_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_Get_sync", "segments": [ { "end": 53, @@ -35554,43 +36618,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_list_sync.py" + "title": "compute_v1_generated_region_backend_services_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.patch", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.Patch", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Insert", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, - "shortName": "Patch" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionAutoscalerRequest" + "type": "google.cloud.compute_v1.types.InsertRegionBackendServiceRequest" }, { "name": "project", @@ -35601,8 +36665,8 @@ "type": "str" }, { - "name": "autoscaler_resource", - "type": "google.cloud.compute_v1.types.Autoscaler" + "name": "backend_service_resource", + "type": "google.cloud.compute_v1.types.BackendService" }, { "name": "retry", @@ -35614,17 +36678,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "shortName": "insert" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_region_autoscalers_patch_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_backend_services_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_Patch_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_Insert_sync", "segments": [ { "end": 52, @@ -35657,28 +36721,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_patch_sync.py" + "title": "compute_v1_generated_region_backend_services_insert_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient", - "shortName": "RegionAutoscalersClient" + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", + "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionAutoscalersClient.update", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.list_usable", "method": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers.Update", + "fullName": "google.cloud.compute.v1.RegionBackendServices.ListUsable", "service": { - "fullName": "google.cloud.compute.v1.RegionAutoscalers", - "shortName": "RegionAutoscalers" + "fullName": "google.cloud.compute.v1.RegionBackendServices", + "shortName": "RegionBackendServices" }, - "shortName": "Update" + "shortName": "ListUsable" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdateRegionAutoscalerRequest" + "type": "google.cloud.compute_v1.types.ListUsableRegionBackendServicesRequest" }, { "name": "project", @@ -35688,10 +36752,6 @@ "name": "region", "type": "str" }, - { - "name": "autoscaler_resource", - "type": "google.cloud.compute_v1.types.Autoscaler" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -35702,25 +36762,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update" + "resultType": "google.cloud.compute_v1.services.region_backend_services.pagers.ListUsablePager", + "shortName": "list_usable" }, - "description": "Sample for Update", - "file": "compute_v1_generated_region_autoscalers_update_sync.py", + "description": "Sample for ListUsable", + "file": "compute_v1_generated_region_backend_services_list_usable_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionAutoscalers_Update_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_ListUsable_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -35740,12 +36800,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 54, "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_autoscalers_update_sync.py" + "title": "compute_v1_generated_region_backend_services_list_usable_sync.py" }, { "canonical": true, @@ -35754,19 +36814,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.delete", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.Delete", + "fullName": "google.cloud.compute.v1.RegionBackendServices.List", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "Delete" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.ListRegionBackendServicesRequest" }, { "name": "project", @@ -35776,10 +36836,6 @@ "name": "region", "type": "str" }, - { - "name": "backend_service", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -35790,17 +36846,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "resultType": "google.cloud.compute_v1.services.region_backend_services.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_region_backend_services_delete_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_backend_services_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_Delete_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_List_sync", "segments": [ { "end": 53, @@ -35818,22 +36874,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_delete_sync.py" + "title": "compute_v1_generated_region_backend_services_list_sync.py" }, { "canonical": true, @@ -35842,19 +36898,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get_health", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.patch", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.GetHealth", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Patch", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "GetHealth" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetHealthRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.PatchRegionBackendServiceRequest" }, { "name": "project", @@ -35869,8 +36925,8 @@ "type": "str" }, { - "name": "resource_group_reference_resource", - "type": "google.cloud.compute_v1.types.ResourceGroupReference" + "name": "backend_service_resource", + "type": "google.cloud.compute_v1.types.BackendService" }, { "name": "retry", @@ -35882,17 +36938,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.BackendServiceGroupHealth", - "shortName": "get_health" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "patch" }, - "description": "Sample for GetHealth", - "file": "compute_v1_generated_region_backend_services_get_health_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_region_backend_services_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_GetHealth_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_Patch_sync", "segments": [ { "end": 53, @@ -35925,7 +36981,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_get_health_sync.py" + "title": "compute_v1_generated_region_backend_services_patch_sync.py" }, { "canonical": true, @@ -35934,19 +36990,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get_iam_policy", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.set_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionBackendServices.SetIamPolicy", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "GetIamPolicy" + "shortName": "SetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetIamPolicyRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.SetIamPolicyRegionBackendServiceRequest" }, { "name": "project", @@ -35960,6 +37016,10 @@ "name": "resource", "type": "str" }, + { + "name": "region_set_policy_request_resource", + "type": "google.cloud.compute_v1.types.RegionSetPolicyRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -35970,17 +37030,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "get_iam_policy" + "shortName": "set_iam_policy" }, - "description": "Sample for GetIamPolicy", - "file": "compute_v1_generated_region_backend_services_get_iam_policy_sync.py", + "description": "Sample for SetIamPolicy", + "file": "compute_v1_generated_region_backend_services_set_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_GetIamPolicy_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_SetIamPolicy_sync", "segments": [ { "end": 53, @@ -36013,7 +37073,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_get_iam_policy_sync.py" + "title": "compute_v1_generated_region_backend_services_set_iam_policy_sync.py" }, { "canonical": true, @@ -36022,19 +37082,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.get", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.set_security_policy", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.Get", + "fullName": "google.cloud.compute.v1.RegionBackendServices.SetSecurityPolicy", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "Get" + "shortName": "SetSecurityPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.SetSecurityPolicyRegionBackendServiceRequest" }, { "name": "project", @@ -36048,6 +37108,10 @@ "name": "backend_service", "type": "str" }, + { + "name": "security_policy_reference_resource", + "type": "google.cloud.compute_v1.types.SecurityPolicyReference" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36058,17 +37122,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.BackendService", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "set_security_policy" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_backend_services_get_sync.py", + "description": "Sample for SetSecurityPolicy", + "file": "compute_v1_generated_region_backend_services_set_security_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_Get_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_SetSecurityPolicy_sync", "segments": [ { "end": 53, @@ -36101,7 +37165,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_get_sync.py" + "title": "compute_v1_generated_region_backend_services_set_security_policy_sync.py" }, { "canonical": true, @@ -36110,19 +37174,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.insert", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.test_iam_permissions", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.Insert", + "fullName": "google.cloud.compute.v1.RegionBackendServices.TestIamPermissions", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "Insert" + "shortName": "TestIamPermissions" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.TestIamPermissionsRegionBackendServiceRequest" }, { "name": "project", @@ -36133,8 +37197,12 @@ "type": "str" }, { - "name": "backend_service_resource", - "type": "google.cloud.compute_v1.types.BackendService" + "name": "resource", + "type": "str" + }, + { + "name": "test_permissions_request_resource", + "type": "google.cloud.compute_v1.types.TestPermissionsRequest" }, { "name": "retry", @@ -36146,25 +37214,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", + "shortName": "test_iam_permissions" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_backend_services_insert_sync.py", + "description": "Sample for TestIamPermissions", + "file": "compute_v1_generated_region_backend_services_test_iam_permissions_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_Insert_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_TestIamPermissions_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -36174,22 +37242,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_insert_sync.py" + "title": "compute_v1_generated_region_backend_services_test_iam_permissions_sync.py" }, { "canonical": true, @@ -36198,19 +37266,19 @@ "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", "shortName": "RegionBackendServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.list_usable", + "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.update", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.ListUsable", + "fullName": "google.cloud.compute.v1.RegionBackendServices.Update", "service": { "fullName": "google.cloud.compute.v1.RegionBackendServices", "shortName": "RegionBackendServices" }, - "shortName": "ListUsable" + "shortName": "Update" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListUsableRegionBackendServicesRequest" + "type": "google.cloud.compute_v1.types.UpdateRegionBackendServiceRequest" }, { "name": "project", @@ -36220,6 +37288,14 @@ "name": "region", "type": "str" }, + { + "name": "backend_service", + "type": "str" + }, + { + "name": "backend_service_resource", + "type": "google.cloud.compute_v1.types.BackendService" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36230,17 +37306,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_backend_services.pagers.ListUsablePager", - "shortName": "list_usable" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "update" }, - "description": "Sample for ListUsable", - "file": "compute_v1_generated_region_backend_services_list_usable_sync.py", + "description": "Sample for Update", + "file": "compute_v1_generated_region_backend_services_update_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_ListUsable_sync", + "regionTag": "compute_v1_generated_RegionBackendServices_Update_sync", "segments": [ { "end": 53, @@ -36258,52 +37334,48 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_list_usable_sync.py" + "title": "compute_v1_generated_region_backend_services_update_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", + "shortName": "RegionCommitmentsClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.list", + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.aggregated_list", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.List", + "fullName": "google.cloud.compute.v1.RegionCommitments.AggregatedList", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionCommitments", + "shortName": "RegionCommitments" }, - "shortName": "List" + "shortName": "AggregatedList" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionBackendServicesRequest" + "type": "google.cloud.compute_v1.types.AggregatedListRegionCommitmentsRequest" }, { "name": "project", "type": "str" }, - { - "name": "region", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36314,25 +37386,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_backend_services.pagers.ListPager", - "shortName": "list" + "resultType": "google.cloud.compute_v1.services.region_commitments.pagers.AggregatedListPager", + "shortName": "aggregated_list" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_backend_services_list_sync.py", + "description": "Sample for AggregatedList", + "file": "compute_v1_generated_region_commitments_aggregated_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_List_sync", + "regionTag": "compute_v1_generated_RegionCommitments_AggregatedList_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -36342,43 +37414,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 50, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_list_sync.py" + "title": "compute_v1_generated_region_commitments_aggregated_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", + "shortName": "RegionCommitmentsClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.patch", + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.Patch", + "fullName": "google.cloud.compute.v1.RegionCommitments.Get", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionCommitments", + "shortName": "RegionCommitments" }, - "shortName": "Patch" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.GetRegionCommitmentRequest" }, { "name": "project", @@ -36389,13 +37461,9 @@ "type": "str" }, { - "name": "backend_service", + "name": "commitment", "type": "str" }, - { - "name": "backend_service_resource", - "type": "google.cloud.compute_v1.types.BackendService" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36406,17 +37474,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "resultType": "google.cloud.compute_v1.types.Commitment", + "shortName": "get" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_region_backend_services_patch_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_commitments_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_Patch_sync", + "regionTag": "compute_v1_generated_RegionCommitments_Get_sync", "segments": [ { "end": 53, @@ -36449,28 +37517,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_patch_sync.py" + "title": "compute_v1_generated_region_commitments_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", + "shortName": "RegionCommitmentsClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.set_iam_policy", + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionCommitments.Insert", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionCommitments", + "shortName": "RegionCommitments" }, - "shortName": "SetIamPolicy" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetIamPolicyRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.InsertRegionCommitmentRequest" }, { "name": "project", @@ -36481,12 +37549,8 @@ "type": "str" }, { - "name": "resource", - "type": "str" - }, - { - "name": "region_set_policy_request_resource", - "type": "google.cloud.compute_v1.types.RegionSetPolicyRequest" + "name": "commitment_resource", + "type": "google.cloud.compute_v1.types.Commitment" }, { "name": "retry", @@ -36498,25 +37562,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "set_iam_policy" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" }, - "description": "Sample for SetIamPolicy", - "file": "compute_v1_generated_region_backend_services_set_iam_policy_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_commitments_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_SetIamPolicy_sync", + "regionTag": "compute_v1_generated_RegionCommitments_Insert_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -36526,43 +37590,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_set_iam_policy_sync.py" + "title": "compute_v1_generated_region_commitments_insert_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", + "shortName": "RegionCommitmentsClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.set_security_policy", + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.SetSecurityPolicy", + "fullName": "google.cloud.compute.v1.RegionCommitments.List", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionCommitments", + "shortName": "RegionCommitments" }, - "shortName": "SetSecurityPolicy" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetSecurityPolicyRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.ListRegionCommitmentsRequest" }, { "name": "project", @@ -36572,14 +37636,6 @@ "name": "region", "type": "str" }, - { - "name": "backend_service", - "type": "str" - }, - { - "name": "security_policy_reference_resource", - "type": "google.cloud.compute_v1.types.SecurityPolicyReference" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36590,17 +37646,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_security_policy" + "resultType": "google.cloud.compute_v1.services.region_commitments.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for SetSecurityPolicy", - "file": "compute_v1_generated_region_backend_services_set_security_policy_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_commitments_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_SetSecurityPolicy_sync", + "regionTag": "compute_v1_generated_RegionCommitments_List_sync", "segments": [ { "end": 53, @@ -36618,43 +37674,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_set_security_policy_sync.py" + "title": "compute_v1_generated_region_commitments_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", + "shortName": "RegionCommitmentsClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.test_iam_permissions", + "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.update", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionCommitments.Update", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionCommitments", + "shortName": "RegionCommitments" }, - "shortName": "TestIamPermissions" + "shortName": "Update" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.TestIamPermissionsRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.UpdateRegionCommitmentRequest" }, { "name": "project", @@ -36665,12 +37721,12 @@ "type": "str" }, { - "name": "resource", + "name": "commitment", "type": "str" }, { - "name": "test_permissions_request_resource", - "type": "google.cloud.compute_v1.types.TestPermissionsRequest" + "name": "commitment_resource", + "type": "google.cloud.compute_v1.types.Commitment" }, { "name": "retry", @@ -36682,17 +37738,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", - "shortName": "test_iam_permissions" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "update" }, - "description": "Sample for TestIamPermissions", - "file": "compute_v1_generated_region_backend_services_test_iam_permissions_sync.py", + "description": "Sample for Update", + "file": "compute_v1_generated_region_commitments_update_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_TestIamPermissions_sync", + "regionTag": "compute_v1_generated_RegionCommitments_Update_sync", "segments": [ { "end": 53, @@ -36725,28 +37781,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_test_iam_permissions_sync.py" + "title": "compute_v1_generated_region_commitments_update_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient", - "shortName": "RegionBackendServicesClient" + "fullName": "google.cloud.compute_v1.RegionDiskTypesClient", + "shortName": "RegionDiskTypesClient" }, - "fullName": "google.cloud.compute_v1.RegionBackendServicesClient.update", + "fullName": "google.cloud.compute_v1.RegionDiskTypesClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionBackendServices.Update", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.Get", "service": { - "fullName": "google.cloud.compute.v1.RegionBackendServices", - "shortName": "RegionBackendServices" + "fullName": "google.cloud.compute.v1.RegionDiskTypes", + "shortName": "RegionDiskTypes" }, - "shortName": "Update" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdateRegionBackendServiceRequest" + "type": "google.cloud.compute_v1.types.GetRegionDiskTypeRequest" }, { "name": "project", @@ -36757,13 +37813,9 @@ "type": "str" }, { - "name": "backend_service", + "name": "disk_type", "type": "str" }, - { - "name": "backend_service_resource", - "type": "google.cloud.compute_v1.types.BackendService" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36774,17 +37826,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update" + "resultType": "google.cloud.compute_v1.types.DiskType", + "shortName": "get" }, - "description": "Sample for Update", - "file": "compute_v1_generated_region_backend_services_update_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_disk_types_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionBackendServices_Update_sync", + "regionTag": "compute_v1_generated_RegionDiskTypes_Get_sync", "segments": [ { "end": 53, @@ -36817,33 +37869,37 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_backend_services_update_sync.py" + "title": "compute_v1_generated_region_disk_types_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", - "shortName": "RegionCommitmentsClient" + "fullName": "google.cloud.compute_v1.RegionDiskTypesClient", + "shortName": "RegionDiskTypesClient" }, - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.aggregated_list", + "fullName": "google.cloud.compute_v1.RegionDiskTypesClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionCommitments.AggregatedList", + "fullName": "google.cloud.compute.v1.RegionDiskTypes.List", "service": { - "fullName": "google.cloud.compute.v1.RegionCommitments", - "shortName": "RegionCommitments" + "fullName": "google.cloud.compute.v1.RegionDiskTypes", + "shortName": "RegionDiskTypes" }, - "shortName": "AggregatedList" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AggregatedListRegionCommitmentsRequest" + "type": "google.cloud.compute_v1.types.ListRegionDiskTypesRequest" }, { "name": "project", "type": "str" }, + { + "name": "region", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36854,25 +37910,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_commitments.pagers.AggregatedListPager", - "shortName": "aggregated_list" + "resultType": "google.cloud.compute_v1.services.region_disk_types.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for AggregatedList", - "file": "compute_v1_generated_region_commitments_aggregated_list_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_disk_types_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionCommitments_AggregatedList_sync", + "regionTag": "compute_v1_generated_RegionDiskTypes_List_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -36882,43 +37938,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 54, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_commitments_aggregated_list_sync.py" + "title": "compute_v1_generated_region_disk_types_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", - "shortName": "RegionCommitmentsClient" + "fullName": "google.cloud.compute_v1.RegionDisksClient", + "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.get", + "fullName": "google.cloud.compute_v1.RegionDisksClient.add_resource_policies", "method": { - "fullName": "google.cloud.compute.v1.RegionCommitments.Get", + "fullName": "google.cloud.compute.v1.RegionDisks.AddResourcePolicies", "service": { - "fullName": "google.cloud.compute.v1.RegionCommitments", - "shortName": "RegionCommitments" + "fullName": "google.cloud.compute.v1.RegionDisks", + "shortName": "RegionDisks" }, - "shortName": "Get" + "shortName": "AddResourcePolicies" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionCommitmentRequest" + "type": "google.cloud.compute_v1.types.AddResourcePoliciesRegionDiskRequest" }, { "name": "project", @@ -36929,9 +37985,13 @@ "type": "str" }, { - "name": "commitment", + "name": "disk", "type": "str" }, + { + "name": "region_disks_add_resource_policies_request_resource", + "type": "google.cloud.compute_v1.types.RegionDisksAddResourcePoliciesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -36942,17 +38002,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Commitment", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "add_resource_policies" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_commitments_get_sync.py", + "description": "Sample for AddResourcePolicies", + "file": "compute_v1_generated_region_disks_add_resource_policies_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionCommitments_Get_sync", + "regionTag": "compute_v1_generated_RegionDisks_AddResourcePolicies_sync", "segments": [ { "end": 53, @@ -36985,28 +38045,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_commitments_get_sync.py" + "title": "compute_v1_generated_region_disks_add_resource_policies_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", - "shortName": "RegionCommitmentsClient" + "fullName": "google.cloud.compute_v1.RegionDisksClient", + "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.insert", + "fullName": "google.cloud.compute_v1.RegionDisksClient.bulk_insert", "method": { - "fullName": "google.cloud.compute.v1.RegionCommitments.Insert", + "fullName": "google.cloud.compute.v1.RegionDisks.BulkInsert", "service": { - "fullName": "google.cloud.compute.v1.RegionCommitments", - "shortName": "RegionCommitments" + "fullName": "google.cloud.compute.v1.RegionDisks", + "shortName": "RegionDisks" }, - "shortName": "Insert" + "shortName": "BulkInsert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionCommitmentRequest" + "type": "google.cloud.compute_v1.types.BulkInsertRegionDiskRequest" }, { "name": "project", @@ -37017,8 +38077,8 @@ "type": "str" }, { - "name": "commitment_resource", - "type": "google.cloud.compute_v1.types.Commitment" + "name": "bulk_insert_disk_resource_resource", + "type": "google.cloud.compute_v1.types.BulkInsertDiskResource" }, { "name": "retry", @@ -37030,17 +38090,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "shortName": "bulk_insert" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_commitments_insert_sync.py", + "description": "Sample for BulkInsert", + "file": "compute_v1_generated_region_disks_bulk_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionCommitments_Insert_sync", + "regionTag": "compute_v1_generated_RegionDisks_BulkInsert_sync", "segments": [ { "end": 52, @@ -37073,112 +38133,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_commitments_insert_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", - "shortName": "RegionCommitmentsClient" - }, - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.list", - "method": { - "fullName": "google.cloud.compute.v1.RegionCommitments.List", - "service": { - "fullName": "google.cloud.compute.v1.RegionCommitments", - "shortName": "RegionCommitments" - }, - "shortName": "List" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionCommitmentsRequest" - }, - { - "name": "project", - "type": "str" - }, - { - "name": "region", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.compute_v1.services.region_commitments.pagers.ListPager", - "shortName": "list" - }, - "description": "Sample for List", - "file": "compute_v1_generated_region_commitments_list_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionCommitments_List_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "compute_v1_generated_region_commitments_list_sync.py" + "title": "compute_v1_generated_region_disks_bulk_insert_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient", - "shortName": "RegionCommitmentsClient" + "fullName": "google.cloud.compute_v1.RegionDisksClient", + "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionCommitmentsClient.update", + "fullName": "google.cloud.compute_v1.RegionDisksClient.create_snapshot", "method": { - "fullName": "google.cloud.compute.v1.RegionCommitments.Update", + "fullName": "google.cloud.compute.v1.RegionDisks.CreateSnapshot", "service": { - "fullName": "google.cloud.compute.v1.RegionCommitments", - "shortName": "RegionCommitments" + "fullName": "google.cloud.compute.v1.RegionDisks", + "shortName": "RegionDisks" }, - "shortName": "Update" + "shortName": "CreateSnapshot" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdateRegionCommitmentRequest" + "type": "google.cloud.compute_v1.types.CreateSnapshotRegionDiskRequest" }, { "name": "project", @@ -37189,12 +38165,12 @@ "type": "str" }, { - "name": "commitment", + "name": "disk", "type": "str" }, { - "name": "commitment_resource", - "type": "google.cloud.compute_v1.types.Commitment" + "name": "snapshot_resource", + "type": "google.cloud.compute_v1.types.Snapshot" }, { "name": "retry", @@ -37206,17 +38182,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update" + "shortName": "create_snapshot" }, - "description": "Sample for Update", - "file": "compute_v1_generated_region_commitments_update_sync.py", + "description": "Sample for CreateSnapshot", + "file": "compute_v1_generated_region_disks_create_snapshot_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionCommitments_Update_sync", + "regionTag": "compute_v1_generated_RegionDisks_CreateSnapshot_sync", "segments": [ { "end": 53, @@ -37249,28 +38225,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_commitments_update_sync.py" + "title": "compute_v1_generated_region_disks_create_snapshot_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDiskTypesClient", - "shortName": "RegionDiskTypesClient" + "fullName": "google.cloud.compute_v1.RegionDisksClient", + "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDiskTypesClient.get", + "fullName": "google.cloud.compute_v1.RegionDisksClient.delete", "method": { - "fullName": "google.cloud.compute.v1.RegionDiskTypes.Get", + "fullName": "google.cloud.compute.v1.RegionDisks.Delete", "service": { - "fullName": "google.cloud.compute.v1.RegionDiskTypes", - "shortName": "RegionDiskTypes" + "fullName": "google.cloud.compute.v1.RegionDisks", + "shortName": "RegionDisks" }, - "shortName": "Get" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionDiskTypeRequest" + "type": "google.cloud.compute_v1.types.DeleteRegionDiskRequest" }, { "name": "project", @@ -37281,7 +38257,7 @@ "type": "str" }, { - "name": "disk_type", + "name": "disk", "type": "str" }, { @@ -37294,17 +38270,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.DiskType", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_disk_types_get_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_region_disks_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDiskTypes_Get_sync", + "regionTag": "compute_v1_generated_RegionDisks_Delete_sync", "segments": [ { "end": 53, @@ -37337,28 +38313,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disk_types_get_sync.py" + "title": "compute_v1_generated_region_disks_delete_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDiskTypesClient", - "shortName": "RegionDiskTypesClient" + "fullName": "google.cloud.compute_v1.RegionDisksClient", + "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDiskTypesClient.list", + "fullName": "google.cloud.compute_v1.RegionDisksClient.get_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.RegionDiskTypes.List", + "fullName": "google.cloud.compute.v1.RegionDisks.GetIamPolicy", "service": { - "fullName": "google.cloud.compute.v1.RegionDiskTypes", - "shortName": "RegionDiskTypes" + "fullName": "google.cloud.compute.v1.RegionDisks", + "shortName": "RegionDisks" }, - "shortName": "List" + "shortName": "GetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionDiskTypesRequest" + "type": "google.cloud.compute_v1.types.GetIamPolicyRegionDiskRequest" }, { "name": "project", @@ -37368,6 +38344,10 @@ "name": "region", "type": "str" }, + { + "name": "resource", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37378,17 +38358,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_disk_types.pagers.ListPager", - "shortName": "list" + "resultType": "google.cloud.compute_v1.types.Policy", + "shortName": "get_iam_policy" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_disk_types_list_sync.py", + "description": "Sample for GetIamPolicy", + "file": "compute_v1_generated_region_disks_get_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDiskTypes_List_sync", + "regionTag": "compute_v1_generated_RegionDisks_GetIamPolicy_sync", "segments": [ { "end": 53, @@ -37406,22 +38386,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disk_types_list_sync.py" + "title": "compute_v1_generated_region_disks_get_iam_policy_sync.py" }, { "canonical": true, @@ -37430,19 +38410,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.add_resource_policies", + "fullName": "google.cloud.compute_v1.RegionDisksClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.AddResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.Get", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "AddResourcePolicies" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AddResourcePoliciesRegionDiskRequest" + "type": "google.cloud.compute_v1.types.GetRegionDiskRequest" }, { "name": "project", @@ -37456,10 +38436,6 @@ "name": "disk", "type": "str" }, - { - "name": "region_disks_add_resource_policies_request_resource", - "type": "google.cloud.compute_v1.types.RegionDisksAddResourcePoliciesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37470,17 +38446,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "add_resource_policies" + "resultType": "google.cloud.compute_v1.types.Disk", + "shortName": "get" }, - "description": "Sample for AddResourcePolicies", - "file": "compute_v1_generated_region_disks_add_resource_policies_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_disks_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_AddResourcePolicies_sync", + "regionTag": "compute_v1_generated_RegionDisks_Get_sync", "segments": [ { "end": 53, @@ -37513,7 +38489,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_add_resource_policies_sync.py" + "title": "compute_v1_generated_region_disks_get_sync.py" }, { "canonical": true, @@ -37522,19 +38498,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.bulk_insert", + "fullName": "google.cloud.compute_v1.RegionDisksClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.BulkInsert", + "fullName": "google.cloud.compute.v1.RegionDisks.Insert", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "BulkInsert" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.BulkInsertRegionDiskRequest" + "type": "google.cloud.compute_v1.types.InsertRegionDiskRequest" }, { "name": "project", @@ -37545,8 +38521,8 @@ "type": "str" }, { - "name": "bulk_insert_disk_resource_resource", - "type": "google.cloud.compute_v1.types.BulkInsertDiskResource" + "name": "disk_resource", + "type": "google.cloud.compute_v1.types.Disk" }, { "name": "retry", @@ -37558,17 +38534,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "bulk_insert" + "shortName": "insert" }, - "description": "Sample for BulkInsert", - "file": "compute_v1_generated_region_disks_bulk_insert_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_disks_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_BulkInsert_sync", + "regionTag": "compute_v1_generated_RegionDisks_Insert_sync", "segments": [ { "end": 52, @@ -37601,7 +38577,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_bulk_insert_sync.py" + "title": "compute_v1_generated_region_disks_insert_sync.py" }, { "canonical": true, @@ -37610,19 +38586,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.create_snapshot", + "fullName": "google.cloud.compute_v1.RegionDisksClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.CreateSnapshot", + "fullName": "google.cloud.compute.v1.RegionDisks.List", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "CreateSnapshot" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.CreateSnapshotRegionDiskRequest" + "type": "google.cloud.compute_v1.types.ListRegionDisksRequest" }, { "name": "project", @@ -37632,14 +38608,6 @@ "name": "region", "type": "str" }, - { - "name": "disk", - "type": "str" - }, - { - "name": "snapshot_resource", - "type": "google.cloud.compute_v1.types.Snapshot" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37650,17 +38618,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "create_snapshot" + "resultType": "google.cloud.compute_v1.services.region_disks.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for CreateSnapshot", - "file": "compute_v1_generated_region_disks_create_snapshot_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_disks_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_CreateSnapshot_sync", + "regionTag": "compute_v1_generated_RegionDisks_List_sync", "segments": [ { "end": 53, @@ -37678,22 +38646,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_create_snapshot_sync.py" + "title": "compute_v1_generated_region_disks_list_sync.py" }, { "canonical": true, @@ -37702,19 +38670,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.delete", + "fullName": "google.cloud.compute_v1.RegionDisksClient.remove_resource_policies", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.Delete", + "fullName": "google.cloud.compute.v1.RegionDisks.RemoveResourcePolicies", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "Delete" + "shortName": "RemoveResourcePolicies" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionDiskRequest" + "type": "google.cloud.compute_v1.types.RemoveResourcePoliciesRegionDiskRequest" }, { "name": "project", @@ -37728,6 +38696,10 @@ "name": "disk", "type": "str" }, + { + "name": "region_disks_remove_resource_policies_request_resource", + "type": "google.cloud.compute_v1.types.RegionDisksRemoveResourcePoliciesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37738,17 +38710,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "shortName": "remove_resource_policies" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_region_disks_delete_sync.py", + "description": "Sample for RemoveResourcePolicies", + "file": "compute_v1_generated_region_disks_remove_resource_policies_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_Delete_sync", + "regionTag": "compute_v1_generated_RegionDisks_RemoveResourcePolicies_sync", "segments": [ { "end": 53, @@ -37781,7 +38753,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_delete_sync.py" + "title": "compute_v1_generated_region_disks_remove_resource_policies_sync.py" }, { "canonical": true, @@ -37790,19 +38762,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.get_iam_policy", + "fullName": "google.cloud.compute_v1.RegionDisksClient.resize", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.GetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.Resize", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "GetIamPolicy" + "shortName": "Resize" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetIamPolicyRegionDiskRequest" + "type": "google.cloud.compute_v1.types.ResizeRegionDiskRequest" }, { "name": "project", @@ -37813,9 +38785,13 @@ "type": "str" }, { - "name": "resource", + "name": "disk", "type": "str" }, + { + "name": "region_disks_resize_request_resource", + "type": "google.cloud.compute_v1.types.RegionDisksResizeRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37826,17 +38802,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "get_iam_policy" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "resize" }, - "description": "Sample for GetIamPolicy", - "file": "compute_v1_generated_region_disks_get_iam_policy_sync.py", + "description": "Sample for Resize", + "file": "compute_v1_generated_region_disks_resize_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_GetIamPolicy_sync", + "regionTag": "compute_v1_generated_RegionDisks_Resize_sync", "segments": [ { "end": 53, @@ -37869,7 +38845,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_get_iam_policy_sync.py" + "title": "compute_v1_generated_region_disks_resize_sync.py" }, { "canonical": true, @@ -37878,19 +38854,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.get", + "fullName": "google.cloud.compute_v1.RegionDisksClient.set_iam_policy", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.Get", + "fullName": "google.cloud.compute.v1.RegionDisks.SetIamPolicy", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "Get" + "shortName": "SetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionDiskRequest" + "type": "google.cloud.compute_v1.types.SetIamPolicyRegionDiskRequest" }, { "name": "project", @@ -37901,9 +38877,13 @@ "type": "str" }, { - "name": "disk", + "name": "resource", "type": "str" }, + { + "name": "region_set_policy_request_resource", + "type": "google.cloud.compute_v1.types.RegionSetPolicyRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -37914,17 +38894,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Disk", - "shortName": "get" + "resultType": "google.cloud.compute_v1.types.Policy", + "shortName": "set_iam_policy" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_disks_get_sync.py", + "description": "Sample for SetIamPolicy", + "file": "compute_v1_generated_region_disks_set_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_Get_sync", + "regionTag": "compute_v1_generated_RegionDisks_SetIamPolicy_sync", "segments": [ { "end": 53, @@ -37957,7 +38937,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_get_sync.py" + "title": "compute_v1_generated_region_disks_set_iam_policy_sync.py" }, { "canonical": true, @@ -37966,19 +38946,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.insert", + "fullName": "google.cloud.compute_v1.RegionDisksClient.set_labels", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.Insert", + "fullName": "google.cloud.compute.v1.RegionDisks.SetLabels", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "Insert" + "shortName": "SetLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionDiskRequest" + "type": "google.cloud.compute_v1.types.SetLabelsRegionDiskRequest" }, { "name": "project", @@ -37989,8 +38969,12 @@ "type": "str" }, { - "name": "disk_resource", - "type": "google.cloud.compute_v1.types.Disk" + "name": "resource", + "type": "str" + }, + { + "name": "region_set_labels_request_resource", + "type": "google.cloud.compute_v1.types.RegionSetLabelsRequest" }, { "name": "retry", @@ -38002,25 +38986,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "shortName": "set_labels" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_disks_insert_sync.py", + "description": "Sample for SetLabels", + "file": "compute_v1_generated_region_disks_set_labels_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_Insert_sync", + "regionTag": "compute_v1_generated_RegionDisks_SetLabels_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -38030,22 +39014,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_insert_sync.py" + "title": "compute_v1_generated_region_disks_set_labels_sync.py" }, { "canonical": true, @@ -38054,19 +39038,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.list", + "fullName": "google.cloud.compute_v1.RegionDisksClient.start_async_replication", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.List", + "fullName": "google.cloud.compute.v1.RegionDisks.StartAsyncReplication", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "List" + "shortName": "StartAsyncReplication" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionDisksRequest" + "type": "google.cloud.compute_v1.types.StartAsyncReplicationRegionDiskRequest" }, { "name": "project", @@ -38076,6 +39060,14 @@ "name": "region", "type": "str" }, + { + "name": "disk", + "type": "str" + }, + { + "name": "region_disks_start_async_replication_request_resource", + "type": "google.cloud.compute_v1.types.RegionDisksStartAsyncReplicationRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -38086,17 +39078,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_disks.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "start_async_replication" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_disks_list_sync.py", + "description": "Sample for StartAsyncReplication", + "file": "compute_v1_generated_region_disks_start_async_replication_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_List_sync", + "regionTag": "compute_v1_generated_RegionDisks_StartAsyncReplication_sync", "segments": [ { "end": 53, @@ -38114,22 +39106,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_list_sync.py" + "title": "compute_v1_generated_region_disks_start_async_replication_sync.py" }, { "canonical": true, @@ -38138,19 +39130,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.remove_resource_policies", + "fullName": "google.cloud.compute_v1.RegionDisksClient.stop_async_replication", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.RemoveResourcePolicies", + "fullName": "google.cloud.compute.v1.RegionDisks.StopAsyncReplication", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "RemoveResourcePolicies" + "shortName": "StopAsyncReplication" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.RemoveResourcePoliciesRegionDiskRequest" + "type": "google.cloud.compute_v1.types.StopAsyncReplicationRegionDiskRequest" }, { "name": "project", @@ -38164,10 +39156,6 @@ "name": "disk", "type": "str" }, - { - "name": "region_disks_remove_resource_policies_request_resource", - "type": "google.cloud.compute_v1.types.RegionDisksRemoveResourcePoliciesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -38178,17 +39166,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "remove_resource_policies" + "shortName": "stop_async_replication" }, - "description": "Sample for RemoveResourcePolicies", - "file": "compute_v1_generated_region_disks_remove_resource_policies_sync.py", + "description": "Sample for StopAsyncReplication", + "file": "compute_v1_generated_region_disks_stop_async_replication_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_RemoveResourcePolicies_sync", + "regionTag": "compute_v1_generated_RegionDisks_StopAsyncReplication_sync", "segments": [ { "end": 53, @@ -38221,7 +39209,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_remove_resource_policies_sync.py" + "title": "compute_v1_generated_region_disks_stop_async_replication_sync.py" }, { "canonical": true, @@ -38230,19 +39218,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.resize", + "fullName": "google.cloud.compute_v1.RegionDisksClient.stop_group_async_replication", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.Resize", + "fullName": "google.cloud.compute.v1.RegionDisks.StopGroupAsyncReplication", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "Resize" + "shortName": "StopGroupAsyncReplication" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ResizeRegionDiskRequest" + "type": "google.cloud.compute_v1.types.StopGroupAsyncReplicationRegionDiskRequest" }, { "name": "project", @@ -38253,12 +39241,8 @@ "type": "str" }, { - "name": "disk", - "type": "str" - }, - { - "name": "region_disks_resize_request_resource", - "type": "google.cloud.compute_v1.types.RegionDisksResizeRequest" + "name": "disks_stop_group_async_replication_resource_resource", + "type": "google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource" }, { "name": "retry", @@ -38270,25 +39254,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "resize" + "shortName": "stop_group_async_replication" }, - "description": "Sample for Resize", - "file": "compute_v1_generated_region_disks_resize_sync.py", + "description": "Sample for StopGroupAsyncReplication", + "file": "compute_v1_generated_region_disks_stop_group_async_replication_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_Resize_sync", + "regionTag": "compute_v1_generated_RegionDisks_StopGroupAsyncReplication_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -38298,22 +39282,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_resize_sync.py" + "title": "compute_v1_generated_region_disks_stop_group_async_replication_sync.py" }, { "canonical": true, @@ -38322,19 +39306,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.set_iam_policy", + "fullName": "google.cloud.compute_v1.RegionDisksClient.test_iam_permissions", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.SetIamPolicy", + "fullName": "google.cloud.compute.v1.RegionDisks.TestIamPermissions", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "SetIamPolicy" + "shortName": "TestIamPermissions" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetIamPolicyRegionDiskRequest" + "type": "google.cloud.compute_v1.types.TestIamPermissionsRegionDiskRequest" }, { "name": "project", @@ -38349,8 +39333,8 @@ "type": "str" }, { - "name": "region_set_policy_request_resource", - "type": "google.cloud.compute_v1.types.RegionSetPolicyRequest" + "name": "test_permissions_request_resource", + "type": "google.cloud.compute_v1.types.TestPermissionsRequest" }, { "name": "retry", @@ -38362,17 +39346,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.Policy", - "shortName": "set_iam_policy" + "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", + "shortName": "test_iam_permissions" }, - "description": "Sample for SetIamPolicy", - "file": "compute_v1_generated_region_disks_set_iam_policy_sync.py", + "description": "Sample for TestIamPermissions", + "file": "compute_v1_generated_region_disks_test_iam_permissions_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_SetIamPolicy_sync", + "regionTag": "compute_v1_generated_RegionDisks_TestIamPermissions_sync", "segments": [ { "end": 53, @@ -38405,7 +39389,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_set_iam_policy_sync.py" + "title": "compute_v1_generated_region_disks_test_iam_permissions_sync.py" }, { "canonical": true, @@ -38414,19 +39398,19 @@ "fullName": "google.cloud.compute_v1.RegionDisksClient", "shortName": "RegionDisksClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.set_labels", + "fullName": "google.cloud.compute_v1.RegionDisksClient.update", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.SetLabels", + "fullName": "google.cloud.compute.v1.RegionDisks.Update", "service": { "fullName": "google.cloud.compute.v1.RegionDisks", "shortName": "RegionDisks" }, - "shortName": "SetLabels" + "shortName": "Update" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetLabelsRegionDiskRequest" + "type": "google.cloud.compute_v1.types.UpdateRegionDiskRequest" }, { "name": "project", @@ -38437,12 +39421,12 @@ "type": "str" }, { - "name": "resource", + "name": "disk", "type": "str" }, { - "name": "region_set_labels_request_resource", - "type": "google.cloud.compute_v1.types.RegionSetLabelsRequest" + "name": "disk_resource", + "type": "google.cloud.compute_v1.types.Disk" }, { "name": "retry", @@ -38454,17 +39438,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_labels" + "shortName": "update" }, - "description": "Sample for SetLabels", - "file": "compute_v1_generated_region_disks_set_labels_sync.py", + "description": "Sample for Update", + "file": "compute_v1_generated_region_disks_update_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_SetLabels_sync", + "regionTag": "compute_v1_generated_RegionDisks_Update_sync", "segments": [ { "end": 53, @@ -38497,28 +39481,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_set_labels_sync.py" + "title": "compute_v1_generated_region_disks_update_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDisksClient", - "shortName": "RegionDisksClient" + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", + "shortName": "RegionHealthCheckServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.start_async_replication", + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.delete", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.StartAsyncReplication", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Delete", "service": { - "fullName": "google.cloud.compute.v1.RegionDisks", - "shortName": "RegionDisks" + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", + "shortName": "RegionHealthCheckServices" }, - "shortName": "StartAsyncReplication" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.StartAsyncReplicationRegionDiskRequest" + "type": "google.cloud.compute_v1.types.DeleteRegionHealthCheckServiceRequest" }, { "name": "project", @@ -38529,13 +39513,9 @@ "type": "str" }, { - "name": "disk", + "name": "health_check_service", "type": "str" }, - { - "name": "region_disks_start_async_replication_request_resource", - "type": "google.cloud.compute_v1.types.RegionDisksStartAsyncReplicationRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -38546,17 +39526,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "start_async_replication" + "shortName": "delete" }, - "description": "Sample for StartAsyncReplication", - "file": "compute_v1_generated_region_disks_start_async_replication_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_region_health_check_services_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_StartAsyncReplication_sync", + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Delete_sync", "segments": [ { "end": 53, @@ -38589,28 +39569,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_start_async_replication_sync.py" + "title": "compute_v1_generated_region_health_check_services_delete_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDisksClient", - "shortName": "RegionDisksClient" + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", + "shortName": "RegionHealthCheckServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.stop_async_replication", + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.StopAsyncReplication", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Get", "service": { - "fullName": "google.cloud.compute.v1.RegionDisks", - "shortName": "RegionDisks" + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", + "shortName": "RegionHealthCheckServices" }, - "shortName": "StopAsyncReplication" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.StopAsyncReplicationRegionDiskRequest" + "type": "google.cloud.compute_v1.types.GetRegionHealthCheckServiceRequest" }, { "name": "project", @@ -38621,7 +39601,7 @@ "type": "str" }, { - "name": "disk", + "name": "health_check_service", "type": "str" }, { @@ -38634,17 +39614,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "stop_async_replication" + "resultType": "google.cloud.compute_v1.types.HealthCheckService", + "shortName": "get" }, - "description": "Sample for StopAsyncReplication", - "file": "compute_v1_generated_region_disks_stop_async_replication_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_health_check_services_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_StopAsyncReplication_sync", + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Get_sync", "segments": [ { "end": 53, @@ -38677,28 +39657,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_stop_async_replication_sync.py" + "title": "compute_v1_generated_region_health_check_services_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDisksClient", - "shortName": "RegionDisksClient" + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", + "shortName": "RegionHealthCheckServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.stop_group_async_replication", + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.StopGroupAsyncReplication", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Insert", "service": { - "fullName": "google.cloud.compute.v1.RegionDisks", - "shortName": "RegionDisks" + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", + "shortName": "RegionHealthCheckServices" }, - "shortName": "StopGroupAsyncReplication" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.StopGroupAsyncReplicationRegionDiskRequest" + "type": "google.cloud.compute_v1.types.InsertRegionHealthCheckServiceRequest" }, { "name": "project", @@ -38709,8 +39689,8 @@ "type": "str" }, { - "name": "disks_stop_group_async_replication_resource_resource", - "type": "google.cloud.compute_v1.types.DisksStopGroupAsyncReplicationResource" + "name": "health_check_service_resource", + "type": "google.cloud.compute_v1.types.HealthCheckService" }, { "name": "retry", @@ -38722,17 +39702,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "stop_group_async_replication" + "shortName": "insert" }, - "description": "Sample for StopGroupAsyncReplication", - "file": "compute_v1_generated_region_disks_stop_group_async_replication_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_health_check_services_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_StopGroupAsyncReplication_sync", + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Insert_sync", "segments": [ { "end": 52, @@ -38765,28 +39745,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_stop_group_async_replication_sync.py" + "title": "compute_v1_generated_region_health_check_services_insert_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDisksClient", - "shortName": "RegionDisksClient" + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", + "shortName": "RegionHealthCheckServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.test_iam_permissions", + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.TestIamPermissions", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.List", "service": { - "fullName": "google.cloud.compute.v1.RegionDisks", - "shortName": "RegionDisks" + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", + "shortName": "RegionHealthCheckServices" }, - "shortName": "TestIamPermissions" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.TestIamPermissionsRegionDiskRequest" + "type": "google.cloud.compute_v1.types.ListRegionHealthCheckServicesRequest" }, { "name": "project", @@ -38796,14 +39776,6 @@ "name": "region", "type": "str" }, - { - "name": "resource", - "type": "str" - }, - { - "name": "test_permissions_request_resource", - "type": "google.cloud.compute_v1.types.TestPermissionsRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -38814,17 +39786,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", - "shortName": "test_iam_permissions" + "resultType": "google.cloud.compute_v1.services.region_health_check_services.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for TestIamPermissions", - "file": "compute_v1_generated_region_disks_test_iam_permissions_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_health_check_services_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_TestIamPermissions_sync", + "regionTag": "compute_v1_generated_RegionHealthCheckServices_List_sync", "segments": [ { "end": 53, @@ -38842,43 +39814,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_test_iam_permissions_sync.py" + "title": "compute_v1_generated_region_health_check_services_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionDisksClient", - "shortName": "RegionDisksClient" + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", + "shortName": "RegionHealthCheckServicesClient" }, - "fullName": "google.cloud.compute_v1.RegionDisksClient.update", + "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.patch", "method": { - "fullName": "google.cloud.compute.v1.RegionDisks.Update", + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Patch", "service": { - "fullName": "google.cloud.compute.v1.RegionDisks", - "shortName": "RegionDisks" + "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", + "shortName": "RegionHealthCheckServices" }, - "shortName": "Update" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdateRegionDiskRequest" + "type": "google.cloud.compute_v1.types.PatchRegionHealthCheckServiceRequest" }, { "name": "project", @@ -38889,12 +39861,12 @@ "type": "str" }, { - "name": "disk", + "name": "health_check_service", "type": "str" }, { - "name": "disk_resource", - "type": "google.cloud.compute_v1.types.Disk" + "name": "health_check_service_resource", + "type": "google.cloud.compute_v1.types.HealthCheckService" }, { "name": "retry", @@ -38906,17 +39878,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update" + "shortName": "patch" }, - "description": "Sample for Update", - "file": "compute_v1_generated_region_disks_update_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_region_health_check_services_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionDisks_Update_sync", + "regionTag": "compute_v1_generated_RegionHealthCheckServices_Patch_sync", "segments": [ { "end": 53, @@ -38949,28 +39921,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_disks_update_sync.py" + "title": "compute_v1_generated_region_health_check_services_patch_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", - "shortName": "RegionHealthCheckServicesClient" + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", + "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.delete", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.delete", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Delete", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Delete", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", - "shortName": "RegionHealthCheckServices" + "fullName": "google.cloud.compute.v1.RegionHealthChecks", + "shortName": "RegionHealthChecks" }, "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionHealthCheckServiceRequest" + "type": "google.cloud.compute_v1.types.DeleteRegionHealthCheckRequest" }, { "name": "project", @@ -38981,7 +39953,7 @@ "type": "str" }, { - "name": "health_check_service", + "name": "health_check", "type": "str" }, { @@ -38994,17 +39966,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", "shortName": "delete" }, "description": "Sample for Delete", - "file": "compute_v1_generated_region_health_check_services_delete_sync.py", + "file": "compute_v1_generated_region_health_checks_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthCheckServices_Delete_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_Delete_sync", "segments": [ { "end": 53, @@ -39037,28 +40009,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_check_services_delete_sync.py" + "title": "compute_v1_generated_region_health_checks_delete_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", - "shortName": "RegionHealthCheckServicesClient" + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", + "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.get", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Get", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Get", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", - "shortName": "RegionHealthCheckServices" + "fullName": "google.cloud.compute.v1.RegionHealthChecks", + "shortName": "RegionHealthChecks" }, "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionHealthCheckServiceRequest" + "type": "google.cloud.compute_v1.types.GetRegionHealthCheckRequest" }, { "name": "project", @@ -39069,7 +40041,7 @@ "type": "str" }, { - "name": "health_check_service", + "name": "health_check", "type": "str" }, { @@ -39082,17 +40054,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.HealthCheckService", + "resultType": "google.cloud.compute_v1.types.HealthCheck", "shortName": "get" }, "description": "Sample for Get", - "file": "compute_v1_generated_region_health_check_services_get_sync.py", + "file": "compute_v1_generated_region_health_checks_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthCheckServices_Get_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_Get_sync", "segments": [ { "end": 53, @@ -39125,28 +40097,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_check_services_get_sync.py" + "title": "compute_v1_generated_region_health_checks_get_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", - "shortName": "RegionHealthCheckServicesClient" + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", + "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.insert", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Insert", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Insert", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", - "shortName": "RegionHealthCheckServices" + "fullName": "google.cloud.compute.v1.RegionHealthChecks", + "shortName": "RegionHealthChecks" }, "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionHealthCheckServiceRequest" + "type": "google.cloud.compute_v1.types.InsertRegionHealthCheckRequest" }, { "name": "project", @@ -39157,8 +40129,8 @@ "type": "str" }, { - "name": "health_check_service_resource", - "type": "google.cloud.compute_v1.types.HealthCheckService" + "name": "health_check_resource", + "type": "google.cloud.compute_v1.types.HealthCheck" }, { "name": "retry", @@ -39170,17 +40142,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", "shortName": "insert" }, "description": "Sample for Insert", - "file": "compute_v1_generated_region_health_check_services_insert_sync.py", + "file": "compute_v1_generated_region_health_checks_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthCheckServices_Insert_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_Insert_sync", "segments": [ { "end": 52, @@ -39213,28 +40185,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_check_services_insert_sync.py" + "title": "compute_v1_generated_region_health_checks_insert_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", - "shortName": "RegionHealthCheckServicesClient" + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", + "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.list", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.List", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.List", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", - "shortName": "RegionHealthCheckServices" + "fullName": "google.cloud.compute.v1.RegionHealthChecks", + "shortName": "RegionHealthChecks" }, "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionHealthCheckServicesRequest" + "type": "google.cloud.compute_v1.types.ListRegionHealthChecksRequest" }, { "name": "project", @@ -39254,17 +40226,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_health_check_services.pagers.ListPager", + "resultType": "google.cloud.compute_v1.services.region_health_checks.pagers.ListPager", "shortName": "list" }, "description": "Sample for List", - "file": "compute_v1_generated_region_health_check_services_list_sync.py", + "file": "compute_v1_generated_region_health_checks_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthCheckServices_List_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_List_sync", "segments": [ { "end": 53, @@ -39297,28 +40269,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_check_services_list_sync.py" + "title": "compute_v1_generated_region_health_checks_list_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient", - "shortName": "RegionHealthCheckServicesClient" + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", + "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthCheckServicesClient.patch", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.patch", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices.Patch", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Patch", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthCheckServices", - "shortName": "RegionHealthCheckServices" + "fullName": "google.cloud.compute.v1.RegionHealthChecks", + "shortName": "RegionHealthChecks" }, "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionHealthCheckServiceRequest" + "type": "google.cloud.compute_v1.types.PatchRegionHealthCheckRequest" }, { "name": "project", @@ -39329,12 +40301,12 @@ "type": "str" }, { - "name": "health_check_service", + "name": "health_check", "type": "str" }, { - "name": "health_check_service_resource", - "type": "google.cloud.compute_v1.types.HealthCheckService" + "name": "health_check_resource", + "type": "google.cloud.compute_v1.types.HealthCheck" }, { "name": "retry", @@ -39346,17 +40318,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", "shortName": "patch" }, "description": "Sample for Patch", - "file": "compute_v1_generated_region_health_check_services_patch_sync.py", + "file": "compute_v1_generated_region_health_checks_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthCheckServices_Patch_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_Patch_sync", "segments": [ { "end": 53, @@ -39389,7 +40361,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_check_services_patch_sync.py" + "title": "compute_v1_generated_region_health_checks_patch_sync.py" }, { "canonical": true, @@ -39398,19 +40370,19 @@ "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", "shortName": "RegionHealthChecksClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.delete", + "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.update", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.Delete", + "fullName": "google.cloud.compute.v1.RegionHealthChecks.Update", "service": { "fullName": "google.cloud.compute.v1.RegionHealthChecks", "shortName": "RegionHealthChecks" }, - "shortName": "Delete" + "shortName": "Update" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionHealthCheckRequest" + "type": "google.cloud.compute_v1.types.UpdateRegionHealthCheckRequest" }, { "name": "project", @@ -39424,6 +40396,10 @@ "name": "health_check", "type": "str" }, + { + "name": "health_check_resource", + "type": "google.cloud.compute_v1.types.HealthCheck" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -39434,17 +40410,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "shortName": "update" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_region_health_checks_delete_sync.py", + "description": "Sample for Update", + "file": "compute_v1_generated_region_health_checks_update_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_Delete_sync", + "regionTag": "compute_v1_generated_RegionHealthChecks_Update_sync", "segments": [ { "end": 53, @@ -39477,28 +40453,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_delete_sync.py" + "title": "compute_v1_generated_region_health_checks_update_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", - "shortName": "RegionHealthChecksClient" + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", + "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.get", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.abandon_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.AbandonInstances", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks", - "shortName": "RegionHealthChecks" + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Get" + "shortName": "AbandonInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionHealthCheckRequest" + "type": "google.cloud.compute_v1.types.AbandonInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39509,9 +40485,13 @@ "type": "str" }, { - "name": "health_check", + "name": "instance_group_manager", "type": "str" }, + { + "name": "region_instance_group_managers_abandon_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersAbandonInstancesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -39522,17 +40502,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.HealthCheck", - "shortName": "get" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "abandon_instances" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_health_checks_get_sync.py", + "description": "Sample for AbandonInstances", + "file": "compute_v1_generated_region_instance_group_managers_abandon_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_Get_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_sync", "segments": [ { "end": 53, @@ -39565,28 +40545,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_get_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_abandon_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", - "shortName": "RegionHealthChecksClient" + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", + "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.insert", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.apply_updates_to_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.Insert", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ApplyUpdatesToInstances", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks", - "shortName": "RegionHealthChecks" + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Insert" + "shortName": "ApplyUpdatesToInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionHealthCheckRequest" + "type": "google.cloud.compute_v1.types.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39597,8 +40577,12 @@ "type": "str" }, { - "name": "health_check_resource", - "type": "google.cloud.compute_v1.types.HealthCheck" + "name": "instance_group_manager", + "type": "str" + }, + { + "name": "region_instance_group_managers_apply_updates_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersApplyUpdatesRequest" }, { "name": "retry", @@ -39610,25 +40594,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" + "shortName": "apply_updates_to_instances" }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_health_checks_insert_sync.py", + "description": "Sample for ApplyUpdatesToInstances", + "file": "compute_v1_generated_region_instance_group_managers_apply_updates_to_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_Insert_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_sync", "segments": [ { - "end": 52, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 53, "start": 27, "type": "SHORT" }, @@ -39638,43 +40622,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_insert_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_apply_updates_to_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", - "shortName": "RegionHealthChecksClient" + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", + "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.list", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.create_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.CreateInstances", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks", - "shortName": "RegionHealthChecks" + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "shortName": "RegionInstanceGroupManagers" }, - "shortName": "List" + "shortName": "CreateInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionHealthChecksRequest" + "type": "google.cloud.compute_v1.types.CreateInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39684,6 +40668,14 @@ "name": "region", "type": "str" }, + { + "name": "instance_group_manager", + "type": "str" + }, + { + "name": "region_instance_group_managers_create_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersCreateInstancesRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -39694,17 +40686,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_health_checks.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "create_instances" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_health_checks_list_sync.py", + "description": "Sample for CreateInstances", + "file": "compute_v1_generated_region_instance_group_managers_create_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_List_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_sync", "segments": [ { "end": 53, @@ -39722,43 +40714,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_list_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_create_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", - "shortName": "RegionHealthChecksClient" + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", + "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.patch", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.Patch", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeleteInstances", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks", - "shortName": "RegionHealthChecks" + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Patch" + "shortName": "DeleteInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionHealthCheckRequest" + "type": "google.cloud.compute_v1.types.DeleteInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39769,12 +40761,12 @@ "type": "str" }, { - "name": "health_check", + "name": "instance_group_manager", "type": "str" }, { - "name": "health_check_resource", - "type": "google.cloud.compute_v1.types.HealthCheck" + "name": "region_instance_group_managers_delete_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersDeleteInstancesRequest" }, { "name": "retry", @@ -39786,17 +40778,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "shortName": "delete_instances" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_region_health_checks_patch_sync.py", + "description": "Sample for DeleteInstances", + "file": "compute_v1_generated_region_instance_group_managers_delete_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_Patch_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_sync", "segments": [ { "end": 53, @@ -39829,28 +40821,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_patch_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_delete_instances_sync.py" }, { "canonical": true, "clientMethod": { "client": { - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient", - "shortName": "RegionHealthChecksClient" + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", + "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionHealthChecksClient.update", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete_per_instance_configs", "method": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks.Update", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeletePerInstanceConfigs", "service": { - "fullName": "google.cloud.compute.v1.RegionHealthChecks", - "shortName": "RegionHealthChecks" + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", + "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Update" + "shortName": "DeletePerInstanceConfigs" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.UpdateRegionHealthCheckRequest" + "type": "google.cloud.compute_v1.types.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39861,12 +40853,12 @@ "type": "str" }, { - "name": "health_check", + "name": "instance_group_manager", "type": "str" }, { - "name": "health_check_resource", - "type": "google.cloud.compute_v1.types.HealthCheck" + "name": "region_instance_group_manager_delete_instance_config_req_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagerDeleteInstanceConfigReq" }, { "name": "retry", @@ -39878,17 +40870,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "update" + "shortName": "delete_per_instance_configs" }, - "description": "Sample for Update", - "file": "compute_v1_generated_region_health_checks_update_sync.py", + "description": "Sample for DeletePerInstanceConfigs", + "file": "compute_v1_generated_region_instance_group_managers_delete_per_instance_configs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionHealthChecks_Update_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_sync", "segments": [ { "end": 53, @@ -39921,7 +40913,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_health_checks_update_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_delete_per_instance_configs_sync.py" }, { "canonical": true, @@ -39930,19 +40922,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.abandon_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.AbandonInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Delete", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "AbandonInstances" + "shortName": "Delete" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.AbandonInstancesRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.DeleteRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -39956,10 +40948,6 @@ "name": "instance_group_manager", "type": "str" }, - { - "name": "region_instance_group_managers_abandon_instances_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersAbandonInstancesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -39970,17 +40958,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "abandon_instances" + "shortName": "delete" }, - "description": "Sample for AbandonInstances", - "file": "compute_v1_generated_region_instance_group_managers_abandon_instances_sync.py", + "description": "Sample for Delete", + "file": "compute_v1_generated_region_instance_group_managers_delete_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_AbandonInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Delete_sync", "segments": [ { "end": 53, @@ -40013,7 +41001,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_abandon_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_delete_sync.py" }, { "canonical": true, @@ -40022,19 +41010,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.apply_updates_to_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.get", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ApplyUpdatesToInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Get", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "ApplyUpdatesToInstances" + "shortName": "Get" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.GetRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40048,10 +41036,6 @@ "name": "instance_group_manager", "type": "str" }, - { - "name": "region_instance_group_managers_apply_updates_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersApplyUpdatesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40062,17 +41046,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "apply_updates_to_instances" + "resultType": "google.cloud.compute_v1.types.InstanceGroupManager", + "shortName": "get" }, - "description": "Sample for ApplyUpdatesToInstances", - "file": "compute_v1_generated_region_instance_group_managers_apply_updates_to_instances_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_instance_group_managers_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ApplyUpdatesToInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Get_sync", "segments": [ { "end": 53, @@ -40105,7 +41089,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_apply_updates_to_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_get_sync.py" }, { "canonical": true, @@ -40114,19 +41098,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.create_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.CreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Insert", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "CreateInstances" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.CreateInstancesRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.InsertRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40137,12 +41121,8 @@ "type": "str" }, { - "name": "instance_group_manager", - "type": "str" - }, - { - "name": "region_instance_group_managers_create_instances_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersCreateInstancesRequest" + "name": "instance_group_manager_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManager" }, { "name": "retry", @@ -40154,25 +41134,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "create_instances" + "shortName": "insert" }, - "description": "Sample for CreateInstances", - "file": "compute_v1_generated_region_instance_group_managers_create_instances_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_instance_group_managers_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_CreateInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Insert_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -40182,22 +41162,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_create_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_insert_sync.py" }, { "canonical": true, @@ -40206,19 +41186,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_errors", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeleteInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListErrors", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "DeleteInstances" + "shortName": "ListErrors" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteInstancesRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ListErrorsRegionInstanceGroupManagersRequest" }, { "name": "project", @@ -40232,10 +41212,6 @@ "name": "instance_group_manager", "type": "str" }, - { - "name": "region_instance_group_managers_delete_instances_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersDeleteInstancesRequest" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40246,25 +41222,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete_instances" + "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListErrorsPager", + "shortName": "list_errors" }, - "description": "Sample for DeleteInstances", - "file": "compute_v1_generated_region_instance_group_managers_delete_instances_sync.py", + "description": "Sample for ListErrors", + "file": "compute_v1_generated_region_instance_group_managers_list_errors_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeleteInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListErrors_sync", "segments": [ { - "end": 53, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 54, "start": 27, "type": "SHORT" }, @@ -40284,12 +41260,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 55, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_delete_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_list_errors_sync.py" }, { "canonical": true, @@ -40298,19 +41274,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete_per_instance_configs", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_managed_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.DeletePerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListManagedInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "DeletePerInstanceConfigs" + "shortName": "ListManagedInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ListManagedInstancesRegionInstanceGroupManagersRequest" }, { "name": "project", @@ -40324,10 +41300,6 @@ "name": "instance_group_manager", "type": "str" }, - { - "name": "region_instance_group_manager_delete_instance_config_req_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagerDeleteInstanceConfigReq" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40338,25 +41310,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete_per_instance_configs" + "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListManagedInstancesPager", + "shortName": "list_managed_instances" }, - "description": "Sample for DeletePerInstanceConfigs", - "file": "compute_v1_generated_region_instance_group_managers_delete_per_instance_configs_sync.py", + "description": "Sample for ListManagedInstances", + "file": "compute_v1_generated_region_instance_group_managers_list_managed_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_DeletePerInstanceConfigs_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_sync", "segments": [ { - "end": 53, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 54, "start": 27, "type": "SHORT" }, @@ -40376,12 +41348,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 55, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_delete_per_instance_configs_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_list_managed_instances_sync.py" }, { "canonical": true, @@ -40390,19 +41362,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.delete", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_per_instance_configs", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Delete", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListPerInstanceConfigs", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Delete" + "shortName": "ListPerInstanceConfigs" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.DeleteRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ListPerInstanceConfigsRegionInstanceGroupManagersRequest" }, { "name": "project", @@ -40426,25 +41398,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListPerInstanceConfigsPager", + "shortName": "list_per_instance_configs" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_region_instance_group_managers_delete_sync.py", + "description": "Sample for ListPerInstanceConfigs", + "file": "compute_v1_generated_region_instance_group_managers_list_per_instance_configs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Delete_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_sync", "segments": [ { - "end": 53, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 54, "start": 27, "type": "SHORT" }, @@ -40464,12 +41436,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 54, + "end": 55, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_delete_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_list_per_instance_configs_sync.py" }, { "canonical": true, @@ -40478,19 +41450,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.get", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Get", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.List", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Get" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ListRegionInstanceGroupManagersRequest" }, { "name": "project", @@ -40500,10 +41472,6 @@ "name": "region", "type": "str" }, - { - "name": "instance_group_manager", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40514,17 +41482,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.InstanceGroupManager", - "shortName": "get" + "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_instance_group_managers_get_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_instance_group_managers_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Get_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_List_sync", "segments": [ { "end": 53, @@ -40541,94 +41509,6 @@ "start": 38, "type": "CLIENT_INITIALIZATION" }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "compute_v1_generated_region_instance_group_managers_get_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", - "shortName": "RegionInstanceGroupManagersClient" - }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.insert", - "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Insert", - "service": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", - "shortName": "RegionInstanceGroupManagers" - }, - "shortName": "Insert" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionInstanceGroupManagerRequest" - }, - { - "name": "project", - "type": "str" - }, - { - "name": "region", - "type": "str" - }, - { - "name": "instance_group_manager_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupManager" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" - }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_instance_group_managers_insert_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Insert_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, { "end": 46, "start": 41, @@ -40640,12 +41520,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 54, "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_insert_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_list_sync.py" }, { "canonical": true, @@ -40654,19 +41534,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_errors", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.patch_per_instance_configs", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListErrors", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.PatchPerInstanceConfigs", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "ListErrors" + "shortName": "PatchPerInstanceConfigs" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListErrorsRegionInstanceGroupManagersRequest" + "type": "google.cloud.compute_v1.types.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40680,6 +41560,10 @@ "name": "instance_group_manager", "type": "str" }, + { + "name": "region_instance_group_manager_patch_instance_config_req_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagerPatchInstanceConfigReq" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40690,25 +41574,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListErrorsPager", - "shortName": "list_errors" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "patch_per_instance_configs" }, - "description": "Sample for ListErrors", - "file": "compute_v1_generated_region_instance_group_managers_list_errors_sync.py", + "description": "Sample for PatchPerInstanceConfigs", + "file": "compute_v1_generated_region_instance_group_managers_patch_per_instance_configs_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListErrors_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_sync", "segments": [ { - "end": 54, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 53, "start": 27, "type": "SHORT" }, @@ -40728,12 +41612,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 55, + "end": 54, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_list_errors_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_patch_per_instance_configs_sync.py" }, { "canonical": true, @@ -40742,19 +41626,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_managed_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.patch", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListManagedInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Patch", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "ListManagedInstances" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListManagedInstancesRegionInstanceGroupManagersRequest" + "type": "google.cloud.compute_v1.types.PatchRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40768,6 +41652,10 @@ "name": "instance_group_manager", "type": "str" }, + { + "name": "instance_group_manager_resource", + "type": "google.cloud.compute_v1.types.InstanceGroupManager" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40778,25 +41666,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListManagedInstancesPager", - "shortName": "list_managed_instances" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "patch" }, - "description": "Sample for ListManagedInstances", - "file": "compute_v1_generated_region_instance_group_managers_list_managed_instances_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_region_instance_group_managers_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListManagedInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Patch_sync", "segments": [ { - "end": 54, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 53, "start": 27, "type": "SHORT" }, @@ -40816,12 +41704,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 55, + "end": 54, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_list_managed_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_patch_sync.py" }, { "canonical": true, @@ -40830,19 +41718,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list_per_instance_configs", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.recreate_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ListPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.RecreateInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "ListPerInstanceConfigs" + "shortName": "RecreateInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListPerInstanceConfigsRegionInstanceGroupManagersRequest" + "type": "google.cloud.compute_v1.types.RecreateInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40856,6 +41744,10 @@ "name": "instance_group_manager", "type": "str" }, + { + "name": "region_instance_group_managers_recreate_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersRecreateRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40866,25 +41758,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListPerInstanceConfigsPager", - "shortName": "list_per_instance_configs" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "recreate_instances" }, - "description": "Sample for ListPerInstanceConfigs", - "file": "compute_v1_generated_region_instance_group_managers_list_per_instance_configs_sync.py", + "description": "Sample for RecreateInstances", + "file": "compute_v1_generated_region_instance_group_managers_recreate_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ListPerInstanceConfigs_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_sync", "segments": [ { - "end": 54, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 53, "start": 27, "type": "SHORT" }, @@ -40904,12 +41796,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 55, + "end": 54, "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_list_per_instance_configs_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_recreate_instances_sync.py" }, { "canonical": true, @@ -40918,19 +41810,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.list", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.resize", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.List", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Resize", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "List" + "shortName": "Resize" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionInstanceGroupManagersRequest" + "type": "google.cloud.compute_v1.types.ResizeRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -40940,6 +41832,14 @@ "name": "region", "type": "str" }, + { + "name": "instance_group_manager", + "type": "str" + }, + { + "name": "size", + "type": "int" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -40950,25 +41850,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_instance_group_managers.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "resize" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_instance_group_managers_list_sync.py", + "description": "Sample for Resize", + "file": "compute_v1_generated_region_instance_group_managers_resize_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_List_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Resize_sync", "segments": [ { - "end": 53, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 54, "start": 27, "type": "SHORT" }, @@ -40978,22 +41878,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 51, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 50, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_list_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_resize_sync.py" }, { "canonical": true, @@ -41002,19 +41902,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.patch_per_instance_configs", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.resume_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.PatchPerInstanceConfigs", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.ResumeInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "PatchPerInstanceConfigs" + "shortName": "ResumeInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.ResumeInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41029,8 +41929,8 @@ "type": "str" }, { - "name": "region_instance_group_manager_patch_instance_config_req_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagerPatchInstanceConfigReq" + "name": "region_instance_group_managers_resume_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersResumeInstancesRequest" }, { "name": "retry", @@ -41042,17 +41942,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch_per_instance_configs" + "shortName": "resume_instances" }, - "description": "Sample for PatchPerInstanceConfigs", - "file": "compute_v1_generated_region_instance_group_managers_patch_per_instance_configs_sync.py", + "description": "Sample for ResumeInstances", + "file": "compute_v1_generated_region_instance_group_managers_resume_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_PatchPerInstanceConfigs_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_ResumeInstances_sync", "segments": [ { "end": 53, @@ -41085,7 +41985,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_patch_per_instance_configs_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_resume_instances_sync.py" }, { "canonical": true, @@ -41094,19 +41994,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.patch", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.set_instance_template", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Patch", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetInstanceTemplate", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Patch" + "shortName": "SetInstanceTemplate" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41121,8 +42021,8 @@ "type": "str" }, { - "name": "instance_group_manager_resource", - "type": "google.cloud.compute_v1.types.InstanceGroupManager" + "name": "region_instance_group_managers_set_template_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest" }, { "name": "retry", @@ -41134,17 +42034,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "shortName": "set_instance_template" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_region_instance_group_managers_patch_sync.py", + "description": "Sample for SetInstanceTemplate", + "file": "compute_v1_generated_region_instance_group_managers_set_instance_template_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Patch_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_sync", "segments": [ { "end": 53, @@ -41177,7 +42077,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_patch_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_set_instance_template_sync.py" }, { "canonical": true, @@ -41186,19 +42086,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.recreate_instances", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.set_target_pools", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.RecreateInstances", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetTargetPools", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "RecreateInstances" + "shortName": "SetTargetPools" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.RecreateInstancesRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41213,8 +42113,8 @@ "type": "str" }, { - "name": "region_instance_group_managers_recreate_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersRecreateRequest" + "name": "region_instance_group_managers_set_target_pools_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest" }, { "name": "retry", @@ -41226,17 +42126,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "recreate_instances" + "shortName": "set_target_pools" }, - "description": "Sample for RecreateInstances", - "file": "compute_v1_generated_region_instance_group_managers_recreate_instances_sync.py", + "description": "Sample for SetTargetPools", + "file": "compute_v1_generated_region_instance_group_managers_set_target_pools_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_RecreateInstances_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_sync", "segments": [ { "end": 53, @@ -41269,7 +42169,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_recreate_instances_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_set_target_pools_sync.py" }, { "canonical": true, @@ -41278,19 +42178,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.resize", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.start_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.Resize", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.StartInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "Resize" + "shortName": "StartInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.ResizeRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.StartInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41305,8 +42205,8 @@ "type": "str" }, { - "name": "size", - "type": "int" + "name": "region_instance_group_managers_start_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersStartInstancesRequest" }, { "name": "retry", @@ -41318,25 +42218,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "resize" + "shortName": "start_instances" }, - "description": "Sample for Resize", - "file": "compute_v1_generated_region_instance_group_managers_resize_sync.py", + "description": "Sample for StartInstances", + "file": "compute_v1_generated_region_instance_group_managers_start_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_Resize_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_StartInstances_sync", "segments": [ { - "end": 54, + "end": 53, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 53, "start": 27, "type": "SHORT" }, @@ -41346,22 +42246,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 48, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 49, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 54, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_resize_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_start_instances_sync.py" }, { "canonical": true, @@ -41370,19 +42270,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.set_instance_template", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.stop_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetInstanceTemplate", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.StopInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "SetInstanceTemplate" + "shortName": "StopInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetInstanceTemplateRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.StopInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41397,8 +42297,8 @@ "type": "str" }, { - "name": "region_instance_group_managers_set_template_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTemplateRequest" + "name": "region_instance_group_managers_stop_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersStopInstancesRequest" }, { "name": "retry", @@ -41410,17 +42310,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_instance_template" + "shortName": "stop_instances" }, - "description": "Sample for SetInstanceTemplate", - "file": "compute_v1_generated_region_instance_group_managers_set_instance_template_sync.py", + "description": "Sample for StopInstances", + "file": "compute_v1_generated_region_instance_group_managers_stop_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetInstanceTemplate_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_StopInstances_sync", "segments": [ { "end": 53, @@ -41453,7 +42353,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_set_instance_template_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_stop_instances_sync.py" }, { "canonical": true, @@ -41462,19 +42362,19 @@ "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient", "shortName": "RegionInstanceGroupManagersClient" }, - "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.set_target_pools", + "fullName": "google.cloud.compute_v1.RegionInstanceGroupManagersClient.suspend_instances", "method": { - "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SetTargetPools", + "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers.SuspendInstances", "service": { "fullName": "google.cloud.compute.v1.RegionInstanceGroupManagers", "shortName": "RegionInstanceGroupManagers" }, - "shortName": "SetTargetPools" + "shortName": "SuspendInstances" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.SetTargetPoolsRegionInstanceGroupManagerRequest" + "type": "google.cloud.compute_v1.types.SuspendInstancesRegionInstanceGroupManagerRequest" }, { "name": "project", @@ -41489,8 +42389,8 @@ "type": "str" }, { - "name": "region_instance_group_managers_set_target_pools_request_resource", - "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersSetTargetPoolsRequest" + "name": "region_instance_group_managers_suspend_instances_request_resource", + "type": "google.cloud.compute_v1.types.RegionInstanceGroupManagersSuspendInstancesRequest" }, { "name": "retry", @@ -41502,17 +42402,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "set_target_pools" + "shortName": "suspend_instances" }, - "description": "Sample for SetTargetPools", - "file": "compute_v1_generated_region_instance_group_managers_set_target_pools_sync.py", + "description": "Sample for SuspendInstances", + "file": "compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SetTargetPools_sync", + "regionTag": "compute_v1_generated_RegionInstanceGroupManagers_SuspendInstances_sync", "segments": [ { "end": 53, @@ -41545,7 +42445,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_instance_group_managers_set_target_pools_sync.py" + "title": "compute_v1_generated_region_instance_group_managers_suspend_instances_sync.py" }, { "canonical": true, @@ -41594,7 +42494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -41682,7 +42582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceGroup", @@ -41774,7 +42674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_instance_groups.pagers.ListInstancesPager", @@ -41858,7 +42758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_instance_groups.pagers.ListPager", @@ -41950,7 +42850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42038,7 +42938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42126,7 +43026,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstanceTemplate", @@ -42214,7 +43114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42298,7 +43198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_instance_templates.pagers.ListPager", @@ -42386,7 +43286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42474,7 +43374,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42562,7 +43462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -42650,7 +43550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.InstantSnapshot", @@ -42738,7 +43638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -42822,7 +43722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_instant_snapshots.pagers.ListPager", @@ -42914,7 +43814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -43006,7 +43906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43098,7 +43998,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -43190,7 +44090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43278,7 +44178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43370,7 +44270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43458,7 +44358,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NetworkEndpointGroup", @@ -43546,7 +44446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43634,7 +44534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_network_endpoint_groups.pagers.ListNetworkEndpointsPager", @@ -43718,7 +44618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_network_endpoint_groups.pagers.ListPager", @@ -43810,7 +44710,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43902,7 +44802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -43990,7 +44890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -44078,7 +44978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -44166,7 +45066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyAssociation", @@ -44254,7 +45154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse", @@ -44342,7 +45242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -44430,7 +45330,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicyRule", @@ -44518,7 +45418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.FirewallPolicy", @@ -44606,7 +45506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -44690,7 +45590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_network_firewall_policies.pagers.ListPager", @@ -44782,7 +45682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -44874,7 +45774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -44962,7 +45862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -45050,7 +45950,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -45142,7 +46042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -45234,7 +46134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -45322,7 +46222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -45410,7 +46310,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NotificationEndpoint", @@ -45498,7 +46398,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -45582,7 +46482,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_notification_endpoints.pagers.ListPager", @@ -45670,7 +46570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.DeleteRegionOperationResponse", @@ -45758,7 +46658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -45842,7 +46742,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_operations.pagers.ListPager", @@ -45930,7 +46830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -46022,7 +46922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -46110,17 +47010,193 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "delete" + }, + "description": "Sample for Delete", + "file": "compute_v1_generated_region_security_policies_delete_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Delete_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_security_policies_delete_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", + "shortName": "RegionSecurityPoliciesClient" + }, + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.get_rule", + "method": { + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.GetRule", + "service": { + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", + "shortName": "RegionSecurityPolicies" + }, + "shortName": "GetRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.GetRuleRegionSecurityPolicyRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "security_policy", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.types.SecurityPolicyRule", + "shortName": "get_rule" + }, + "description": "Sample for GetRule", + "file": "compute_v1_generated_region_security_policies_get_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_GetRule_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_region_security_policies_get_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", + "shortName": "RegionSecurityPoliciesClient" + }, + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.get", + "method": { + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Get", + "service": { + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", + "shortName": "RegionSecurityPolicies" + }, + "shortName": "Get" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.GetRegionSecurityPolicyRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "region", + "type": "str" + }, + { + "name": "security_policy", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "delete" + "resultType": "google.cloud.compute_v1.types.SecurityPolicy", + "shortName": "get" }, - "description": "Sample for Delete", - "file": "compute_v1_generated_region_security_policies_delete_sync.py", + "description": "Sample for Get", + "file": "compute_v1_generated_region_security_policies_get_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_Delete_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Get_sync", "segments": [ { "end": 53, @@ -46153,7 +47229,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_delete_sync.py" + "title": "compute_v1_generated_region_security_policies_get_sync.py" }, { "canonical": true, @@ -46162,19 +47238,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.get_rule", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.insert", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.GetRule", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Insert", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "GetRule" + "shortName": "Insert" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRuleRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.InsertRegionSecurityPolicyRequest" }, { "name": "project", @@ -46185,8 +47261,8 @@ "type": "str" }, { - "name": "security_policy", - "type": "str" + "name": "security_policy_resource", + "type": "google.cloud.compute_v1.types.SecurityPolicy" }, { "name": "retry", @@ -46198,25 +47274,25 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.SecurityPolicyRule", - "shortName": "get_rule" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "insert" }, - "description": "Sample for GetRule", - "file": "compute_v1_generated_region_security_policies_get_rule_sync.py", + "description": "Sample for Insert", + "file": "compute_v1_generated_region_security_policies_insert_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_GetRule_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Insert_sync", "segments": [ { - "end": 53, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 52, "start": 27, "type": "SHORT" }, @@ -46226,22 +47302,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_get_rule_sync.py" + "title": "compute_v1_generated_region_security_policies_insert_sync.py" }, { "canonical": true, @@ -46250,19 +47326,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.get", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.list", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Get", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.List", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "Get" + "shortName": "List" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.GetRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.ListRegionSecurityPoliciesRequest" }, { "name": "project", @@ -46272,10 +47348,6 @@ "name": "region", "type": "str" }, - { - "name": "security_policy", - "type": "str" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -46286,17 +47358,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.types.SecurityPolicy", - "shortName": "get" + "resultType": "google.cloud.compute_v1.services.region_security_policies.pagers.ListPager", + "shortName": "list" }, - "description": "Sample for Get", - "file": "compute_v1_generated_region_security_policies_get_sync.py", + "description": "Sample for List", + "file": "compute_v1_generated_region_security_policies_list_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_Get_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_List_sync", "segments": [ { "end": 53, @@ -46314,22 +47386,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 47, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 51, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_get_sync.py" + "title": "compute_v1_generated_region_security_policies_list_sync.py" }, { "canonical": true, @@ -46338,19 +47410,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.insert", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.patch_rule", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Insert", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.PatchRule", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "Insert" + "shortName": "PatchRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.InsertRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.PatchRuleRegionSecurityPolicyRequest" }, { "name": "project", @@ -46361,92 +47433,12 @@ "type": "str" }, { - "name": "security_policy_resource", - "type": "google.cloud.compute_v1.types.SecurityPolicy" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "insert" - }, - "description": "Sample for Insert", - "file": "compute_v1_generated_region_security_policies_insert_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_Insert_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "compute_v1_generated_region_security_policies_insert_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", - "shortName": "RegionSecurityPoliciesClient" - }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.list", - "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.List", - "service": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", - "shortName": "RegionSecurityPolicies" - }, - "shortName": "List" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.compute_v1.types.ListRegionSecurityPoliciesRequest" - }, - { - "name": "project", + "name": "security_policy", "type": "str" }, { - "name": "region", - "type": "str" + "name": "security_policy_rule_resource", + "type": "google.cloud.compute_v1.types.SecurityPolicyRule" }, { "name": "retry", @@ -46458,17 +47450,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.compute_v1.services.region_security_policies.pagers.ListPager", - "shortName": "list" + "resultType": "google.api_core.extended_operation.ExtendedOperation", + "shortName": "patch_rule" }, - "description": "Sample for List", - "file": "compute_v1_generated_region_security_policies_list_sync.py", + "description": "Sample for PatchRule", + "file": "compute_v1_generated_region_security_policies_patch_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_List_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_PatchRule_sync", "segments": [ { "end": 53, @@ -46486,22 +47478,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 47, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 50, + "start": 48, "type": "REQUEST_EXECUTION" }, { "end": 54, - "start": 50, + "start": 51, "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_list_sync.py" + "title": "compute_v1_generated_region_security_policies_patch_rule_sync.py" }, { "canonical": true, @@ -46510,19 +47502,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.patch_rule", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.patch", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.PatchRule", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Patch", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "PatchRule" + "shortName": "Patch" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRuleRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.PatchRegionSecurityPolicyRequest" }, { "name": "project", @@ -46537,8 +47529,8 @@ "type": "str" }, { - "name": "security_policy_rule_resource", - "type": "google.cloud.compute_v1.types.SecurityPolicyRule" + "name": "security_policy_resource", + "type": "google.cloud.compute_v1.types.SecurityPolicy" }, { "name": "retry", @@ -46550,17 +47542,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch_rule" + "shortName": "patch" }, - "description": "Sample for PatchRule", - "file": "compute_v1_generated_region_security_policies_patch_rule_sync.py", + "description": "Sample for Patch", + "file": "compute_v1_generated_region_security_policies_patch_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_PatchRule_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_Patch_sync", "segments": [ { "end": 53, @@ -46593,7 +47585,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_patch_rule_sync.py" + "title": "compute_v1_generated_region_security_policies_patch_sync.py" }, { "canonical": true, @@ -46602,19 +47594,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.patch", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.remove_rule", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.Patch", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.RemoveRule", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "Patch" + "shortName": "RemoveRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.PatchRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.RemoveRuleRegionSecurityPolicyRequest" }, { "name": "project", @@ -46628,10 +47620,6 @@ "name": "security_policy", "type": "str" }, - { - "name": "security_policy_resource", - "type": "google.cloud.compute_v1.types.SecurityPolicy" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -46642,17 +47630,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "patch" + "shortName": "remove_rule" }, - "description": "Sample for Patch", - "file": "compute_v1_generated_region_security_policies_patch_sync.py", + "description": "Sample for RemoveRule", + "file": "compute_v1_generated_region_security_policies_remove_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_Patch_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_RemoveRule_sync", "segments": [ { "end": 53, @@ -46685,7 +47673,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_patch_sync.py" + "title": "compute_v1_generated_region_security_policies_remove_rule_sync.py" }, { "canonical": true, @@ -46694,19 +47682,19 @@ "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient", "shortName": "RegionSecurityPoliciesClient" }, - "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.remove_rule", + "fullName": "google.cloud.compute_v1.RegionSecurityPoliciesClient.set_labels", "method": { - "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.RemoveRule", + "fullName": "google.cloud.compute.v1.RegionSecurityPolicies.SetLabels", "service": { "fullName": "google.cloud.compute.v1.RegionSecurityPolicies", "shortName": "RegionSecurityPolicies" }, - "shortName": "RemoveRule" + "shortName": "SetLabels" }, "parameters": [ { "name": "request", - "type": "google.cloud.compute_v1.types.RemoveRuleRegionSecurityPolicyRequest" + "type": "google.cloud.compute_v1.types.SetLabelsRegionSecurityPolicyRequest" }, { "name": "project", @@ -46717,9 +47705,13 @@ "type": "str" }, { - "name": "security_policy", + "name": "resource", "type": "str" }, + { + "name": "region_set_labels_request_resource", + "type": "google.cloud.compute_v1.types.RegionSetLabelsRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -46730,17 +47722,17 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", - "shortName": "remove_rule" + "shortName": "set_labels" }, - "description": "Sample for RemoveRule", - "file": "compute_v1_generated_region_security_policies_remove_rule_sync.py", + "description": "Sample for SetLabels", + "file": "compute_v1_generated_region_security_policies_set_labels_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "compute_v1_generated_RegionSecurityPolicies_RemoveRule_sync", + "regionTag": "compute_v1_generated_RegionSecurityPolicies_SetLabels_sync", "segments": [ { "end": 53, @@ -46773,7 +47765,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "compute_v1_generated_region_security_policies_remove_rule_sync.py" + "title": "compute_v1_generated_region_security_policies_set_labels_sync.py" }, { "canonical": true, @@ -46818,7 +47810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -46906,7 +47898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslCertificate", @@ -46994,7 +47986,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47078,7 +48070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_ssl_certificates.pagers.ListPager", @@ -47166,7 +48158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47254,7 +48246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslPolicy", @@ -47342,7 +48334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47426,7 +48418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslPoliciesListAvailableFeaturesResponse", @@ -47510,7 +48502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_ssl_policies.pagers.ListPager", @@ -47602,7 +48594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47690,7 +48682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47778,7 +48770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetHttpProxy", @@ -47866,7 +48858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -47950,7 +48942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_target_http_proxies.pagers.ListPager", @@ -48042,7 +49034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48130,7 +49122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48218,7 +49210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetHttpsProxy", @@ -48306,7 +49298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48390,7 +49382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_target_https_proxies.pagers.ListPager", @@ -48482,7 +49474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48574,7 +49566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48666,7 +49658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48754,7 +49746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -48842,7 +49834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetTcpProxy", @@ -48930,7 +49922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -49014,7 +50006,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_target_tcp_proxies.pagers.ListPager", @@ -49102,7 +50094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -49190,7 +50182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.UrlMap", @@ -49278,7 +50270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -49362,7 +50354,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_url_maps.pagers.ListPager", @@ -49454,7 +50446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -49546,7 +50538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -49638,7 +50630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.UrlMapsValidateResponse", @@ -49722,7 +50714,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.region_zones.pagers.ListPager", @@ -49806,7 +50798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Region", @@ -49886,7 +50878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.regions.pagers.ListPager", @@ -49966,7 +50958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.reservations.pagers.AggregatedListPager", @@ -50054,7 +51046,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -50142,7 +51134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -50230,7 +51222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Reservation", @@ -50318,7 +51310,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -50402,7 +51394,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.reservations.pagers.ListPager", @@ -50494,7 +51486,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -50586,7 +51578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -50678,7 +51670,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -50770,7 +51762,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -50850,7 +51842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.resource_policies.pagers.AggregatedListPager", @@ -50938,7 +51930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -51026,7 +52018,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -51114,7 +52106,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ResourcePolicy", @@ -51202,7 +52194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -51286,7 +52278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.resource_policies.pagers.ListPager", @@ -51378,7 +52370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -51470,7 +52462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -51562,7 +52554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -51642,7 +52634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.routers.pagers.AggregatedListPager", @@ -51730,7 +52722,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -51818,7 +52810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.NatIpInfoResponse", @@ -51906,7 +52898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.routers.pagers.GetNatMappingInfoPager", @@ -51994,7 +52986,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.RouterStatusResponse", @@ -52082,7 +53074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Router", @@ -52170,7 +53162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -52254,7 +53246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.routers.pagers.ListPager", @@ -52346,7 +53338,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -52438,7 +53430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.RoutersPreviewResponse", @@ -52530,7 +53522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -52614,7 +53606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -52698,7 +53690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Route", @@ -52782,7 +53774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -52862,7 +53854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.routes.pagers.ListPager", @@ -52950,7 +53942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53030,7 +54022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.security_policies.pagers.AggregatedListPager", @@ -53114,7 +54106,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53198,7 +54190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SecurityPolicyRule", @@ -53282,7 +54274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SecurityPolicy", @@ -53366,7 +54358,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53446,7 +54438,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SecurityPoliciesListPreconfiguredExpressionSetsResponse", @@ -53526,7 +54518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.security_policies.pagers.ListPager", @@ -53614,7 +54606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53702,7 +54694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53786,7 +54778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53874,7 +54866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -53954,7 +54946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.service_attachments.pagers.AggregatedListPager", @@ -54042,7 +55034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -54130,7 +55122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -54218,7 +55210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.ServiceAttachment", @@ -54306,7 +55298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -54390,7 +55382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.service_attachments.pagers.ListPager", @@ -54482,7 +55474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -54574,7 +55566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -54666,7 +55658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -54746,7 +55738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SnapshotSettings", @@ -54830,7 +55822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -54914,7 +55906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -54998,7 +55990,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -55082,7 +56074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Snapshot", @@ -55166,7 +56158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -55246,7 +56238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.snapshots.pagers.ListPager", @@ -55334,7 +56326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -55422,7 +56414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -55510,7 +56502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -55590,7 +56582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.ssl_certificates.pagers.AggregatedListPager", @@ -55674,7 +56666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -55758,7 +56750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslCertificate", @@ -55842,7 +56834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -55922,7 +56914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.ssl_certificates.pagers.ListPager", @@ -56002,7 +56994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.ssl_policies.pagers.AggregatedListPager", @@ -56086,7 +57078,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -56170,7 +57162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslPolicy", @@ -56254,7 +57246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -56334,7 +57326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.SslPoliciesListAvailableFeaturesResponse", @@ -56414,7 +57406,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.ssl_policies.pagers.ListPager", @@ -56502,7 +57494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -56582,7 +57574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.storage_pool_types.pagers.AggregatedListPager", @@ -56670,7 +57662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.StoragePoolType", @@ -56754,7 +57746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.storage_pool_types.pagers.ListPager", @@ -56834,7 +57826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.storage_pools.pagers.AggregatedListPager", @@ -56922,7 +57914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -57010,7 +58002,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -57098,7 +58090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.StoragePool", @@ -57186,7 +58178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -57274,7 +58266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.storage_pools.pagers.ListDisksPager", @@ -57358,7 +58350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.storage_pools.pagers.ListPager", @@ -57450,7 +58442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -57542,7 +58534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -57634,7 +58626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -57714,7 +58706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.subnetworks.pagers.AggregatedListPager", @@ -57802,7 +58794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -57894,7 +58886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -57982,7 +58974,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -58070,7 +59062,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Subnetwork", @@ -58158,7 +59150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -58238,7 +59230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.subnetworks.pagers.ListUsablePager", @@ -58322,7 +59314,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.subnetworks.pagers.ListPager", @@ -58414,7 +59406,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -58506,7 +59498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Policy", @@ -58598,7 +59590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -58690,7 +59682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -58774,7 +59766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -58858,7 +59850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetGrpcProxy", @@ -58942,7 +59934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59022,7 +60014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_grpc_proxies.pagers.ListPager", @@ -59110,7 +60102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59190,7 +60182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_http_proxies.pagers.AggregatedListPager", @@ -59274,7 +60266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59358,7 +60350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetHttpProxy", @@ -59442,7 +60434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59522,7 +60514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_http_proxies.pagers.ListPager", @@ -59610,7 +60602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59698,7 +60690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59778,7 +60770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_https_proxies.pagers.AggregatedListPager", @@ -59862,7 +60854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -59946,7 +60938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetHttpsProxy", @@ -60030,7 +61022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60110,7 +61102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_https_proxies.pagers.ListPager", @@ -60198,7 +61190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60286,7 +61278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60374,7 +61366,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60462,7 +61454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60550,7 +61542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60638,7 +61630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60718,7 +61710,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_instances.pagers.AggregatedListPager", @@ -60806,7 +61798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -60894,7 +61886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetInstance", @@ -60982,7 +61974,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61066,7 +62058,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_instances.pagers.ListPager", @@ -61158,7 +62150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61250,7 +62242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61342,7 +62334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61422,7 +62414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_pools.pagers.AggregatedListPager", @@ -61510,7 +62502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61602,7 +62594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetPoolInstanceHealth", @@ -61690,7 +62682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetPool", @@ -61778,7 +62770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -61862,7 +62854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_pools.pagers.ListPager", @@ -61954,7 +62946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62046,7 +63038,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62138,7 +63130,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62230,7 +63222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62314,7 +63306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62398,7 +63390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetSslProxy", @@ -62482,7 +63474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62562,7 +63554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_ssl_proxies.pagers.ListPager", @@ -62650,7 +63642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62738,7 +63730,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62826,7 +63818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -62914,7 +63906,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63002,7 +63994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63082,7 +64074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_tcp_proxies.pagers.AggregatedListPager", @@ -63166,7 +64158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63250,7 +64242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetTcpProxy", @@ -63334,7 +64326,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63414,7 +64406,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_tcp_proxies.pagers.ListPager", @@ -63502,7 +64494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63590,7 +64582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63670,7 +64662,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_vpn_gateways.pagers.AggregatedListPager", @@ -63758,7 +64750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -63846,7 +64838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TargetVpnGateway", @@ -63934,7 +64926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64018,7 +65010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.target_vpn_gateways.pagers.ListPager", @@ -64110,7 +65102,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64190,7 +65182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.url_maps.pagers.AggregatedListPager", @@ -64274,7 +65266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64358,7 +65350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.UrlMap", @@ -64442,7 +65434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64530,7 +65522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64610,7 +65602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.url_maps.pagers.ListPager", @@ -64698,7 +65690,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64786,7 +65778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -64874,7 +65866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.UrlMapsValidateResponse", @@ -64954,7 +65946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.vpn_gateways.pagers.AggregatedListPager", @@ -65042,7 +66034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -65130,7 +66122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.VpnGatewaysGetStatusResponse", @@ -65218,7 +66210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.VpnGateway", @@ -65306,7 +66298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -65390,7 +66382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.vpn_gateways.pagers.ListPager", @@ -65482,7 +66474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -65574,7 +66566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.TestPermissionsResponse", @@ -65654,7 +66646,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.vpn_tunnels.pagers.AggregatedListPager", @@ -65742,7 +66734,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -65830,7 +66822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.VpnTunnel", @@ -65918,7 +66910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -66002,7 +66994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.vpn_tunnels.pagers.ListPager", @@ -66094,7 +67086,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.extended_operation.ExtendedOperation", @@ -66182,7 +67174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.DeleteZoneOperationResponse", @@ -66270,7 +67262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -66354,7 +67346,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.zone_operations.pagers.ListPager", @@ -66442,7 +67434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Operation", @@ -66526,7 +67518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.types.Zone", @@ -66606,7 +67598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.compute_v1.services.zones.pagers.ListPager", diff --git a/packages/google-cloud-compute/scripts/fixup_compute_v1_keywords.py b/packages/google-cloud-compute/scripts/fixup_compute_v1_keywords.py index 16368ebf4939..d23baf82d5c1 100644 --- a/packages/google-cloud-compute/scripts/fixup_compute_v1_keywords.py +++ b/packages/google-cloud-compute/scripts/fixup_compute_v1_keywords.py @@ -129,6 +129,7 @@ class computeCallTransformer(cst.CSTTransformer): 'reset': ('instance', 'project', 'zone', 'request_id', ), 'resize': ('disk', 'disks_resize_request_resource', 'project', 'zone', 'request_id', ), 'resume': ('instance', 'project', 'zone', 'request_id', ), + 'resume_instances': ('instance_group_manager', 'instance_group_managers_resume_instances_request_resource', 'project', 'zone', 'request_id', ), 'send_diagnostic_interrupt': ('instance', 'project', 'zone', ), 'set_backend_service': ('project', 'target_ssl_proxies_set_backend_service_request_resource', 'target_ssl_proxy', 'request_id', ), 'set_backup': ('project', 'region', 'target_pool', 'target_reference_resource', 'failover_ratio', 'request_id', ), @@ -166,11 +167,14 @@ class computeCallTransformer(cst.CSTTransformer): 'simulate_maintenance_event': ('instance', 'project', 'zone', 'request_id', 'with_extended_notifications', ), 'start': ('instance', 'project', 'zone', 'request_id', ), 'start_async_replication': ('disk', 'disks_start_async_replication_request_resource', 'project', 'zone', 'request_id', ), + 'start_instances': ('instance_group_manager', 'instance_group_managers_start_instances_request_resource', 'project', 'zone', 'request_id', ), 'start_with_encryption_key': ('instance', 'instances_start_with_encryption_key_request_resource', 'project', 'zone', 'request_id', ), 'stop': ('instance', 'project', 'zone', 'discard_local_ssd', 'request_id', ), 'stop_async_replication': ('disk', 'project', 'zone', 'request_id', ), 'stop_group_async_replication': ('disks_stop_group_async_replication_resource_resource', 'project', 'zone', 'request_id', ), + 'stop_instances': ('instance_group_manager', 'instance_group_managers_stop_instances_request_resource', 'project', 'zone', 'request_id', ), 'suspend': ('instance', 'project', 'zone', 'discard_local_ssd', 'request_id', ), + 'suspend_instances': ('instance_group_manager', 'instance_group_managers_suspend_instances_request_resource', 'project', 'zone', 'request_id', ), 'switch_to_custom_mode': ('network', 'project', 'request_id', ), 'test_iam_permissions': ('project', 'resource', 'test_permissions_request_resource', ), 'update': ('autoscaler_resource', 'project', 'zone', 'autoscaler', 'request_id', ), diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_accelerator_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_accelerator_types.py index a554a17f9c63..332b851fa082 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_accelerator_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_accelerator_types.py @@ -1029,6 +1029,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1087,6 +1088,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1299,6 +1301,7 @@ def test_get_rest_required_fields(request_type=compute.GetAcceleratorTypeRequest 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(request) @@ -1359,6 +1362,7 @@ def test_get_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(**mock_args) @@ -1504,6 +1508,7 @@ def test_list_rest_required_fields(request_type=compute.ListAcceleratorTypesRequ 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(request) @@ -1566,6 +1571,7 @@ def test_list_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(**mock_args) @@ -1760,6 +1766,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1799,6 +1806,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -1843,6 +1851,7 @@ def test_aggregated_list_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 = compute.AcceleratorTypeAggregatedList.to_json( compute.AcceleratorTypeAggregatedList() ) @@ -1891,6 +1900,7 @@ def test_get_rest_bad_request(request_type=compute.GetAcceleratorTypeRequest): 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(request) @@ -1937,6 +1947,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1984,6 +1995,7 @@ def test_get_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 = compute.AcceleratorType.to_json(compute.AcceleratorType()) req.return_value.content = return_value @@ -2026,6 +2038,7 @@ def test_list_rest_bad_request(request_type=compute.ListAcceleratorTypesRequest) 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(request) @@ -2064,6 +2077,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2107,6 +2121,7 @@ def test_list_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 = compute.AcceleratorTypeList.to_json( compute.AcceleratorTypeList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_addresses.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_addresses.py index 52c35826df5c..c31ef30aa987 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_addresses.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_addresses.py @@ -987,6 +987,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1045,6 +1046,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1258,6 +1260,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteAddressRequest): 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(request) @@ -1318,6 +1321,7 @@ def test_delete_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.delete(**mock_args) @@ -1463,6 +1467,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteAddressReq 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_unary(request) @@ -1523,6 +1528,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1662,6 +1668,7 @@ def test_get_rest_required_fields(request_type=compute.GetAddressRequest): 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(request) @@ -1722,6 +1729,7 @@ def test_get_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(**mock_args) @@ -1864,6 +1872,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertAddressRequest): 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.insert(request) @@ -1920,6 +1929,7 @@ def test_insert_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.insert(**mock_args) @@ -2062,6 +2072,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertAddressReq 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.insert_unary(request) @@ -2118,6 +2129,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2263,6 +2275,7 @@ def test_list_rest_required_fields(request_type=compute.ListAddressesRequest): 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(request) @@ -2325,6 +2338,7 @@ def test_list_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(**mock_args) @@ -2531,6 +2545,7 @@ def test_move_rest_required_fields(request_type=compute.MoveAddressRequest): 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.move(request) @@ -2595,6 +2610,7 @@ def test_move_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.move(**mock_args) @@ -2744,6 +2760,7 @@ def test_move_unary_rest_required_fields(request_type=compute.MoveAddressRequest 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.move_unary(request) @@ -2808,6 +2825,7 @@ def test_move_unary_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.move_unary(**mock_args) @@ -2957,6 +2975,7 @@ def test_set_labels_rest_required_fields(request_type=compute.SetLabelsAddressRe 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_labels(request) @@ -3021,6 +3040,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3172,6 +3192,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3236,6 +3257,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3373,6 +3395,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3412,6 +3435,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3454,6 +3478,7 @@ def test_aggregated_list_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 = compute.AddressAggregatedList.to_json( compute.AddressAggregatedList() ) @@ -3498,6 +3523,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteAddressRequest): 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(request) @@ -3554,6 +3580,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3611,6 +3638,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3653,6 +3681,7 @@ def test_get_rest_bad_request(request_type=compute.GetAddressRequest): 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(request) @@ -3706,6 +3735,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3760,6 +3790,7 @@ def test_get_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 = compute.Address.to_json(compute.Address()) req.return_value.content = return_value @@ -3802,6 +3833,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertAddressRequest): 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.insert(request) @@ -3947,6 +3979,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.insert(request) # Establish that the response is the type that we expect. @@ -4004,6 +4037,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4046,6 +4080,7 @@ def test_list_rest_bad_request(request_type=compute.ListAddressesRequest): 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(request) @@ -4084,6 +4119,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4123,6 +4159,7 @@ def test_list_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 = compute.AddressList.to_json(compute.AddressList()) req.return_value.content = return_value @@ -4165,6 +4202,7 @@ def test_move_rest_bad_request(request_type=compute.MoveAddressRequest): 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.move(request) @@ -4303,6 +4341,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.move(request) # Establish that the response is the type that we expect. @@ -4360,6 +4399,7 @@ def test_move_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4402,6 +4442,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsAddressReques 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_labels(request) @@ -4537,6 +4578,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4596,6 +4638,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_autoscalers.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_autoscalers.py index 10367f5db405..e8db5d6b4b18 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_autoscalers.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_autoscalers.py @@ -995,6 +995,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1053,6 +1054,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1269,6 +1271,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteAutoscalerReques 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(request) @@ -1329,6 +1332,7 @@ def test_delete_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.delete(**mock_args) @@ -1476,6 +1480,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1536,6 +1541,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1675,6 +1681,7 @@ def test_get_rest_required_fields(request_type=compute.GetAutoscalerRequest): 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(request) @@ -1735,6 +1742,7 @@ def test_get_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(**mock_args) @@ -1877,6 +1885,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertAutoscalerReques 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.insert(request) @@ -1935,6 +1944,7 @@ def test_insert_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.insert(**mock_args) @@ -2081,6 +2091,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2139,6 +2150,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2286,6 +2298,7 @@ def test_list_rest_required_fields(request_type=compute.ListAutoscalersRequest): 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(request) @@ -2348,6 +2361,7 @@ def test_list_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(**mock_args) @@ -2555,6 +2569,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchAutoscalerRequest) 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.patch(request) @@ -2618,6 +2633,7 @@ def test_patch_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.patch(**mock_args) @@ -2767,6 +2783,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchAutoscalerRe 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.patch_unary(request) @@ -2830,6 +2847,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2979,6 +2997,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateAutoscalerReques 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(request) @@ -3042,6 +3061,7 @@ def test_update_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(**mock_args) @@ -3193,6 +3213,7 @@ def test_update_unary_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.update_unary(request) @@ -3256,6 +3277,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3392,6 +3414,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3431,6 +3454,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3475,6 +3499,7 @@ def test_aggregated_list_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 = compute.AutoscalerAggregatedList.to_json( compute.AutoscalerAggregatedList() ) @@ -3519,6 +3544,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteAutoscalerRequest): 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(request) @@ -3575,6 +3601,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3636,6 +3663,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3678,6 +3706,7 @@ def test_get_rest_bad_request(request_type=compute.GetAutoscalerRequest): 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(request) @@ -3723,6 +3752,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3771,6 +3801,7 @@ def test_get_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 = compute.Autoscaler.to_json(compute.Autoscaler()) req.return_value.content = return_value @@ -3813,6 +3844,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertAutoscalerRequest): 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.insert(request) @@ -3980,6 +4012,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.insert(request) # Establish that the response is the type that we expect. @@ -4041,6 +4074,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4083,6 +4117,7 @@ def test_list_rest_bad_request(request_type=compute.ListAutoscalersRequest): 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(request) @@ -4121,6 +4156,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4162,6 +4198,7 @@ def test_list_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 = compute.AutoscalerList.to_json(compute.AutoscalerList()) req.return_value.content = return_value @@ -4204,6 +4241,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchAutoscalerRequest): 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.patch(request) @@ -4371,6 +4409,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.patch(request) # Establish that the response is the type that we expect. @@ -4430,6 +4469,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4472,6 +4512,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateAutoscalerRequest): 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(request) @@ -4639,6 +4680,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(request) # Establish that the response is the type that we expect. @@ -4700,6 +4742,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_buckets.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_buckets.py index 83563aedffa0..5acf61735682 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_buckets.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_buckets.py @@ -1019,6 +1019,7 @@ def test_add_signed_url_key_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.add_signed_url_key(request) @@ -1075,6 +1076,7 @@ def test_add_signed_url_key_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.add_signed_url_key(**mock_args) @@ -1223,6 +1225,7 @@ def test_add_signed_url_key_unary_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.add_signed_url_key_unary(request) @@ -1279,6 +1282,7 @@ def test_add_signed_url_key_unary_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.add_signed_url_key_unary(**mock_args) @@ -1420,6 +1424,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteBackendBucketReq 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(request) @@ -1474,6 +1479,7 @@ def test_delete_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.delete(**mock_args) @@ -1616,6 +1622,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1670,6 +1677,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1829,6 +1837,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) @@ -1895,6 +1904,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(**mock_args) @@ -2055,6 +2065,7 @@ def test_delete_signed_url_key_unary_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.delete_signed_url_key_unary(request) @@ -2121,6 +2132,7 @@ def test_delete_signed_url_key_unary_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.delete_signed_url_key_unary(**mock_args) @@ -2256,6 +2268,7 @@ def test_get_rest_required_fields(request_type=compute.GetBackendBucketRequest): 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(request) @@ -2310,6 +2323,7 @@ def test_get_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(**mock_args) @@ -2448,6 +2462,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) @@ -2502,6 +2517,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) @@ -2639,6 +2655,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertBackendBucketReq 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.insert(request) @@ -2695,6 +2712,7 @@ def test_insert_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.insert(**mock_args) @@ -2836,6 +2854,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2892,6 +2911,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3034,6 +3054,7 @@ def test_list_rest_required_fields(request_type=compute.ListBackendBucketsReques 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(request) @@ -3090,6 +3111,7 @@ def test_list_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(**mock_args) @@ -3291,6 +3313,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchBackendBucketReque 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.patch(request) @@ -3349,6 +3372,7 @@ def test_patch_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.patch(**mock_args) @@ -3495,6 +3519,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3553,6 +3578,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3704,6 +3730,7 @@ def test_set_edge_security_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_edge_security_policy(request) @@ -3762,6 +3789,7 @@ def test_set_edge_security_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_edge_security_policy(**mock_args) @@ -3913,6 +3941,7 @@ def test_set_edge_security_policy_unary_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_edge_security_policy_unary(request) @@ -3971,6 +4000,7 @@ def test_set_edge_security_policy_unary_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_edge_security_policy_unary(**mock_args) @@ -4111,6 +4141,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) @@ -4169,6 +4200,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) @@ -4313,6 +4345,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) @@ -4371,6 +4404,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) @@ -4515,6 +4549,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateBackendBucketReq 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(request) @@ -4573,6 +4608,7 @@ def test_update_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(**mock_args) @@ -4719,6 +4755,7 @@ def test_update_unary_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.update_unary(request) @@ -4777,6 +4814,7 @@ def test_update_unary_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_unary(**mock_args) @@ -4913,6 +4951,7 @@ def test_add_signed_url_key_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.add_signed_url_key(request) @@ -5044,6 +5083,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.add_signed_url_key(request) # Establish that the response is the type that we expect. @@ -5105,6 +5145,7 @@ def test_add_signed_url_key_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5147,6 +5188,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteBackendBucketRequest 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(request) @@ -5203,6 +5245,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -5264,6 +5307,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5308,6 +5352,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) @@ -5364,6 +5409,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) # Establish that the response is the type that we expect. @@ -5425,6 +5471,7 @@ def test_delete_signed_url_key_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5467,6 +5514,7 @@ def test_get_rest_bad_request(request_type=compute.GetBackendBucketRequest): 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(request) @@ -5512,6 +5560,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5562,6 +5611,7 @@ def test_get_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 = compute.BackendBucket.to_json(compute.BackendBucket()) req.return_value.content = return_value @@ -5606,6 +5656,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) @@ -5643,6 +5694,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. @@ -5685,6 +5737,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5727,6 +5780,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertBackendBucketRequest 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.insert(request) @@ -5897,6 +5951,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.insert(request) # Establish that the response is the type that we expect. @@ -5958,6 +6013,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6000,6 +6056,7 @@ def test_list_rest_bad_request(request_type=compute.ListBackendBucketsRequest): 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(request) @@ -6038,6 +6095,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -6081,6 +6139,7 @@ def test_list_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 = compute.BackendBucketList.to_json(compute.BackendBucketList()) req.return_value.content = return_value @@ -6123,6 +6182,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchBackendBucketRequest): 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.patch(request) @@ -6293,6 +6353,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.patch(request) # Establish that the response is the type that we expect. @@ -6354,6 +6415,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6398,6 +6460,7 @@ def test_set_edge_security_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_edge_security_policy(request) @@ -6532,6 +6595,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.set_edge_security_policy(request) # Establish that the response is the type that we expect. @@ -6593,6 +6657,7 @@ def test_set_edge_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6637,6 +6702,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) @@ -6790,6 +6856,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -6832,6 +6899,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -6876,6 +6944,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) @@ -6989,6 +7058,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7029,6 +7099,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -7073,6 +7144,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateBackendBucketRequest 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(request) @@ -7243,6 +7315,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(request) # Establish that the response is the type that we expect. @@ -7304,6 +7377,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_services.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_services.py index 20bef7bb2d30..2a066c7451bd 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_services.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_backend_services.py @@ -1033,6 +1033,7 @@ def test_add_signed_url_key_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.add_signed_url_key(request) @@ -1089,6 +1090,7 @@ def test_add_signed_url_key_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.add_signed_url_key(**mock_args) @@ -1237,6 +1239,7 @@ def test_add_signed_url_key_unary_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.add_signed_url_key_unary(request) @@ -1293,6 +1296,7 @@ def test_add_signed_url_key_unary_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.add_signed_url_key_unary(**mock_args) @@ -1438,6 +1442,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1496,6 +1501,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1710,6 +1716,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteBackendServiceRe 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(request) @@ -1764,6 +1771,7 @@ def test_delete_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.delete(**mock_args) @@ -1906,6 +1914,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1960,6 +1969,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2119,6 +2129,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) @@ -2185,6 +2196,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(**mock_args) @@ -2345,6 +2357,7 @@ def test_delete_signed_url_key_unary_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.delete_signed_url_key_unary(request) @@ -2411,6 +2424,7 @@ def test_delete_signed_url_key_unary_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.delete_signed_url_key_unary(**mock_args) @@ -2546,6 +2560,7 @@ def test_get_rest_required_fields(request_type=compute.GetBackendServiceRequest) 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(request) @@ -2600,6 +2615,7 @@ def test_get_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(**mock_args) @@ -2737,6 +2753,7 @@ def test_get_health_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_health(request) @@ -2795,6 +2812,7 @@ def test_get_health_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_health(**mock_args) @@ -2936,6 +2954,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) @@ -2990,6 +3009,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) @@ -3127,6 +3147,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertBackendServiceRe 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.insert(request) @@ -3183,6 +3204,7 @@ def test_insert_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.insert(**mock_args) @@ -3324,6 +3346,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3380,6 +3403,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3522,6 +3546,7 @@ def test_list_rest_required_fields(request_type=compute.ListBackendServicesReque 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(request) @@ -3578,6 +3603,7 @@ def test_list_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(**mock_args) @@ -3780,6 +3806,7 @@ def test_list_usable_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.list_usable(request) @@ -3836,6 +3863,7 @@ def test_list_usable_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_usable(**mock_args) @@ -4037,6 +4065,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchBackendServiceRequ 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.patch(request) @@ -4095,6 +4124,7 @@ def test_patch_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.patch(**mock_args) @@ -4241,6 +4271,7 @@ def test_patch_unary_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.patch_unary(request) @@ -4299,6 +4330,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -4450,6 +4482,7 @@ def test_set_edge_security_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_edge_security_policy(request) @@ -4508,6 +4541,7 @@ def test_set_edge_security_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_edge_security_policy(**mock_args) @@ -4659,6 +4693,7 @@ def test_set_edge_security_policy_unary_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_edge_security_policy_unary(request) @@ -4717,6 +4752,7 @@ def test_set_edge_security_policy_unary_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_edge_security_policy_unary(**mock_args) @@ -4857,6 +4893,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) @@ -4915,6 +4952,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) @@ -5065,6 +5103,7 @@ def test_set_security_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_security_policy(request) @@ -5123,6 +5162,7 @@ def test_set_security_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_security_policy(**mock_args) @@ -5273,6 +5313,7 @@ def test_set_security_policy_unary_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_security_policy_unary(request) @@ -5331,6 +5372,7 @@ def test_set_security_policy_unary_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_security_policy_unary(**mock_args) @@ -5475,6 +5517,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) @@ -5533,6 +5576,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) @@ -5677,6 +5721,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateBackendServiceRe 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(request) @@ -5735,6 +5780,7 @@ def test_update_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(**mock_args) @@ -5881,6 +5927,7 @@ def test_update_unary_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.update_unary(request) @@ -5939,6 +5986,7 @@ def test_update_unary_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_unary(**mock_args) @@ -6075,6 +6123,7 @@ def test_add_signed_url_key_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.add_signed_url_key(request) @@ -6206,6 +6255,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.add_signed_url_key(request) # Establish that the response is the type that we expect. @@ -6267,6 +6317,7 @@ def test_add_signed_url_key_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6311,6 +6362,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -6350,6 +6402,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -6394,6 +6447,7 @@ def test_aggregated_list_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 = compute.BackendServiceAggregatedList.to_json( compute.BackendServiceAggregatedList() ) @@ -6438,6 +6492,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteBackendServiceReques 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(request) @@ -6494,6 +6549,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -6555,6 +6611,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6599,6 +6656,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) @@ -6655,6 +6713,7 @@ def test_delete_signed_url_key_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.delete_signed_url_key(request) # Establish that the response is the type that we expect. @@ -6716,6 +6775,7 @@ def test_delete_signed_url_key_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6758,6 +6818,7 @@ def test_get_rest_bad_request(request_type=compute.GetBackendServiceRequest): 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(request) @@ -6819,6 +6880,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -6885,6 +6947,7 @@ def test_get_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 = compute.BackendService.to_json(compute.BackendService()) req.return_value.content = return_value @@ -6929,6 +6992,7 @@ def test_get_health_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_health(request) @@ -7040,6 +7104,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.get_health(request) # Establish that the response is the type that we expect. @@ -7080,6 +7145,7 @@ def test_get_health_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 = compute.BackendServiceGroupHealth.to_json( compute.BackendServiceGroupHealth() ) @@ -7126,6 +7192,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) @@ -7163,6 +7230,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. @@ -7205,6 +7273,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -7247,6 +7316,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertBackendServiceReques 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.insert(request) @@ -7544,6 +7614,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.insert(request) # Establish that the response is the type that we expect. @@ -7605,6 +7676,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7647,6 +7719,7 @@ def test_list_rest_bad_request(request_type=compute.ListBackendServicesRequest): 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(request) @@ -7685,6 +7758,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -7728,6 +7802,7 @@ def test_list_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 = compute.BackendServiceList.to_json(compute.BackendServiceList()) req.return_value.content = return_value @@ -7772,6 +7847,7 @@ def test_list_usable_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.list_usable(request) @@ -7810,6 +7886,7 @@ def test_list_usable_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_usable(request) # Establish that the response is the type that we expect. @@ -7853,6 +7930,7 @@ def test_list_usable_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 = compute.BackendServiceListUsable.to_json( compute.BackendServiceListUsable() ) @@ -7897,6 +7975,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchBackendServiceRequest) 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.patch(request) @@ -8194,6 +8273,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.patch(request) # Establish that the response is the type that we expect. @@ -8255,6 +8335,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8299,6 +8380,7 @@ def test_set_edge_security_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_edge_security_policy(request) @@ -8433,6 +8515,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.set_edge_security_policy(request) # Establish that the response is the type that we expect. @@ -8494,6 +8577,7 @@ def test_set_edge_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8538,6 +8622,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) @@ -8691,6 +8776,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -8733,6 +8819,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -8777,6 +8864,7 @@ def test_set_security_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_security_policy(request) @@ -8911,6 +8999,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.set_security_policy(request) # Establish that the response is the type that we expect. @@ -8972,6 +9061,7 @@ def test_set_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9016,6 +9106,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) @@ -9129,6 +9220,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -9169,6 +9261,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -9213,6 +9306,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateBackendServiceReques 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(request) @@ -9510,6 +9604,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(request) # Establish that the response is the type that we expect. @@ -9571,6 +9666,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disk_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disk_types.py index 81d46d2759cb..cc53d755d9cf 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disk_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disk_types.py @@ -982,6 +982,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1040,6 +1041,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1247,6 +1249,7 @@ def test_get_rest_required_fields(request_type=compute.GetDiskTypeRequest): 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(request) @@ -1307,6 +1310,7 @@ def test_get_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(**mock_args) @@ -1452,6 +1456,7 @@ def test_list_rest_required_fields(request_type=compute.ListDiskTypesRequest): 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(request) @@ -1514,6 +1519,7 @@ def test_list_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(**mock_args) @@ -1708,6 +1714,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1747,6 +1754,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -1789,6 +1797,7 @@ def test_aggregated_list_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 = compute.DiskTypeAggregatedList.to_json( compute.DiskTypeAggregatedList() ) @@ -1833,6 +1842,7 @@ def test_get_rest_bad_request(request_type=compute.GetDiskTypeRequest): 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(request) @@ -1877,6 +1887,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1922,6 +1933,7 @@ def test_get_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 = compute.DiskType.to_json(compute.DiskType()) req.return_value.content = return_value @@ -1964,6 +1976,7 @@ def test_list_rest_bad_request(request_type=compute.ListDiskTypesRequest): 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(request) @@ -2002,6 +2015,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2041,6 +2055,7 @@ def test_list_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 = compute.DiskTypeList.to_json(compute.DiskTypeList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disks.py index 822ec1ab601b..0e0ca05287c5 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_disks.py @@ -974,6 +974,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -1034,6 +1035,7 @@ def test_add_resource_policies_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.add_resource_policies(**mock_args) @@ -1190,6 +1192,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(request) @@ -1250,6 +1253,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(**mock_args) @@ -1398,6 +1402,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1456,6 +1461,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1666,6 +1672,7 @@ def test_bulk_insert_rest_required_fields(request_type=compute.BulkInsertDiskReq 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.bulk_insert(request) @@ -1724,6 +1731,7 @@ def test_bulk_insert_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.bulk_insert(**mock_args) @@ -1870,6 +1878,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(request) @@ -1928,6 +1937,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(**mock_args) @@ -2083,6 +2093,7 @@ def test_create_snapshot_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.create_snapshot(request) @@ -2146,6 +2157,7 @@ def test_create_snapshot_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_snapshot(**mock_args) @@ -2300,6 +2312,7 @@ def test_create_snapshot_unary_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.create_snapshot_unary(request) @@ -2363,6 +2376,7 @@ def test_create_snapshot_unary_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_snapshot_unary(**mock_args) @@ -2509,6 +2523,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteDiskRequest): 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(request) @@ -2565,6 +2580,7 @@ def test_delete_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.delete(**mock_args) @@ -2710,6 +2726,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteDiskReques 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_unary(request) @@ -2766,6 +2783,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2905,6 +2923,7 @@ def test_get_rest_required_fields(request_type=compute.GetDiskRequest): 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(request) @@ -2961,6 +2980,7 @@ def test_get_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(**mock_args) @@ -3104,6 +3124,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) @@ -3164,6 +3185,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) @@ -3311,6 +3333,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertDiskRequest): 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.insert(request) @@ -3372,6 +3395,7 @@ def test_insert_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.insert(**mock_args) @@ -3519,6 +3543,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertDiskReques 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.insert_unary(request) @@ -3580,6 +3605,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3725,6 +3751,7 @@ def test_list_rest_required_fields(request_type=compute.ListDisksRequest): 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(request) @@ -3787,6 +3814,7 @@ def test_list_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(**mock_args) @@ -4000,6 +4028,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -4060,6 +4089,7 @@ def test_remove_resource_policies_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.remove_resource_policies(**mock_args) @@ -4216,6 +4246,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(request) @@ -4276,6 +4307,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(**mock_args) @@ -4425,6 +4457,7 @@ def test_resize_rest_required_fields(request_type=compute.ResizeDiskRequest): 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.resize(request) @@ -4483,6 +4516,7 @@ def test_resize_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.resize(**mock_args) @@ -4630,6 +4664,7 @@ def test_resize_unary_rest_required_fields(request_type=compute.ResizeDiskReques 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.resize_unary(request) @@ -4688,6 +4723,7 @@ def test_resize_unary_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.resize_unary(**mock_args) @@ -4831,6 +4867,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) @@ -4895,6 +4932,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) @@ -5044,6 +5082,7 @@ def test_set_labels_rest_required_fields(request_type=compute.SetLabelsDiskReque 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_labels(request) @@ -5108,6 +5147,7 @@ def test_set_labels_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_labels(**mock_args) @@ -5259,6 +5299,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -5323,6 +5364,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -5479,6 +5521,7 @@ def test_start_async_replication_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.start_async_replication(request) @@ -5539,6 +5582,7 @@ def test_start_async_replication_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.start_async_replication(**mock_args) @@ -5695,6 +5739,7 @@ def test_start_async_replication_unary_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.start_async_replication_unary(request) @@ -5755,6 +5800,7 @@ def test_start_async_replication_unary_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.start_async_replication_unary(**mock_args) @@ -5910,6 +5956,7 @@ def test_stop_async_replication_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.stop_async_replication(request) @@ -5966,6 +6013,7 @@ def test_stop_async_replication_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.stop_async_replication(**mock_args) @@ -6118,6 +6166,7 @@ def test_stop_async_replication_unary_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.stop_async_replication_unary(request) @@ -6174,6 +6223,7 @@ def test_stop_async_replication_unary_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.stop_async_replication_unary(**mock_args) @@ -6323,6 +6373,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(request) @@ -6381,6 +6432,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(**mock_args) @@ -6532,6 +6584,7 @@ def test_stop_group_async_replication_unary_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.stop_group_async_replication_unary(request) @@ -6590,6 +6643,7 @@ def test_stop_group_async_replication_unary_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.stop_group_async_replication_unary(**mock_args) @@ -6740,6 +6794,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) @@ -6804,6 +6859,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) @@ -6959,6 +7015,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateDiskRequest): 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(request) @@ -7023,6 +7080,7 @@ def test_update_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(**mock_args) @@ -7176,6 +7234,7 @@ def test_update_unary_rest_required_fields(request_type=compute.UpdateDiskReques 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_unary(request) @@ -7240,6 +7299,7 @@ def test_update_unary_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_unary(**mock_args) @@ -7375,6 +7435,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -7516,6 +7577,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.add_resource_policies(request) # Establish that the response is the type that we expect. @@ -7575,6 +7637,7 @@ def test_add_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7619,6 +7682,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -7658,6 +7722,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -7700,6 +7765,7 @@ def test_aggregated_list_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 = compute.DiskAggregatedList.to_json(compute.DiskAggregatedList()) req.return_value.content = return_value @@ -7742,6 +7808,7 @@ def test_bulk_insert_rest_bad_request(request_type=compute.BulkInsertDiskRequest 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.bulk_insert(request) @@ -7876,6 +7943,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.bulk_insert(request) # Establish that the response is the type that we expect. @@ -7933,6 +8001,7 @@ def test_bulk_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7977,6 +8046,7 @@ def test_create_snapshot_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.create_snapshot(request) @@ -8144,6 +8214,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_snapshot(request) # Establish that the response is the type that we expect. @@ -8203,6 +8274,7 @@ def test_create_snapshot_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8245,6 +8317,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteDiskRequest): 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(request) @@ -8301,6 +8374,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -8358,6 +8432,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8400,6 +8475,7 @@ def test_get_rest_bad_request(request_type=compute.GetDiskRequest): 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(request) @@ -8475,6 +8551,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -8557,6 +8634,7 @@ def test_get_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 = compute.Disk.to_json(compute.Disk()) req.return_value.content = return_value @@ -8599,6 +8677,7 @@ def test_get_iam_policy_rest_bad_request(request_type=compute.GetIamPolicyDiskRe 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) @@ -8636,6 +8715,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. @@ -8676,6 +8756,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -8718,6 +8799,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertDiskRequest): 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.insert(request) @@ -8907,6 +8989,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.insert(request) # Establish that the response is the type that we expect. @@ -8964,6 +9047,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9006,6 +9090,7 @@ def test_list_rest_bad_request(request_type=compute.ListDisksRequest): 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(request) @@ -9044,6 +9129,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -9083,6 +9169,7 @@ def test_list_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 = compute.DiskList.to_json(compute.DiskList()) req.return_value.content = return_value @@ -9127,6 +9214,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -9268,6 +9356,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.remove_resource_policies(request) # Establish that the response is the type that we expect. @@ -9327,6 +9416,7 @@ def test_remove_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9369,6 +9459,7 @@ def test_resize_rest_bad_request(request_type=compute.ResizeDiskRequest): 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.resize(request) @@ -9499,6 +9590,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.resize(request) # Establish that the response is the type that we expect. @@ -9556,6 +9648,7 @@ def test_resize_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9598,6 +9691,7 @@ def test_set_iam_policy_rest_bad_request(request_type=compute.SetIamPolicyDiskRe 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) @@ -9751,6 +9845,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -9791,6 +9886,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -9833,6 +9929,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsDiskRequest): 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_labels(request) @@ -9968,6 +10065,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.set_labels(request) # Establish that the response is the type that we expect. @@ -10025,6 +10123,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10069,6 +10168,7 @@ def test_start_async_replication_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.start_async_replication(request) @@ -10210,6 +10310,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.start_async_replication(request) # Establish that the response is the type that we expect. @@ -10269,6 +10370,7 @@ def test_start_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10313,6 +10415,7 @@ def test_stop_async_replication_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.stop_async_replication(request) @@ -10369,6 +10472,7 @@ def test_stop_async_replication_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.stop_async_replication(request) # Establish that the response is the type that we expect. @@ -10428,6 +10532,7 @@ def test_stop_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10472,6 +10577,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(request) @@ -10613,6 +10719,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.stop_group_async_replication(request) # Establish that the response is the type that we expect. @@ -10672,6 +10779,7 @@ def test_stop_group_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10716,6 +10824,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) @@ -10829,6 +10938,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -10867,6 +10977,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -10911,6 +11022,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateDiskRequest): 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(request) @@ -11100,6 +11212,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(request) # Establish that the response is the type that we expect. @@ -11157,6 +11270,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_external_vpn_gateways.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_external_vpn_gateways.py index 71d639a5ff35..052b17cf0be6 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_external_vpn_gateways.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_external_vpn_gateways.py @@ -1056,6 +1056,7 @@ def test_delete_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.delete(request) @@ -1110,6 +1111,7 @@ def test_delete_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.delete(**mock_args) @@ -1252,6 +1254,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1306,6 +1309,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1440,6 +1444,7 @@ def test_get_rest_required_fields(request_type=compute.GetExternalVpnGatewayRequ 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(request) @@ -1494,6 +1499,7 @@ def test_get_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(**mock_args) @@ -1633,6 +1639,7 @@ def test_insert_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.insert(request) @@ -1689,6 +1696,7 @@ def test_insert_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.insert(**mock_args) @@ -1830,6 +1838,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1886,6 +1895,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2028,6 +2038,7 @@ def test_list_rest_required_fields(request_type=compute.ListExternalVpnGatewaysR 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(request) @@ -2084,6 +2095,7 @@ def test_list_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(**mock_args) @@ -2285,6 +2297,7 @@ def test_set_labels_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_labels(request) @@ -2343,6 +2356,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2487,6 +2501,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2545,6 +2560,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -2689,6 +2705,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) @@ -2747,6 +2764,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) @@ -2881,6 +2899,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteExternalVpnGatewayRe 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(request) @@ -2937,6 +2956,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2998,6 +3018,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3040,6 +3061,7 @@ def test_get_rest_bad_request(request_type=compute.GetExternalVpnGatewayRequest) 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(request) @@ -3082,6 +3104,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3129,6 +3152,7 @@ def test_get_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 = compute.ExternalVpnGateway.to_json(compute.ExternalVpnGateway()) req.return_value.content = return_value @@ -3171,6 +3195,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertExternalVpnGatewayRe 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.insert(request) @@ -3320,6 +3345,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.insert(request) # Establish that the response is the type that we expect. @@ -3381,6 +3407,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3423,6 +3450,7 @@ def test_list_rest_bad_request(request_type=compute.ListExternalVpnGatewaysReque 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(request) @@ -3462,6 +3490,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3506,6 +3535,7 @@ def test_list_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 = compute.ExternalVpnGatewayList.to_json( compute.ExternalVpnGatewayList() ) @@ -3552,6 +3582,7 @@ def test_set_labels_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_labels(request) @@ -3687,6 +3718,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.set_labels(request) # Establish that the response is the type that we expect. @@ -3748,6 +3780,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3792,6 +3825,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) @@ -3905,6 +3939,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -3945,6 +3980,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewall_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewall_policies.py index 6753777e9064..d84d086889d4 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewall_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewall_policies.py @@ -1036,6 +1036,7 @@ def test_add_association_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.add_association(request) @@ -1097,6 +1098,7 @@ def test_add_association_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.add_association(**mock_args) @@ -1243,6 +1245,7 @@ def test_add_association_unary_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.add_association_unary(request) @@ -1304,6 +1307,7 @@ def test_add_association_unary_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.add_association_unary(**mock_args) @@ -1445,6 +1449,7 @@ def test_add_rule_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.add_rule(request) @@ -1501,6 +1506,7 @@ def test_add_rule_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.add_rule(**mock_args) @@ -1642,6 +1648,7 @@ def test_add_rule_unary_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.add_rule_unary(request) @@ -1698,6 +1705,7 @@ def test_add_rule_unary_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.add_rule_unary(**mock_args) @@ -1843,6 +1851,7 @@ def test_clone_rules_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.clone_rules(request) @@ -1896,6 +1905,7 @@ def test_clone_rules_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.clone_rules(**mock_args) @@ -2038,6 +2048,7 @@ def test_clone_rules_unary_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.clone_rules_unary(request) @@ -2091,6 +2102,7 @@ def test_clone_rules_unary_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.clone_rules_unary(**mock_args) @@ -2226,6 +2238,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteFirewallPolicyRe 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(request) @@ -2271,6 +2284,7 @@ def test_delete_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.delete(**mock_args) @@ -2408,6 +2422,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2453,6 +2468,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2582,6 +2598,7 @@ def test_get_rest_required_fields(request_type=compute.GetFirewallPolicyRequest) 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(request) @@ -2627,6 +2644,7 @@ def test_get_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(**mock_args) @@ -2760,6 +2778,7 @@ def test_get_association_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_association(request) @@ -2805,6 +2824,7 @@ def test_get_association_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_association(**mock_args) @@ -2938,6 +2958,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) @@ -2985,6 +3006,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) @@ -3118,6 +3140,7 @@ def test_get_rule_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_rule(request) @@ -3163,6 +3186,7 @@ def test_get_rule_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_rule(**mock_args) @@ -3307,6 +3331,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertFirewallPolicyRe 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.insert(request) @@ -3377,6 +3402,7 @@ def test_insert_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.insert(**mock_args) @@ -3529,6 +3555,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3599,6 +3626,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3887,6 +3915,7 @@ def test_move_rest_required_fields(request_type=compute.MoveFirewallPolicyReques 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.move(request) @@ -3951,6 +3980,7 @@ def test_move_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.move(**mock_args) @@ -4101,6 +4131,7 @@ def test_move_unary_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.move_unary(request) @@ -4165,6 +4196,7 @@ def test_move_unary_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.move_unary(**mock_args) @@ -4302,6 +4334,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchFirewallPolicyRequ 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.patch(request) @@ -4362,6 +4395,7 @@ def test_patch_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.patch(**mock_args) @@ -4507,6 +4541,7 @@ def test_patch_unary_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.patch_unary(request) @@ -4567,6 +4602,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -4717,6 +4753,7 @@ def test_patch_rule_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.patch_rule(request) @@ -4778,6 +4815,7 @@ def test_patch_rule_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.patch_rule(**mock_args) @@ -4924,6 +4962,7 @@ def test_patch_rule_unary_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.patch_rule_unary(request) @@ -4985,6 +5024,7 @@ def test_patch_rule_unary_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.patch_rule_unary(**mock_args) @@ -5134,6 +5174,7 @@ def test_remove_association_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.remove_association(request) @@ -5187,6 +5228,7 @@ def test_remove_association_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.remove_association(**mock_args) @@ -5333,6 +5375,7 @@ def test_remove_association_unary_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.remove_association_unary(request) @@ -5386,6 +5429,7 @@ def test_remove_association_unary_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.remove_association_unary(**mock_args) @@ -5528,6 +5572,7 @@ def test_remove_rule_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.remove_rule(request) @@ -5581,6 +5626,7 @@ def test_remove_rule_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.remove_rule(**mock_args) @@ -5723,6 +5769,7 @@ def test_remove_rule_unary_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.remove_rule_unary(request) @@ -5776,6 +5823,7 @@ def test_remove_rule_unary_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.remove_rule_unary(**mock_args) @@ -5908,6 +5956,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) @@ -5964,6 +6013,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) @@ -6103,6 +6153,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) @@ -6159,6 +6210,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) @@ -6294,6 +6346,7 @@ def test_add_association_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.add_association(request) @@ -6434,6 +6487,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.add_association(request) # Establish that the response is the type that we expect. @@ -6495,6 +6549,7 @@ def test_add_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6537,6 +6592,7 @@ def test_add_rule_rest_bad_request(request_type=compute.AddRuleFirewallPolicyReq 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.add_rule(request) @@ -6721,6 +6777,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.add_rule(request) # Establish that the response is the type that we expect. @@ -6782,6 +6839,7 @@ def test_add_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6826,6 +6884,7 @@ def test_clone_rules_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.clone_rules(request) @@ -6882,6 +6941,7 @@ def test_clone_rules_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.clone_rules(request) # Establish that the response is the type that we expect. @@ -6943,6 +7003,7 @@ def test_clone_rules_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6985,6 +7046,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteFirewallPolicyReques 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(request) @@ -7041,6 +7103,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -7102,6 +7165,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7144,6 +7208,7 @@ def test_get_rest_bad_request(request_type=compute.GetFirewallPolicyRequest): 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(request) @@ -7191,6 +7256,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -7243,6 +7309,7 @@ def test_get_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 = compute.FirewallPolicy.to_json(compute.FirewallPolicy()) req.return_value.content = return_value @@ -7287,6 +7354,7 @@ def test_get_association_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_association(request) @@ -7326,6 +7394,7 @@ def test_get_association_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_association(request) # Establish that the response is the type that we expect. @@ -7370,6 +7439,7 @@ def test_get_association_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 = compute.FirewallPolicyAssociation.to_json( compute.FirewallPolicyAssociation() ) @@ -7416,6 +7486,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) @@ -7453,6 +7524,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. @@ -7495,6 +7567,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -7537,6 +7610,7 @@ def test_get_rule_rest_bad_request(request_type=compute.GetRuleFirewallPolicyReq 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_rule(request) @@ -7584,6 +7658,7 @@ def test_get_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -7636,6 +7711,7 @@ def test_get_rule_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 = compute.FirewallPolicyRule.to_json(compute.FirewallPolicyRule()) req.return_value.content = return_value @@ -7678,6 +7754,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertFirewallPolicyReques 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.insert(request) @@ -7893,6 +7970,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.insert(request) # Establish that the response is the type that we expect. @@ -7954,6 +8032,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7996,6 +8075,7 @@ def test_list_rest_bad_request(request_type=compute.ListFirewallPoliciesRequest) 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(request) @@ -8033,6 +8113,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -8075,6 +8156,7 @@ def test_list_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 = compute.FirewallPolicyList.to_json(compute.FirewallPolicyList()) req.return_value.content = return_value @@ -8119,6 +8201,7 @@ def test_list_associations_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.list_associations(request) @@ -8154,6 +8237,7 @@ def test_list_associations_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_associations(request) # Establish that the response is the type that we expect. @@ -8194,6 +8278,7 @@ def test_list_associations_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 = compute.FirewallPoliciesListAssociationsResponse.to_json( compute.FirewallPoliciesListAssociationsResponse() ) @@ -8238,6 +8323,7 @@ def test_move_rest_bad_request(request_type=compute.MoveFirewallPolicyRequest): 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.move(request) @@ -8294,6 +8380,7 @@ def test_move_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.move(request) # Establish that the response is the type that we expect. @@ -8355,6 +8442,7 @@ def test_move_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8397,6 +8485,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchFirewallPolicyRequest) 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.patch(request) @@ -8612,6 +8701,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.patch(request) # Establish that the response is the type that we expect. @@ -8673,6 +8763,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8717,6 +8808,7 @@ def test_patch_rule_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.patch_rule(request) @@ -8901,6 +8993,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.patch_rule(request) # Establish that the response is the type that we expect. @@ -8962,6 +9055,7 @@ def test_patch_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9006,6 +9100,7 @@ def test_remove_association_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.remove_association(request) @@ -9062,6 +9157,7 @@ def test_remove_association_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.remove_association(request) # Establish that the response is the type that we expect. @@ -9123,6 +9219,7 @@ def test_remove_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9167,6 +9264,7 @@ def test_remove_rule_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.remove_rule(request) @@ -9223,6 +9321,7 @@ def test_remove_rule_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.remove_rule(request) # Establish that the response is the type that we expect. @@ -9284,6 +9383,7 @@ def test_remove_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9328,6 +9428,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) @@ -9488,6 +9589,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -9530,6 +9632,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -9574,6 +9677,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) @@ -9687,6 +9791,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -9727,6 +9832,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewalls.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewalls.py index e60e8f020c86..5eb85a6aabb7 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewalls.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_firewalls.py @@ -983,6 +983,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteFirewallRequest) 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(request) @@ -1037,6 +1038,7 @@ def test_delete_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.delete(**mock_args) @@ -1177,6 +1179,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteFirewallRe 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_unary(request) @@ -1231,6 +1234,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1365,6 +1369,7 @@ def test_get_rest_required_fields(request_type=compute.GetFirewallRequest): 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(request) @@ -1419,6 +1424,7 @@ def test_get_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(**mock_args) @@ -1556,6 +1562,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertFirewallRequest) 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.insert(request) @@ -1612,6 +1619,7 @@ def test_insert_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.insert(**mock_args) @@ -1751,6 +1759,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertFirewallRe 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.insert_unary(request) @@ -1807,6 +1816,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -1949,6 +1959,7 @@ def test_list_rest_required_fields(request_type=compute.ListFirewallsRequest): 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(request) @@ -2005,6 +2016,7 @@ def test_list_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(**mock_args) @@ -2206,6 +2218,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchFirewallRequest): 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.patch(request) @@ -2264,6 +2277,7 @@ def test_patch_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.patch(**mock_args) @@ -2408,6 +2422,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchFirewallRequ 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.patch_unary(request) @@ -2466,6 +2481,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2610,6 +2626,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateFirewallRequest) 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(request) @@ -2668,6 +2685,7 @@ def test_update_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(**mock_args) @@ -2812,6 +2830,7 @@ def test_update_unary_rest_required_fields(request_type=compute.UpdateFirewallRe 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_unary(request) @@ -2870,6 +2889,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3004,6 +3024,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteFirewallRequest): 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(request) @@ -3060,6 +3081,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3117,6 +3139,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3159,6 +3182,7 @@ def test_get_rest_bad_request(request_type=compute.GetFirewallRequest): 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(request) @@ -3209,6 +3233,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3260,6 +3285,7 @@ def test_get_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 = compute.Firewall.to_json(compute.Firewall()) req.return_value.content = return_value @@ -3302,6 +3328,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertFirewallRequest): 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.insert(request) @@ -3465,6 +3492,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.insert(request) # Establish that the response is the type that we expect. @@ -3522,6 +3550,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3564,6 +3593,7 @@ def test_list_rest_bad_request(request_type=compute.ListFirewallsRequest): 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(request) @@ -3602,6 +3632,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3641,6 +3672,7 @@ def test_list_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 = compute.FirewallList.to_json(compute.FirewallList()) req.return_value.content = return_value @@ -3683,6 +3715,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchFirewallRequest): 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.patch(request) @@ -3846,6 +3879,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.patch(request) # Establish that the response is the type that we expect. @@ -3903,6 +3937,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3945,6 +3980,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateFirewallRequest): 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(request) @@ -4108,6 +4144,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(request) # Establish that the response is the type that we expect. @@ -4165,6 +4202,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_forwarding_rules.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_forwarding_rules.py index ae8980ee4be6..618f63aa6044 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_forwarding_rules.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_forwarding_rules.py @@ -1030,6 +1030,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1088,6 +1089,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1306,6 +1308,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteForwardingRuleRe 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(request) @@ -1366,6 +1369,7 @@ def test_delete_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.delete(**mock_args) @@ -1513,6 +1517,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1573,6 +1578,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1712,6 +1718,7 @@ def test_get_rest_required_fields(request_type=compute.GetForwardingRuleRequest) 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(request) @@ -1772,6 +1779,7 @@ def test_get_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(**mock_args) @@ -1914,6 +1922,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertForwardingRuleRe 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.insert(request) @@ -1972,6 +1981,7 @@ def test_insert_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.insert(**mock_args) @@ -2118,6 +2128,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2176,6 +2187,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2323,6 +2335,7 @@ def test_list_rest_required_fields(request_type=compute.ListForwardingRulesReque 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(request) @@ -2385,6 +2398,7 @@ def test_list_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(**mock_args) @@ -2591,6 +2605,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchForwardingRuleRequ 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.patch(request) @@ -2655,6 +2670,7 @@ def test_patch_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.patch(**mock_args) @@ -2806,6 +2822,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2870,6 +2887,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3021,6 +3039,7 @@ def test_set_labels_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_labels(request) @@ -3085,6 +3104,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3236,6 +3256,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3300,6 +3321,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3451,6 +3473,7 @@ def test_set_target_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_target(request) @@ -3513,6 +3536,7 @@ def test_set_target_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_target(**mock_args) @@ -3662,6 +3686,7 @@ def test_set_target_unary_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_target_unary(request) @@ -3724,6 +3749,7 @@ def test_set_target_unary_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_target_unary(**mock_args) @@ -3859,6 +3885,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3898,6 +3925,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3942,6 +3970,7 @@ def test_aggregated_list_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 = compute.ForwardingRuleAggregatedList.to_json( compute.ForwardingRuleAggregatedList() ) @@ -3990,6 +4019,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteForwardingRuleReques 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(request) @@ -4050,6 +4080,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4111,6 +4142,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4157,6 +4189,7 @@ def test_get_rest_bad_request(request_type=compute.GetForwardingRuleRequest): 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(request) @@ -4227,6 +4260,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4298,6 +4332,7 @@ def test_get_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 = compute.ForwardingRule.to_json(compute.ForwardingRule()) req.return_value.content = return_value @@ -4340,6 +4375,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertForwardingRuleReques 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.insert(request) @@ -4515,6 +4551,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.insert(request) # Establish that the response is the type that we expect. @@ -4576,6 +4613,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4618,6 +4656,7 @@ def test_list_rest_bad_request(request_type=compute.ListForwardingRulesRequest): 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(request) @@ -4656,6 +4695,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4699,6 +4739,7 @@ def test_list_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 = compute.ForwardingRuleList.to_json(compute.ForwardingRuleList()) req.return_value.content = return_value @@ -4745,6 +4786,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchForwardingRuleRequest) 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.patch(request) @@ -4924,6 +4966,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.patch(request) # Establish that the response is the type that we expect. @@ -4985,6 +5028,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5029,6 +5073,7 @@ def test_set_labels_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_labels(request) @@ -5164,6 +5209,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.set_labels(request) # Establish that the response is the type that we expect. @@ -5225,6 +5271,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5273,6 +5320,7 @@ def test_set_target_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_target(request) @@ -5407,6 +5455,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.set_target(request) # Establish that the response is the type that we expect. @@ -5468,6 +5517,7 @@ def test_set_target_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_addresses.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_addresses.py index a5e189fb604f..d22d485d5bce 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_addresses.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_addresses.py @@ -1026,6 +1026,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteGlobalAddressReq 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(request) @@ -1080,6 +1081,7 @@ def test_delete_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.delete(**mock_args) @@ -1222,6 +1224,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1276,6 +1279,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1410,6 +1414,7 @@ def test_get_rest_required_fields(request_type=compute.GetGlobalAddressRequest): 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(request) @@ -1464,6 +1469,7 @@ def test_get_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(**mock_args) @@ -1601,6 +1607,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertGlobalAddressReq 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.insert(request) @@ -1655,6 +1662,7 @@ def test_insert_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.insert(**mock_args) @@ -1794,6 +1802,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1848,6 +1857,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -1988,6 +1998,7 @@ def test_list_rest_required_fields(request_type=compute.ListGlobalAddressesReque 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(request) @@ -2044,6 +2055,7 @@ def test_list_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(**mock_args) @@ -2245,6 +2257,7 @@ def test_move_rest_required_fields(request_type=compute.MoveGlobalAddressRequest 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.move(request) @@ -2303,6 +2316,7 @@ def test_move_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.move(**mock_args) @@ -2447,6 +2461,7 @@ def test_move_unary_rest_required_fields(request_type=compute.MoveGlobalAddressR 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.move_unary(request) @@ -2505,6 +2520,7 @@ def test_move_unary_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.move_unary(**mock_args) @@ -2649,6 +2665,7 @@ def test_set_labels_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_labels(request) @@ -2707,6 +2724,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2851,6 +2869,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2909,6 +2928,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3043,6 +3063,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteGlobalAddressRequest 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(request) @@ -3099,6 +3120,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3160,6 +3182,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3202,6 +3225,7 @@ def test_get_rest_bad_request(request_type=compute.GetGlobalAddressRequest): 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(request) @@ -3255,6 +3279,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3313,6 +3338,7 @@ def test_get_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 = compute.Address.to_json(compute.Address()) req.return_value.content = return_value @@ -3355,6 +3381,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertGlobalAddressRequest 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.insert(request) @@ -3500,6 +3527,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.insert(request) # Establish that the response is the type that we expect. @@ -3561,6 +3589,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3603,6 +3632,7 @@ def test_list_rest_bad_request(request_type=compute.ListGlobalAddressesRequest): 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(request) @@ -3641,6 +3671,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3684,6 +3715,7 @@ def test_list_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 = compute.AddressList.to_json(compute.AddressList()) req.return_value.content = return_value @@ -3726,6 +3758,7 @@ def test_move_rest_bad_request(request_type=compute.MoveGlobalAddressRequest): 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.move(request) @@ -3864,6 +3897,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.move(request) # Establish that the response is the type that we expect. @@ -3925,6 +3959,7 @@ def test_move_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3969,6 +4004,7 @@ def test_set_labels_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_labels(request) @@ -4104,6 +4140,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4165,6 +4202,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_forwarding_rules.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_forwarding_rules.py index 8025917c13e2..558cfa26346e 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_forwarding_rules.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_forwarding_rules.py @@ -1058,6 +1058,7 @@ def test_delete_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.delete(request) @@ -1112,6 +1113,7 @@ def test_delete_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.delete(**mock_args) @@ -1254,6 +1256,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1308,6 +1311,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1442,6 +1446,7 @@ def test_get_rest_required_fields(request_type=compute.GetGlobalForwardingRuleRe 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(request) @@ -1496,6 +1501,7 @@ def test_get_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(**mock_args) @@ -1635,6 +1641,7 @@ def test_insert_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.insert(request) @@ -1691,6 +1698,7 @@ def test_insert_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.insert(**mock_args) @@ -1832,6 +1840,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1888,6 +1897,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2032,6 +2042,7 @@ def test_list_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.list(request) @@ -2088,6 +2099,7 @@ def test_list_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(**mock_args) @@ -2291,6 +2303,7 @@ def test_patch_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.patch(request) @@ -2349,6 +2362,7 @@ def test_patch_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.patch(**mock_args) @@ -2495,6 +2509,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2553,6 +2568,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2697,6 +2713,7 @@ def test_set_labels_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_labels(request) @@ -2755,6 +2772,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2899,6 +2917,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2957,6 +2976,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3103,6 +3123,7 @@ def test_set_target_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_target(request) @@ -3159,6 +3180,7 @@ def test_set_target_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_target(**mock_args) @@ -3303,6 +3325,7 @@ def test_set_target_unary_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_target_unary(request) @@ -3359,6 +3382,7 @@ def test_set_target_unary_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_target_unary(**mock_args) @@ -3493,6 +3517,7 @@ def test_delete_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.delete(request) @@ -3549,6 +3574,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3610,6 +3636,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3652,6 +3679,7 @@ def test_get_rest_bad_request(request_type=compute.GetGlobalForwardingRuleReques 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(request) @@ -3718,6 +3746,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3789,6 +3818,7 @@ def test_get_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 = compute.ForwardingRule.to_json(compute.ForwardingRule()) req.return_value.content = return_value @@ -3833,6 +3863,7 @@ def test_insert_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.insert(request) @@ -4008,6 +4039,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.insert(request) # Establish that the response is the type that we expect. @@ -4069,6 +4101,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4111,6 +4144,7 @@ def test_list_rest_bad_request(request_type=compute.ListGlobalForwardingRulesReq 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(request) @@ -4149,6 +4183,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4192,6 +4227,7 @@ def test_list_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 = compute.ForwardingRuleList.to_json(compute.ForwardingRuleList()) req.return_value.content = return_value @@ -4234,6 +4270,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchGlobalForwardingRuleRe 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.patch(request) @@ -4409,6 +4446,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.patch(request) # Establish that the response is the type that we expect. @@ -4470,6 +4508,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4514,6 +4553,7 @@ def test_set_labels_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_labels(request) @@ -4649,6 +4689,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4710,6 +4751,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4754,6 +4796,7 @@ def test_set_target_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_target(request) @@ -4884,6 +4927,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.set_target(request) # Establish that the response is the type that we expect. @@ -4945,6 +4989,7 @@ def test_set_target_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_network_endpoint_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_network_endpoint_groups.py index 0eff422926de..260428d94e47 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_network_endpoint_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_network_endpoint_groups.py @@ -1080,6 +1080,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -1140,6 +1141,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(**mock_args) @@ -1293,6 +1295,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(request) @@ -1353,6 +1356,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(**mock_args) @@ -1500,6 +1504,7 @@ def test_delete_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.delete(request) @@ -1554,6 +1559,7 @@ def test_delete_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.delete(**mock_args) @@ -1696,6 +1702,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1750,6 +1757,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1898,6 +1906,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -1958,6 +1967,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(**mock_args) @@ -2111,6 +2121,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(request) @@ -2171,6 +2182,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(**mock_args) @@ -2312,6 +2324,7 @@ def test_get_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(request) @@ -2366,6 +2379,7 @@ def test_get_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(**mock_args) @@ -2505,6 +2519,7 @@ def test_insert_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.insert(request) @@ -2561,6 +2576,7 @@ def test_insert_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.insert(**mock_args) @@ -2702,6 +2718,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2758,6 +2775,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2902,6 +2920,7 @@ def test_list_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.list(request) @@ -2958,6 +2977,7 @@ def test_list_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(**mock_args) @@ -3171,6 +3191,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -3235,6 +3256,7 @@ def test_list_network_endpoints_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_network_endpoints(**mock_args) @@ -3434,6 +3456,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -3587,6 +3610,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.attach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -3650,6 +3674,7 @@ def test_attach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3694,6 +3719,7 @@ def test_delete_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.delete(request) @@ -3750,6 +3776,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3811,6 +3838,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3855,6 +3883,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -4008,6 +4037,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.detach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4071,6 +4101,7 @@ def test_detach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4115,6 +4146,7 @@ def test_get_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(request) @@ -4163,6 +4195,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4216,6 +4249,7 @@ def test_get_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 = compute.NetworkEndpointGroup.to_json( compute.NetworkEndpointGroup() ) @@ -4262,6 +4296,7 @@ def test_insert_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.insert(request) @@ -4427,6 +4462,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.insert(request) # Establish that the response is the type that we expect. @@ -4488,6 +4524,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4532,6 +4569,7 @@ def test_list_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.list(request) @@ -4570,6 +4608,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4613,6 +4652,7 @@ def test_list_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 = compute.NetworkEndpointGroupList.to_json( compute.NetworkEndpointGroupList() ) @@ -4659,6 +4699,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -4698,6 +4739,7 @@ def test_list_network_endpoints_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_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4742,6 +4784,7 @@ def test_list_network_endpoints_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 = compute.NetworkEndpointGroupsListNetworkEndpoints.to_json( compute.NetworkEndpointGroupsListNetworkEndpoints() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_operations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_operations.py index 6ac627a5ca57..eb967c15a5ef 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_operations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_operations.py @@ -1029,6 +1029,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1087,6 +1088,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1290,6 +1292,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteGlobalOperationR 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(request) @@ -1344,6 +1347,7 @@ def test_delete_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.delete(**mock_args) @@ -1478,6 +1482,7 @@ def test_get_rest_required_fields(request_type=compute.GetGlobalOperationRequest 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(request) @@ -1532,6 +1537,7 @@ def test_get_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(**mock_args) @@ -1672,6 +1678,7 @@ def test_list_rest_required_fields(request_type=compute.ListGlobalOperationsRequ 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(request) @@ -1728,6 +1735,7 @@ def test_list_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(**mock_args) @@ -1922,6 +1930,7 @@ def test_wait_rest_required_fields(request_type=compute.WaitGlobalOperationReque 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.wait(request) @@ -1976,6 +1985,7 @@ def test_wait_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.wait(**mock_args) @@ -2109,6 +2119,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -2148,6 +2159,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -2192,6 +2204,7 @@ def test_aggregated_list_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 = compute.OperationAggregatedList.to_json( compute.OperationAggregatedList() ) @@ -2236,6 +2249,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteGlobalOperationReque 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(request) @@ -2269,6 +2283,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2308,6 +2323,7 @@ def test_delete_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 = compute.DeleteGlobalOperationResponse.to_json( compute.DeleteGlobalOperationResponse() ) @@ -2352,6 +2368,7 @@ def test_get_rest_bad_request(request_type=compute.GetGlobalOperationRequest): 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(request) @@ -2408,6 +2425,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2469,6 +2487,7 @@ def test_get_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2511,6 +2530,7 @@ def test_list_rest_bad_request(request_type=compute.ListGlobalOperationsRequest) 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(request) @@ -2549,6 +2569,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2592,6 +2613,7 @@ def test_list_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 = compute.OperationList.to_json(compute.OperationList()) req.return_value.content = return_value @@ -2634,6 +2656,7 @@ def test_wait_rest_bad_request(request_type=compute.WaitGlobalOperationRequest): 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.wait(request) @@ -2690,6 +2713,7 @@ def test_wait_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.wait(request) # Establish that the response is the type that we expect. @@ -2751,6 +2775,7 @@ def test_wait_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_organization_operations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_organization_operations.py index 9b9ac6b6c5cc..8b95225d51aa 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_organization_operations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_organization_operations.py @@ -1065,6 +1065,7 @@ def test_delete_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.delete(request) @@ -1112,6 +1113,7 @@ def test_delete_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.delete(**mock_args) @@ -1245,6 +1247,7 @@ def test_get_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(request) @@ -1290,6 +1293,7 @@ def test_get_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(**mock_args) @@ -1519,6 +1523,7 @@ def test_delete_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.delete(request) @@ -1554,6 +1559,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -1593,6 +1599,7 @@ def test_delete_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 = compute.DeleteGlobalOrganizationOperationResponse.to_json( compute.DeleteGlobalOrganizationOperationResponse() ) @@ -1639,6 +1646,7 @@ def test_get_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(request) @@ -1695,6 +1703,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1756,6 +1765,7 @@ def test_get_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -1800,6 +1810,7 @@ def test_list_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.list(request) @@ -1838,6 +1849,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1881,6 +1893,7 @@ def test_list_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 = compute.OperationList.to_json(compute.OperationList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_public_delegated_prefixes.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_public_delegated_prefixes.py index 409352834f3f..e6f045d7de82 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_public_delegated_prefixes.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_global_public_delegated_prefixes.py @@ -1080,6 +1080,7 @@ def test_delete_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.delete(request) @@ -1134,6 +1135,7 @@ def test_delete_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.delete(**mock_args) @@ -1276,6 +1278,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1330,6 +1333,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1466,6 +1470,7 @@ def test_get_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(request) @@ -1520,6 +1525,7 @@ def test_get_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(**mock_args) @@ -1659,6 +1665,7 @@ def test_insert_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.insert(request) @@ -1715,6 +1722,7 @@ def test_insert_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.insert(**mock_args) @@ -1856,6 +1864,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1912,6 +1921,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2056,6 +2066,7 @@ def test_list_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.list(request) @@ -2112,6 +2123,7 @@ def test_list_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(**mock_args) @@ -2315,6 +2327,7 @@ def test_patch_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.patch(request) @@ -2373,6 +2386,7 @@ def test_patch_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.patch(**mock_args) @@ -2519,6 +2533,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2577,6 +2592,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2713,6 +2729,7 @@ def test_delete_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.delete(request) @@ -2769,6 +2786,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2830,6 +2848,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2874,6 +2893,7 @@ def test_get_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(request) @@ -2923,6 +2943,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2977,6 +2998,7 @@ def test_get_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 = compute.PublicDelegatedPrefix.to_json( compute.PublicDelegatedPrefix() ) @@ -3023,6 +3045,7 @@ def test_insert_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.insert(request) @@ -3184,6 +3207,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.insert(request) # Establish that the response is the type that we expect. @@ -3245,6 +3269,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3289,6 +3314,7 @@ def test_list_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.list(request) @@ -3327,6 +3353,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3370,6 +3397,7 @@ def test_list_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 = compute.PublicDelegatedPrefixList.to_json( compute.PublicDelegatedPrefixList() ) @@ -3416,6 +3444,7 @@ def test_patch_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.patch(request) @@ -3577,6 +3606,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.patch(request) # Establish that the response is the type that we expect. @@ -3638,6 +3668,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_health_checks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_health_checks.py index 8a3017eab1b1..bb08eab4a608 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_health_checks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_health_checks.py @@ -999,6 +999,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1057,6 +1058,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1271,6 +1273,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteHealthCheckReque 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(request) @@ -1325,6 +1328,7 @@ def test_delete_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.delete(**mock_args) @@ -1467,6 +1471,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1521,6 +1526,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1655,6 +1661,7 @@ def test_get_rest_required_fields(request_type=compute.GetHealthCheckRequest): 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(request) @@ -1709,6 +1716,7 @@ def test_get_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(**mock_args) @@ -1846,6 +1854,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertHealthCheckReque 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.insert(request) @@ -1900,6 +1909,7 @@ def test_insert_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.insert(**mock_args) @@ -2039,6 +2049,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2093,6 +2104,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2233,6 +2245,7 @@ def test_list_rest_required_fields(request_type=compute.ListHealthChecksRequest) 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(request) @@ -2289,6 +2302,7 @@ def test_list_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(**mock_args) @@ -2490,6 +2504,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchHealthCheckRequest 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.patch(request) @@ -2546,6 +2561,7 @@ def test_patch_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.patch(**mock_args) @@ -2688,6 +2704,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchHealthCheckR 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.patch_unary(request) @@ -2744,6 +2761,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2886,6 +2904,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateHealthCheckReque 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(request) @@ -2942,6 +2961,7 @@ def test_update_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(**mock_args) @@ -3086,6 +3106,7 @@ def test_update_unary_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.update_unary(request) @@ -3142,6 +3163,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3276,6 +3298,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3315,6 +3338,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3359,6 +3383,7 @@ def test_aggregated_list_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 = compute.HealthChecksAggregatedList.to_json( compute.HealthChecksAggregatedList() ) @@ -3403,6 +3428,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteHealthCheckRequest): 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(request) @@ -3459,6 +3485,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3520,6 +3547,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3562,6 +3590,7 @@ def test_get_rest_bad_request(request_type=compute.GetHealthCheckRequest): 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(request) @@ -3609,6 +3638,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3659,6 +3689,7 @@ def test_get_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 = compute.HealthCheck.to_json(compute.HealthCheck()) req.return_value.content = return_value @@ -3701,6 +3732,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertHealthCheckRequest): 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.insert(request) @@ -3891,6 +3923,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.insert(request) # Establish that the response is the type that we expect. @@ -3952,6 +3985,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3994,6 +4028,7 @@ def test_list_rest_bad_request(request_type=compute.ListHealthChecksRequest): 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(request) @@ -4032,6 +4067,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4075,6 +4111,7 @@ def test_list_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 = compute.HealthCheckList.to_json(compute.HealthCheckList()) req.return_value.content = return_value @@ -4117,6 +4154,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchHealthCheckRequest): 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.patch(request) @@ -4307,6 +4345,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.patch(request) # Establish that the response is the type that we expect. @@ -4368,6 +4407,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4410,6 +4450,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateHealthCheckRequest): 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(request) @@ -4600,6 +4641,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(request) # Establish that the response is the type that we expect. @@ -4661,6 +4703,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_image_family_views.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_image_family_views.py index 7bae0a5195af..035cf135c323 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_image_family_views.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_image_family_views.py @@ -1022,6 +1022,7 @@ def test_get_rest_required_fields(request_type=compute.GetImageFamilyViewRequest 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(request) @@ -1078,6 +1079,7 @@ def test_get_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(**mock_args) @@ -1210,6 +1212,7 @@ def test_get_rest_bad_request(request_type=compute.GetImageFamilyViewRequest): 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(request) @@ -1243,6 +1246,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1282,6 +1286,7 @@ def test_get_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 = compute.ImageFamilyView.to_json(compute.ImageFamilyView()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_images.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_images.py index e4ce780bf79d..22530a0379cb 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_images.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_images.py @@ -966,6 +966,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteImageRequest): 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(request) @@ -1020,6 +1021,7 @@ def test_delete_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.delete(**mock_args) @@ -1160,6 +1162,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteImageReque 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_unary(request) @@ -1214,6 +1217,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1355,6 +1359,7 @@ def test_deprecate_rest_required_fields(request_type=compute.DeprecateImageReque 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.deprecate(request) @@ -1413,6 +1418,7 @@ def test_deprecate_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.deprecate(**mock_args) @@ -1559,6 +1565,7 @@ def test_deprecate_unary_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.deprecate_unary(request) @@ -1617,6 +1624,7 @@ def test_deprecate_unary_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.deprecate_unary(**mock_args) @@ -1754,6 +1762,7 @@ def test_get_rest_required_fields(request_type=compute.GetImageRequest): 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(request) @@ -1808,6 +1817,7 @@ def test_get_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(**mock_args) @@ -1944,6 +1954,7 @@ def test_get_from_family_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_from_family(request) @@ -1998,6 +2009,7 @@ def test_get_from_family_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_from_family(**mock_args) @@ -2136,6 +2148,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) @@ -2190,6 +2203,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) @@ -2332,6 +2346,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertImageRequest): 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.insert(request) @@ -2391,6 +2406,7 @@ def test_insert_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.insert(**mock_args) @@ -2532,6 +2548,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertImageReque 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.insert_unary(request) @@ -2591,6 +2608,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2730,6 +2748,7 @@ def test_list_rest_required_fields(request_type=compute.ListImagesRequest): 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(request) @@ -2786,6 +2805,7 @@ def test_list_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(**mock_args) @@ -2986,6 +3006,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchImageRequest): 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.patch(request) @@ -3042,6 +3063,7 @@ def test_patch_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.patch(**mock_args) @@ -3184,6 +3206,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchImageRequest 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.patch_unary(request) @@ -3240,6 +3263,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3378,6 +3402,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) @@ -3436,6 +3461,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) @@ -3578,6 +3604,7 @@ def test_set_labels_rest_required_fields(request_type=compute.SetLabelsImageRequ 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_labels(request) @@ -3636,6 +3663,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3780,6 +3808,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3838,6 +3867,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3982,6 +4012,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) @@ -4040,6 +4071,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) @@ -4174,6 +4206,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteImageRequest): 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(request) @@ -4230,6 +4263,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4287,6 +4321,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4329,6 +4364,7 @@ def test_deprecate_rest_bad_request(request_type=compute.DeprecateImageRequest): 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.deprecate(request) @@ -4465,6 +4501,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.deprecate(request) # Establish that the response is the type that we expect. @@ -4522,6 +4559,7 @@ def test_deprecate_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4564,6 +4602,7 @@ def test_get_rest_bad_request(request_type=compute.GetImageRequest): 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(request) @@ -4623,6 +4662,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4683,6 +4723,7 @@ def test_get_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 = compute.Image.to_json(compute.Image()) req.return_value.content = return_value @@ -4727,6 +4768,7 @@ def test_get_from_family_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_from_family(request) @@ -4786,6 +4828,7 @@ def test_get_from_family_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_from_family(request) # Establish that the response is the type that we expect. @@ -4848,6 +4891,7 @@ def test_get_from_family_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 = compute.Image.to_json(compute.Image()) req.return_value.content = return_value @@ -4890,6 +4934,7 @@ def test_get_iam_policy_rest_bad_request(request_type=compute.GetIamPolicyImageR 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) @@ -4927,6 +4972,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. @@ -4967,6 +5013,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5009,6 +5056,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertImageRequest): 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.insert(request) @@ -5189,6 +5237,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.insert(request) # Establish that the response is the type that we expect. @@ -5246,6 +5295,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5288,6 +5338,7 @@ def test_list_rest_bad_request(request_type=compute.ListImagesRequest): 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(request) @@ -5326,6 +5377,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5365,6 +5417,7 @@ def test_list_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 = compute.ImageList.to_json(compute.ImageList()) req.return_value.content = return_value @@ -5407,6 +5460,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchImageRequest): 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.patch(request) @@ -5587,6 +5641,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.patch(request) # Establish that the response is the type that we expect. @@ -5644,6 +5699,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5686,6 +5742,7 @@ def test_set_iam_policy_rest_bad_request(request_type=compute.SetIamPolicyImageR 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) @@ -5839,6 +5896,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5879,6 +5937,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5921,6 +5980,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsImageRequest) 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_labels(request) @@ -6056,6 +6116,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.set_labels(request) # Establish that the response is the type that we expect. @@ -6113,6 +6174,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6157,6 +6219,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) @@ -6270,6 +6333,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -6308,6 +6372,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_manager_resize_requests.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_manager_resize_requests.py index 98ed345ea93d..708ce99d3b33 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_manager_resize_requests.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_manager_resize_requests.py @@ -1096,6 +1096,7 @@ def test_cancel_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.cancel(request) @@ -1159,6 +1160,7 @@ def test_cancel_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(**mock_args) @@ -1311,6 +1313,7 @@ def test_cancel_unary_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.cancel_unary(request) @@ -1374,6 +1377,7 @@ def test_cancel_unary_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_unary(**mock_args) @@ -1526,6 +1530,7 @@ def test_delete_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.delete(request) @@ -1589,6 +1594,7 @@ def test_delete_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.delete(**mock_args) @@ -1741,6 +1747,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1804,6 +1811,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1950,6 +1958,7 @@ def test_get_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(request) @@ -2013,6 +2022,7 @@ def test_get_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(**mock_args) @@ -2162,6 +2172,7 @@ def test_insert_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.insert(request) @@ -2226,6 +2237,7 @@ def test_insert_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.insert(**mock_args) @@ -2377,6 +2389,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2441,6 +2454,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2597,6 +2611,7 @@ def test_list_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.list(request) @@ -2667,6 +2682,7 @@ def test_list_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(**mock_args) @@ -2876,6 +2892,7 @@ def test_cancel_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.cancel(request) @@ -2937,6 +2954,7 @@ def test_cancel_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(request) # Establish that the response is the type that we expect. @@ -2998,6 +3016,7 @@ def test_cancel_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3047,6 +3066,7 @@ def test_delete_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.delete(request) @@ -3108,6 +3128,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3169,6 +3190,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3218,6 +3240,7 @@ def test_get_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(request) @@ -3267,6 +3290,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3316,6 +3340,7 @@ def test_get_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 = compute.InstanceGroupManagerResizeRequest.to_json( compute.InstanceGroupManagerResizeRequest() ) @@ -3366,6 +3391,7 @@ def test_insert_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.insert(request) @@ -3562,6 +3588,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.insert(request) # Establish that the response is the type that we expect. @@ -3623,6 +3650,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3671,6 +3699,7 @@ def test_list_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.list(request) @@ -3715,6 +3744,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3758,6 +3788,7 @@ def test_list_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 = compute.InstanceGroupManagerResizeRequestsListResponse.to_json( compute.InstanceGroupManagerResizeRequestsListResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_managers.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_managers.py index 72303de5c880..1062275be377 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_managers.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_group_managers.py @@ -1065,6 +1065,7 @@ def test_abandon_instances_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.abandon_instances(request) @@ -1129,6 +1130,7 @@ def test_abandon_instances_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.abandon_instances(**mock_args) @@ -1282,6 +1284,7 @@ def test_abandon_instances_unary_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.abandon_instances_unary(request) @@ -1346,6 +1349,7 @@ def test_abandon_instances_unary_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.abandon_instances_unary(**mock_args) @@ -1494,6 +1498,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1552,6 +1557,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1776,6 +1782,7 @@ def test_apply_updates_to_instances_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.apply_updates_to_instances(request) @@ -1840,6 +1847,7 @@ def test_apply_updates_to_instances_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.apply_updates_to_instances(**mock_args) @@ -1994,6 +2002,7 @@ def test_apply_updates_to_instances_unary_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.apply_updates_to_instances_unary(request) @@ -2058,6 +2067,7 @@ def test_apply_updates_to_instances_unary_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.apply_updates_to_instances_unary(**mock_args) @@ -2211,6 +2221,7 @@ def test_create_instances_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.create_instances(request) @@ -2275,6 +2286,7 @@ def test_create_instances_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_instances(**mock_args) @@ -2428,6 +2440,7 @@ def test_create_instances_unary_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.create_instances_unary(request) @@ -2492,6 +2505,7 @@ def test_create_instances_unary_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_instances_unary(**mock_args) @@ -2642,6 +2656,7 @@ def test_delete_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.delete(request) @@ -2702,6 +2717,7 @@ def test_delete_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.delete(**mock_args) @@ -2849,6 +2865,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2909,6 +2926,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -3059,6 +3077,7 @@ def test_delete_instances_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.delete_instances(request) @@ -3123,6 +3142,7 @@ def test_delete_instances_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.delete_instances(**mock_args) @@ -3276,6 +3296,7 @@ def test_delete_instances_unary_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.delete_instances_unary(request) @@ -3340,6 +3361,7 @@ def test_delete_instances_unary_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.delete_instances_unary(**mock_args) @@ -3494,6 +3516,7 @@ def test_delete_per_instance_configs_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.delete_per_instance_configs(request) @@ -3558,6 +3581,7 @@ def test_delete_per_instance_configs_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.delete_per_instance_configs(**mock_args) @@ -3712,6 +3736,7 @@ def test_delete_per_instance_configs_unary_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.delete_per_instance_configs_unary(request) @@ -3776,6 +3801,7 @@ def test_delete_per_instance_configs_unary_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.delete_per_instance_configs_unary(**mock_args) @@ -3920,6 +3946,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstanceGroupManagerRe 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(request) @@ -3980,6 +4007,7 @@ def test_get_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(**mock_args) @@ -4124,6 +4152,7 @@ def test_insert_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.insert(request) @@ -4186,6 +4215,7 @@ def test_insert_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.insert(**mock_args) @@ -4336,6 +4366,7 @@ def test_insert_unary_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.insert_unary(request) @@ -4398,6 +4429,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -4551,6 +4583,7 @@ def test_list_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.list(request) @@ -4613,6 +4646,7 @@ def test_list_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(**mock_args) @@ -4826,6 +4860,7 @@ def test_list_errors_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.list_errors(request) @@ -4894,6 +4929,7 @@ def test_list_errors_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_errors(**mock_args) @@ -5119,6 +5155,7 @@ def test_list_managed_instances_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.list_managed_instances(request) @@ -5189,6 +5226,7 @@ def test_list_managed_instances_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_managed_instances(**mock_args) @@ -5415,6 +5453,7 @@ def test_list_per_instance_configs_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.list_per_instance_configs(request) @@ -5485,6 +5524,7 @@ def test_list_per_instance_configs_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_per_instance_configs(**mock_args) @@ -5701,6 +5741,7 @@ def test_patch_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.patch(request) @@ -5769,6 +5810,7 @@ def test_patch_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.patch(**mock_args) @@ -5924,6 +5966,7 @@ def test_patch_unary_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.patch_unary(request) @@ -5992,6 +6035,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -6152,6 +6196,7 @@ def test_patch_per_instance_configs_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.patch_per_instance_configs(request) @@ -6218,6 +6263,7 @@ def test_patch_per_instance_configs_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.patch_per_instance_configs(**mock_args) @@ -6376,6 +6422,7 @@ def test_patch_per_instance_configs_unary_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.patch_per_instance_configs_unary(request) @@ -6442,6 +6489,7 @@ def test_patch_per_instance_configs_unary_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.patch_per_instance_configs_unary(**mock_args) @@ -6599,6 +6647,7 @@ def test_recreate_instances_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.recreate_instances(request) @@ -6663,6 +6712,7 @@ def test_recreate_instances_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.recreate_instances(**mock_args) @@ -6818,6 +6868,7 @@ def test_recreate_instances_unary_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.recreate_instances_unary(request) @@ -6882,6 +6933,7 @@ def test_recreate_instances_unary_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.recreate_instances_unary(**mock_args) @@ -7044,6 +7096,7 @@ def test_resize_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.resize(request) @@ -7116,6 +7169,7 @@ def test_resize_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.resize(**mock_args) @@ -7276,6 +7330,7 @@ def test_resize_unary_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.resize_unary(request) @@ -7348,6 +7403,7 @@ def test_resize_unary_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.resize_unary(**mock_args) @@ -7380,7 +7436,7 @@ def test_resize_unary_rest_flattened_error(transport: str = "rest"): ) -def test_set_instance_template_rest_use_cached_wrapped_rpc(): +def test_resume_instances_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7394,10 +7450,7 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.set_instance_template - in client._transport._wrapped_methods - ) + assert client._transport.resume_instances in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7405,11 +7458,11 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_instance_template + client._transport.resume_instances ] = mock_rpc request = {} - client.set_instance_template(request) + client.resume_instances(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7418,15 +7471,15 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_instance_template(request) + client.resume_instances(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_instance_template_rest_required_fields( - request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, +def test_resume_instances_rest_required_fields( + request_type=compute.ResumeInstancesInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -7444,7 +7497,7 @@ def test_set_instance_template_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7455,7 +7508,7 @@ def test_set_instance_template_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7502,26 +7555,27 @@ def test_set_instance_template_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_instance_template(request) + response = client.resume_instances(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_instance_template_rest_unset_required_fields(): +def test_resume_instances_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_instance_template._get_unset_required_fields({}) + unset_fields = transport.resume_instances._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersSetInstanceTemplateRequestResource", + "instanceGroupManagersResumeInstancesRequestResource", "project", "zone", ) @@ -7529,7 +7583,7 @@ def test_set_instance_template_rest_unset_required_fields(): ) -def test_set_instance_template_rest_flattened(): +def test_resume_instances_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7552,8 +7606,8 @@ def test_set_instance_template_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( - instance_template="instance_template_value" + instance_group_managers_resume_instances_request_resource=compute.InstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) mock_args.update(sample_request) @@ -7566,21 +7620,22 @@ def test_set_instance_template_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_instance_template(**mock_args) + client.resume_instances(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/resumeInstances" % client.transport._host, args[1], ) -def test_set_instance_template_rest_flattened_error(transport: str = "rest"): +def test_resume_instances_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7589,18 +7644,18 @@ def test_set_instance_template_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_instance_template( - compute.SetInstanceTemplateInstanceGroupManagerRequest(), + client.resume_instances( + compute.ResumeInstancesInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( - instance_template="instance_template_value" + instance_group_managers_resume_instances_request_resource=compute.InstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) -def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): +def test_resume_instances_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7614,10 +7669,7 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.set_instance_template - in client._transport._wrapped_methods - ) + assert client._transport.resume_instances in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7625,11 +7677,11 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_instance_template + client._transport.resume_instances ] = mock_rpc request = {} - client.set_instance_template_unary(request) + client.resume_instances_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7638,15 +7690,15 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_instance_template_unary(request) + client.resume_instances_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_instance_template_unary_rest_required_fields( - request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, +def test_resume_instances_unary_rest_required_fields( + request_type=compute.ResumeInstancesInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -7664,7 +7716,7 @@ def test_set_instance_template_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7675,7 +7727,7 @@ def test_set_instance_template_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7722,26 +7774,27 @@ def test_set_instance_template_unary_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_instance_template_unary(request) + response = client.resume_instances_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_instance_template_unary_rest_unset_required_fields(): +def test_resume_instances_unary_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_instance_template._get_unset_required_fields({}) + unset_fields = transport.resume_instances._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersSetInstanceTemplateRequestResource", + "instanceGroupManagersResumeInstancesRequestResource", "project", "zone", ) @@ -7749,7 +7802,7 @@ def test_set_instance_template_unary_rest_unset_required_fields(): ) -def test_set_instance_template_unary_rest_flattened(): +def test_resume_instances_unary_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7772,8 +7825,8 @@ def test_set_instance_template_unary_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( - instance_template="instance_template_value" + instance_group_managers_resume_instances_request_resource=compute.InstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) mock_args.update(sample_request) @@ -7786,21 +7839,22 @@ def test_set_instance_template_unary_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_instance_template_unary(**mock_args) + client.resume_instances_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/resumeInstances" % client.transport._host, args[1], ) -def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest"): +def test_resume_instances_unary_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7809,18 +7863,18 @@ def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_instance_template_unary( - compute.SetInstanceTemplateInstanceGroupManagerRequest(), + client.resume_instances_unary( + compute.ResumeInstancesInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( - instance_template="instance_template_value" + instance_group_managers_resume_instances_request_resource=compute.InstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) -def test_set_target_pools_rest_use_cached_wrapped_rpc(): +def test_set_instance_template_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7834,7 +7888,10 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_target_pools in client._transport._wrapped_methods + assert ( + client._transport.set_instance_template + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7842,11 +7899,11 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_target_pools + client._transport.set_instance_template ] = mock_rpc request = {} - client.set_target_pools(request) + client.set_instance_template(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7855,15 +7912,15 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_target_pools(request) + client.set_instance_template(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_target_pools_rest_required_fields( - request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, +def test_set_instance_template_rest_required_fields( + request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -7881,7 +7938,7 @@ def test_set_target_pools_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7892,7 +7949,7 @@ def test_set_target_pools_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7939,26 +7996,27 @@ def test_set_target_pools_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_target_pools(request) + response = client.set_instance_template(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_target_pools_rest_unset_required_fields(): +def test_set_instance_template_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_target_pools._get_unset_required_fields({}) + unset_fields = transport.set_instance_template._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersSetTargetPoolsRequestResource", + "instanceGroupManagersSetInstanceTemplateRequestResource", "project", "zone", ) @@ -7966,7 +8024,7 @@ def test_set_target_pools_rest_unset_required_fields(): ) -def test_set_target_pools_rest_flattened(): +def test_set_instance_template_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7989,8 +8047,8 @@ def test_set_target_pools_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( + instance_template="instance_template_value" ), ) mock_args.update(sample_request) @@ -8003,21 +8061,22 @@ def test_set_target_pools_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_target_pools(**mock_args) + client.set_instance_template(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" % client.transport._host, args[1], ) -def test_set_target_pools_rest_flattened_error(transport: str = "rest"): +def test_set_instance_template_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8026,18 +8085,18 @@ def test_set_target_pools_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_target_pools( - compute.SetTargetPoolsInstanceGroupManagerRequest(), + client.set_instance_template( + compute.SetInstanceTemplateInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( + instance_template="instance_template_value" ), ) -def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): +def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8051,7 +8110,10 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_target_pools in client._transport._wrapped_methods + assert ( + client._transport.set_instance_template + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -8059,11 +8121,11 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_target_pools + client._transport.set_instance_template ] = mock_rpc request = {} - client.set_target_pools_unary(request) + client.set_instance_template_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -8072,15 +8134,15 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_target_pools_unary(request) + client.set_instance_template_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_target_pools_unary_rest_required_fields( - request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, +def test_set_instance_template_unary_rest_required_fields( + request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -8098,7 +8160,7 @@ def test_set_target_pools_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -8109,7 +8171,7 @@ def test_set_target_pools_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -8156,26 +8218,27 @@ def test_set_target_pools_unary_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_target_pools_unary(request) + response = client.set_instance_template_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_target_pools_unary_rest_unset_required_fields(): +def test_set_instance_template_unary_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_target_pools._get_unset_required_fields({}) + unset_fields = transport.set_instance_template._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersSetTargetPoolsRequestResource", + "instanceGroupManagersSetInstanceTemplateRequestResource", "project", "zone", ) @@ -8183,7 +8246,7 @@ def test_set_target_pools_unary_rest_unset_required_fields(): ) -def test_set_target_pools_unary_rest_flattened(): +def test_set_instance_template_unary_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -8206,8 +8269,8 @@ def test_set_target_pools_unary_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( + instance_template="instance_template_value" ), ) mock_args.update(sample_request) @@ -8220,21 +8283,22 @@ def test_set_target_pools_unary_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_target_pools_unary(**mock_args) + client.set_instance_template_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" % client.transport._host, args[1], ) -def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): +def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8243,18 +8307,18 @@ def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_target_pools_unary( - compute.SetTargetPoolsInstanceGroupManagerRequest(), + client.set_instance_template_unary( + compute.SetInstanceTemplateInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + instance_group_managers_set_instance_template_request_resource=compute.InstanceGroupManagersSetInstanceTemplateRequest( + instance_template="instance_template_value" ), ) -def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): +def test_set_target_pools_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8268,10 +8332,7 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_per_instance_configs - in client._transport._wrapped_methods - ) + assert client._transport.set_target_pools in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -8279,11 +8340,11 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_per_instance_configs + client._transport.set_target_pools ] = mock_rpc request = {} - client.update_per_instance_configs(request) + client.set_target_pools(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -8292,15 +8353,15 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_per_instance_configs(request) + client.set_target_pools(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_per_instance_configs_rest_required_fields( - request_type=compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, +def test_set_target_pools_rest_required_fields( + request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -8318,7 +8379,7 @@ def test_update_per_instance_configs_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -8329,7 +8390,7 @@ def test_update_per_instance_configs_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -8376,26 +8437,27 @@ def test_update_per_instance_configs_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.update_per_instance_configs(request) + response = client.set_target_pools(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_per_instance_configs_rest_unset_required_fields(): +def test_set_target_pools_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + unset_fields = transport.set_target_pools._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersUpdatePerInstanceConfigsReqResource", + "instanceGroupManagersSetTargetPoolsRequestResource", "project", "zone", ) @@ -8403,7 +8465,7 @@ def test_update_per_instance_configs_rest_unset_required_fields(): ) -def test_update_per_instance_configs_rest_flattened(): +def test_set_target_pools_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -8426,10 +8488,8 @@ def test_update_per_instance_configs_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) mock_args.update(sample_request) @@ -8442,21 +8502,22 @@ def test_update_per_instance_configs_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_per_instance_configs(**mock_args) + client.set_target_pools(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setTargetPools" % client.transport._host, args[1], ) -def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest"): +def test_set_target_pools_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8465,20 +8526,18 @@ def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_per_instance_configs( - compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest(), + client.set_target_pools( + compute.SetTargetPoolsInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) -def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): +def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8492,10 +8551,7 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_per_instance_configs - in client._transport._wrapped_methods - ) + assert client._transport.set_target_pools in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -8503,11 +8559,11 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_per_instance_configs + client._transport.set_target_pools ] = mock_rpc request = {} - client.update_per_instance_configs_unary(request) + client.set_target_pools_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -8516,15 +8572,15 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_per_instance_configs_unary(request) + client.set_target_pools_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_per_instance_configs_unary_rest_required_fields( - request_type=compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, +def test_set_target_pools_unary_rest_required_fields( + request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, ): transport_class = transports.InstanceGroupManagersRestTransport @@ -8542,7 +8598,7 @@ def test_update_per_instance_configs_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -8553,7 +8609,7 @@ def test_update_per_instance_configs_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -8600,26 +8656,27 @@ def test_update_per_instance_configs_unary_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.update_per_instance_configs_unary(request) + response = client.set_target_pools_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_per_instance_configs_unary_rest_unset_required_fields(): +def test_set_target_pools_unary_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + unset_fields = transport.set_target_pools._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( ( "instanceGroupManager", - "instanceGroupManagersUpdatePerInstanceConfigsReqResource", + "instanceGroupManagersSetTargetPoolsRequestResource", "project", "zone", ) @@ -8627,7 +8684,7 @@ def test_update_per_instance_configs_unary_rest_unset_required_fields(): ) -def test_update_per_instance_configs_unary_rest_flattened(): +def test_set_target_pools_unary_rest_flattened(): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -8650,10 +8707,8 @@ def test_update_per_instance_configs_unary_rest_flattened(): project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) mock_args.update(sample_request) @@ -8666,23 +8721,22 @@ def test_update_per_instance_configs_unary_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_per_instance_configs_unary(**mock_args) + client.set_target_pools_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/setTargetPools" % client.transport._host, args[1], ) -def test_update_per_instance_configs_unary_rest_flattened_error( - transport: str = "rest", -): +def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8691,103 +8745,2781 @@ def test_update_per_instance_configs_unary_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_per_instance_configs_unary( - compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest(), + client.set_target_pools_unary( + compute.SetTargetPoolsInstanceGroupManagerRequest(), project="project_value", zone="zone_value", instance_group_manager="instance_group_manager_value", - instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + instance_group_managers_set_target_pools_request_resource=compute.InstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.InstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): +def test_start_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.InstanceGroupManagersRestTransport( + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.start_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.start_instances] = mock_rpc + + request = {} + client.start_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.start_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_start_instances_rest_required_fields( + request_type=compute.StartInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - with pytest.raises(ValueError): - client = InstanceGroupManagersClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) + request = request_type(**request_init) - # It is an error to provide an api_key and a transport instance. + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_start_instances_rest_unset_required_fields(): transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.start_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersStartInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_start_instances_rest_flattened(): + client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = InstanceGroupManagersClient( - client_options=options, - transport=transport, + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_start_instances_request_resource=compute.InstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), ) + mock_args.update(sample_request) - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = InstanceGroupManagersClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/startInstances" + % client.transport._host, + args[1], ) - # It is an error to provide scopes and a transport instance. - transport = transports.InstanceGroupManagersRestTransport( + +def test_start_instances_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. with pytest.raises(ValueError): + client.start_instances( + compute.StartInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_start_instances_request_resource=compute.InstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + + +def test_start_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = InstanceGroupManagersClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.InstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = InstanceGroupManagersClient(transport=transport) - assert client.transport is transport + # Ensure method has been cached + assert client._transport.start_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.start_instances] = mock_rpc + + request = {} + client.start_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.start_instances_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_start_instances_unary_rest_required_fields( + request_type=compute.StartInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_start_instances_unary_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.start_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersStartInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_start_instances_unary_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_start_instances_request_resource=compute.InstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/startInstances" + % client.transport._host, + args[1], + ) + + +def test_start_instances_unary_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.start_instances_unary( + compute.StartInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_start_instances_request_resource=compute.InstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + + +def test_stop_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.stop_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.stop_instances] = mock_rpc + + request = {} + client.stop_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.stop_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_stop_instances_rest_required_fields( + request_type=compute.StopInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_stop_instances_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.stop_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersStopInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_stop_instances_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_stop_instances_request_resource=compute.InstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/stopInstances" + % client.transport._host, + args[1], + ) + + +def test_stop_instances_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_instances( + compute.StopInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_stop_instances_request_resource=compute.InstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + + +def test_stop_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.stop_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.stop_instances] = mock_rpc + + request = {} + client.stop_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.stop_instances_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_stop_instances_unary_rest_required_fields( + request_type=compute.StopInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_stop_instances_unary_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.stop_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersStopInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_stop_instances_unary_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_stop_instances_request_resource=compute.InstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/stopInstances" + % client.transport._host, + args[1], + ) + + +def test_stop_instances_unary_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_instances_unary( + compute.StopInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_stop_instances_request_resource=compute.InstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + + +def test_suspend_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.suspend_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.suspend_instances + ] = mock_rpc + + request = {} + client.suspend_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.suspend_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_suspend_instances_rest_required_fields( + request_type=compute.SuspendInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_suspend_instances_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.suspend_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersSuspendInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_suspend_instances_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_suspend_instances_request_resource=compute.InstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/suspendInstances" + % client.transport._host, + args[1], + ) + + +def test_suspend_instances_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.suspend_instances( + compute.SuspendInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_suspend_instances_request_resource=compute.InstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + + +def test_suspend_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.suspend_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.suspend_instances + ] = mock_rpc + + request = {} + client.suspend_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.suspend_instances_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_suspend_instances_unary_rest_required_fields( + request_type=compute.SuspendInstancesInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_suspend_instances_unary_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.suspend_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersSuspendInstancesRequestResource", + "project", + "zone", + ) + ) + ) + + +def test_suspend_instances_unary_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_suspend_instances_request_resource=compute.InstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/suspendInstances" + % client.transport._host, + args[1], + ) + + +def test_suspend_instances_unary_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.suspend_instances_unary( + compute.SuspendInstancesInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_suspend_instances_request_resource=compute.InstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + + +def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_per_instance_configs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_per_instance_configs + ] = mock_rpc + + request = {} + client.update_per_instance_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_per_instance_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_per_instance_configs_rest_required_fields( + request_type=compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_per_instance_configs_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersUpdatePerInstanceConfigsReqResource", + "project", + "zone", + ) + ) + ) + + +def test_update_per_instance_configs_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest"): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_per_instance_configs( + compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + + +def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_per_instance_configs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_per_instance_configs + ] = mock_rpc + + request = {} + client.update_per_instance_configs_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_per_instance_configs_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_per_instance_configs_unary_rest_required_fields( + request_type=compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest, +): + transport_class = transports.InstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["zone"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["zone"] = "zone_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "zone" in jsonified_request + assert jsonified_request["zone"] == "zone_value" + + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_per_instance_configs_unary_rest_unset_required_fields(): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "instanceGroupManagersUpdatePerInstanceConfigsReqResource", + "project", + "zone", + ) + ) + ) + + +def test_update_per_instance_configs_unary_rest_flattened(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_update_per_instance_configs_unary_rest_flattened_error( + transport: str = "rest", +): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_per_instance_configs_unary( + compute.UpdatePerInstanceConfigsInstanceGroupManagerRequest(), + project="project_value", + zone="zone_value", + instance_group_manager="instance_group_manager_value", + instance_group_managers_update_per_instance_configs_req_resource=compute.InstanceGroupManagersUpdatePerInstanceConfigsReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = InstanceGroupManagersClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = InstanceGroupManagersClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = InstanceGroupManagersClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = InstanceGroupManagersClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = InstanceGroupManagersClient(transport=transport) + assert client.transport is transport + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.InstanceGroupManagersRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_rest(): + transport = InstanceGroupManagersClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_abandon_instances_rest_bad_request( + request_type=compute.AbandonInstancesInstanceGroupManagerRequest, +): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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.abandon_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.AbandonInstancesInstanceGroupManagerRequest, + dict, + ], +) +def test_abandon_instances_rest_call_success(request_type): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request_init["instance_group_managers_abandon_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.AbandonInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_abandon_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_abandon_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_abandon_instances_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_abandon_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_abandon_instances_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.abandon_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_abandon_instances_rest_interceptors(null_interceptor): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.InstanceGroupManagersRestInterceptor(), + ) + client = InstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "post_abandon_instances" + ) as post, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "pre_abandon_instances" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.AbandonInstancesInstanceGroupManagerRequest.pb( + compute.AbandonInstancesInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.AbandonInstancesInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.abandon_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_aggregated_list_rest_bad_request( + request_type=compute.AggregatedListInstanceGroupManagersRequest, +): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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.aggregated_list(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.AggregatedListInstanceGroupManagersRequest, + dict, + ], +) +def test_aggregated_list_rest_call_success(request_type): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.InstanceGroupManagerAggregatedList( + id="id_value", + kind="kind_value", + next_page_token="next_page_token_value", + self_link="self_link_value", + unreachables=["unreachables_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.InstanceGroupManagerAggregatedList.pb(return_value) + 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.aggregated_list(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.AggregatedListPager) + assert response.id == "id_value" + assert response.kind == "kind_value" + assert response.next_page_token == "next_page_token_value" + assert response.self_link == "self_link_value" + assert response.unreachables == ["unreachables_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_aggregated_list_rest_interceptors(null_interceptor): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.InstanceGroupManagersRestInterceptor(), + ) + client = InstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "post_aggregated_list" + ) as post, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "pre_aggregated_list" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.AggregatedListInstanceGroupManagersRequest.pb( + compute.AggregatedListInstanceGroupManagersRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.InstanceGroupManagerAggregatedList.to_json( + compute.InstanceGroupManagerAggregatedList() + ) + req.return_value.content = return_value + + request = compute.AggregatedListInstanceGroupManagersRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.InstanceGroupManagerAggregatedList() + + client.aggregated_list( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_apply_updates_to_instances_rest_bad_request( + request_type=compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, +): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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.apply_updates_to_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, + dict, + ], +) +def test_apply_updates_to_instances_rest_call_success(request_type): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request_init["instance_group_managers_apply_updates_request_resource"] = { + "all_instances": True, + "instances": ["instances_value1", "instances_value2"], + "minimal_action": "minimal_action_value", + "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_apply_updates_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_apply_updates_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_apply_updates_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_apply_updates_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_apply_updates_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.apply_updates_to_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_apply_updates_to_instances_rest_interceptors(null_interceptor): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.InstanceGroupManagersRestInterceptor(), + ) + client = InstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, + "post_apply_updates_to_instances", + ) as post, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, + "pre_apply_updates_to_instances", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest.pb( + compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.apply_updates_to_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_instances_rest_bad_request( + request_type=compute.CreateInstancesInstanceGroupManagerRequest, +): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.CreateInstancesInstanceGroupManagerRequest, + dict, + ], +) +def test_create_instances_rest_call_success(request_type): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request_init["instance_group_managers_create_instances_request_resource"] = { + "instances": [ + { + "fingerprint": "fingerprint_value", + "name": "name_value", + "preserved_state": { + "disks": {}, + "external_i_ps": {}, + "internal_i_ps": {}, + "metadata": {}, + }, + "status": "status_value", + } + ] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.CreateInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_create_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_create_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_create_instances_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_create_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_create_instances_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_instances_rest_interceptors(null_interceptor): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.InstanceGroupManagersRestInterceptor(), + ) + client = InstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "post_create_instances" + ) as post, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, "pre_create_instances" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.CreateInstancesInstanceGroupManagerRequest.pb( + compute.CreateInstancesInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value -@pytest.mark.parametrize( - "transport_class", - [ - transports.InstanceGroupManagersRestTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + request = compute.CreateInstancesInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + client.create_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_rest(): - transport = InstanceGroupManagersClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + pre.assert_called_once() + post.assert_called_once() -def test_abandon_instances_rest_bad_request( - request_type=compute.AbandonInstancesInstanceGroupManagerRequest, +def test_delete_rest_bad_request( + request_type=compute.DeleteInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8811,17 +11543,18 @@ def test_abandon_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.abandon_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete(request) @pytest.mark.parametrize( "request_type", [ - compute.AbandonInstancesInstanceGroupManagerRequest, + compute.DeleteInstanceGroupManagerRequest, dict, ], ) -def test_abandon_instances_rest_call_success(request_type): +def test_delete_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -8832,91 +11565,6 @@ def test_abandon_instances_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_abandon_instances_request_resource"] = { - "instances": ["instances_value1", "instances_value2"] - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = compute.AbandonInstancesInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_abandon_instances_request_resource" - ] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "instance_group_managers_abandon_instances_request_resource" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range( - 0, - len( - request_init[ - "instance_group_managers_abandon_instances_request_resource" - ][field] - ), - ): - del request_init[ - "instance_group_managers_abandon_instances_request_resource" - ][field][i][subfield] - else: - del request_init[ - "instance_group_managers_abandon_instances_request_resource" - ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -8956,7 +11604,8 @@ 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 - response = client.abandon_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -8985,7 +11634,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_abandon_instances_rest_interceptors(null_interceptor): +def test_delete_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -8999,14 +11648,14 @@ def test_abandon_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_abandon_instances" + transports.InstanceGroupManagersRestInterceptor, "post_delete" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_abandon_instances" + transports.InstanceGroupManagersRestInterceptor, "pre_delete" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.AbandonInstancesInstanceGroupManagerRequest.pb( - compute.AbandonInstancesInstanceGroupManagerRequest() + pb_message = compute.DeleteInstanceGroupManagerRequest.pb( + compute.DeleteInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9017,10 +11666,11 @@ def test_abandon_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.AbandonInstancesInstanceGroupManagerRequest() + request = compute.DeleteInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -9028,7 +11678,7 @@ def test_abandon_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.abandon_instances( + client.delete( request, metadata=[ ("key", "val"), @@ -9040,14 +11690,18 @@ def test_abandon_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_aggregated_list_rest_bad_request( - request_type=compute.AggregatedListInstanceGroupManagersRequest, +def test_delete_instances_rest_bad_request( + request_type=compute.DeleteInstancesInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1"} + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9061,34 +11715,142 @@ def test_aggregated_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.aggregated_list(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.AggregatedListInstanceGroupManagersRequest, + compute.DeleteInstancesInstanceGroupManagerRequest, dict, ], ) -def test_aggregated_list_rest_call_success(request_type): +def test_delete_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1"} + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request_init["instance_group_managers_delete_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"], + "skip_instances_on_validation_error": True, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.DeleteInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_delete_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_delete_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_delete_instances_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_delete_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_delete_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManagerAggregatedList( - id="id_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", kind="kind_value", - next_page_token="next_page_token_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", self_link="self_link_value", - unreachables=["unreachables_value"], + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -9096,23 +11858,41 @@ def test_aggregated_list_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManagerAggregatedList.pb(return_value) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.aggregated_list(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_instances(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.AggregatedListPager) - assert response.id == "id_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" assert response.kind == "kind_value" - assert response.next_page_token == "next_page_token_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" assert response.self_link == "self_link_value" - assert response.unreachables == ["unreachables_value"] + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_aggregated_list_rest_interceptors(null_interceptor): +def test_delete_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9126,14 +11906,14 @@ def test_aggregated_list_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_aggregated_list" + transports.InstanceGroupManagersRestInterceptor, "post_delete_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_aggregated_list" + transports.InstanceGroupManagersRestInterceptor, "pre_delete_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.AggregatedListInstanceGroupManagersRequest.pb( - compute.AggregatedListInstanceGroupManagersRequest() + pb_message = compute.DeleteInstancesInstanceGroupManagerRequest.pb( + compute.DeleteInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9144,20 +11924,19 @@ def test_aggregated_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.InstanceGroupManagerAggregatedList.to_json( - compute.InstanceGroupManagerAggregatedList() - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.AggregatedListInstanceGroupManagersRequest() + request = compute.DeleteInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManagerAggregatedList() + post.return_value = compute.Operation() - client.aggregated_list( + client.delete_instances( request, metadata=[ ("key", "val"), @@ -9169,8 +11948,8 @@ def test_aggregated_list_rest_interceptors(null_interceptor): post.assert_called_once() -def test_apply_updates_to_instances_rest_bad_request( - request_type=compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, +def test_delete_per_instance_configs_rest_bad_request( + request_type=compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -9194,17 +11973,18 @@ def test_apply_updates_to_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.apply_updates_to_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest, + compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, dict, ], ) -def test_apply_updates_to_instances_rest_call_success(request_type): +def test_delete_per_instance_configs_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -9215,20 +11995,19 @@ def test_apply_updates_to_instances_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_apply_updates_request_resource"] = { - "all_instances": True, - "instances": ["instances_value1", "instances_value2"], - "minimal_action": "minimal_action_value", - "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", + request_init["instance_group_managers_delete_per_instance_configs_req_resource"] = { + "names": ["names_value1", "names_value2"] } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_apply_updates_request_resource" - ] + test_field = ( + compute.DeletePerInstanceConfigsInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_delete_per_instance_configs_req_resource" + ] + ) def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -9257,7 +12036,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_apply_updates_request_resource" + "instance_group_managers_delete_per_instance_configs_req_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -9292,44 +12071,213 @@ def get_message_fields(field): 0, len( request_init[ - "instance_group_managers_apply_updates_request_resource" + "instance_group_managers_delete_per_instance_configs_req_resource" ][field] ), ): del request_init[ - "instance_group_managers_apply_updates_request_resource" + "instance_group_managers_delete_per_instance_configs_req_resource" ][field][i][subfield] else: del request_init[ - "instance_group_managers_apply_updates_request_resource" + "instance_group_managers_delete_per_instance_configs_req_resource" ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.delete_per_instance_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_per_instance_configs_rest_interceptors(null_interceptor): + transport = transports.InstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.InstanceGroupManagersRestInterceptor(), + ) + client = InstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, + "post_delete_per_instance_configs", + ) as post, mock.patch.object( + transports.InstanceGroupManagersRestInterceptor, + "pre_delete_per_instance_configs", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.DeletePerInstanceConfigsInstanceGroupManagerRequest.pb( + compute.DeletePerInstanceConfigsInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.DeletePerInstanceConfigsInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.delete_per_instance_configs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_rest_bad_request(request_type=compute.GetInstanceGroupManagerRequest): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.GetInstanceGroupManagerRequest, + dict, + ], +) +def test_get_rest_call_success(request_type): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.InstanceGroupManager( + base_instance_name="base_instance_name_value", creation_timestamp="creation_timestamp_value", description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, + fingerprint="fingerprint_value", id=205, - insert_time="insert_time_value", + instance_group="instance_group_value", + instance_template="instance_template_value", kind="kind_value", + list_managed_instances_results="list_managed_instances_results_value", name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, region="region_value", + satisfies_pzi=True, + satisfies_pzs=True, self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", + target_pools=["target_pools_value"], + target_size=1185, + target_stopped_size=2047, + target_suspended_size=2251, zone="zone_value", ) @@ -9338,40 +12286,41 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.InstanceGroupManager.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.apply_updates_to_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" + assert isinstance(response, compute.InstanceGroupManager) + assert response.base_instance_name == "base_instance_name_value" assert response.creation_timestamp == "creation_timestamp_value" assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 + assert response.fingerprint == "fingerprint_value" assert response.id == 205 - assert response.insert_time == "insert_time_value" + assert response.instance_group == "instance_group_value" + assert response.instance_template == "instance_template_value" assert response.kind == "kind_value" + assert ( + response.list_managed_instances_results + == "list_managed_instances_results_value" + ) assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 assert response.region == "region_value" + assert response.satisfies_pzi is True + assert response.satisfies_pzs is True assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" + assert response.target_pools == ["target_pools_value"] + assert response.target_size == 1185 + assert response.target_stopped_size == 2047 + assert response.target_suspended_size == 2251 assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_apply_updates_to_instances_rest_interceptors(null_interceptor): +def test_get_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9385,16 +12334,14 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "post_apply_updates_to_instances", + transports.InstanceGroupManagersRestInterceptor, "post_get" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "pre_apply_updates_to_instances", + transports.InstanceGroupManagersRestInterceptor, "pre_get" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest.pb( - compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + pb_message = compute.GetInstanceGroupManagerRequest.pb( + compute.GetInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9405,18 +12352,21 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.InstanceGroupManager.to_json( + compute.InstanceGroupManager() + ) req.return_value.content = return_value - request = compute.ApplyUpdatesToInstancesInstanceGroupManagerRequest() + request = compute.GetInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.InstanceGroupManager() - client.apply_updates_to_instances( + client.get( request, metadata=[ ("key", "val"), @@ -9428,18 +12378,14 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_instances_rest_bad_request( - request_type=compute.CreateInstancesInstanceGroupManagerRequest, +def test_insert_rest_bad_request( + request_type=compute.InsertInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "zone": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "zone": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9453,49 +12399,114 @@ def test_create_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.insert(request) @pytest.mark.parametrize( "request_type", [ - compute.CreateInstancesInstanceGroupManagerRequest, + compute.InsertInstanceGroupManagerRequest, dict, ], ) -def test_create_instances_rest_call_success(request_type): +def test_insert_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "zone": "sample2", - "instance_group_manager": "sample3", - } - request_init["instance_group_managers_create_instances_request_resource"] = { - "instances": [ + request_init = {"project": "sample1", "zone": "sample2"} + request_init["instance_group_manager_resource"] = { + "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, + "auto_healing_policies": [ + {"health_check": "health_check_value", "initial_delay_sec": 1778} + ], + "base_instance_name": "base_instance_name_value", + "creation_timestamp": "creation_timestamp_value", + "current_actions": { + "abandoning": 1041, + "creating": 845, + "creating_without_retries": 2589, + "deleting": 844, + "none": 432, + "recreating": 1060, + "refreshing": 1069, + "restarting": 1091, + "resuming": 874, + "starting": 876, + "stopping": 884, + "suspending": 1088, + "verifying": 979, + }, + "description": "description_value", + "distribution_policy": { + "target_shape": "target_shape_value", + "zones": [{"zone": "zone_value"}], + }, + "fingerprint": "fingerprint_value", + "id": 205, + "instance_flexibility_policy": {"instance_selections": {}}, + "instance_group": "instance_group_value", + "instance_lifecycle_policy": { + "default_action_on_failure": "default_action_on_failure_value", + "force_update_on_repair": "force_update_on_repair_value", + }, + "instance_template": "instance_template_value", + "kind": "kind_value", + "list_managed_instances_results": "list_managed_instances_results_value", + "name": "name_value", + "named_ports": [{"name": "name_value", "port": 453}], + "region": "region_value", + "satisfies_pzi": True, + "satisfies_pzs": True, + "self_link": "self_link_value", + "standby_policy": {"initial_delay_sec": 1778, "mode": "mode_value"}, + "stateful_policy": { + "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} + }, + "status": { + "all_instances_config": { + "current_revision": "current_revision_value", + "effective": True, + }, + "autoscaler": "autoscaler_value", + "is_stable": True, + "stateful": { + "has_stateful_config": True, + "per_instance_configs": {"all_effective": True}, + }, + "version_target": {"is_reached": True}, + }, + "target_pools": ["target_pools_value1", "target_pools_value2"], + "target_size": 1185, + "target_stopped_size": 2047, + "target_suspended_size": 2251, + "update_policy": { + "instance_redistribution_type": "instance_redistribution_type_value", + "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, + "max_unavailable": {}, + "minimal_action": "minimal_action_value", + "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", + "replacement_method": "replacement_method_value", + "type_": "type__value", + }, + "versions": [ { - "fingerprint": "fingerprint_value", + "instance_template": "instance_template_value", "name": "name_value", - "preserved_state": { - "disks": {}, - "external_i_ps": {}, - "internal_i_ps": {}, - "metadata": {}, - }, - "status": "status_value", + "target_size": {}, } - ] + ], + "zone": "zone_value", } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.CreateInstancesInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_create_instances_request_resource" + test_field = compute.InsertInstanceGroupManagerRequest.meta.fields[ + "instance_group_manager_resource" ] def get_message_fields(field): @@ -9525,7 +12536,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_create_instances_request_resource" + "instance_group_manager_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -9557,20 +12568,13 @@ def get_message_fields(field): if subfield: if field_repeated: for i in range( - 0, - len( - request_init[ - "instance_group_managers_create_instances_request_resource" - ][field] - ), + 0, len(request_init["instance_group_manager_resource"][field]) ): - del request_init[ - "instance_group_managers_create_instances_request_resource" - ][field][i][subfield] + del request_init["instance_group_manager_resource"][field][i][ + subfield + ] else: - del request_init[ - "instance_group_managers_create_instances_request_resource" - ][field][subfield] + del request_init["instance_group_manager_resource"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9610,7 +12614,8 @@ 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 - response = client.create_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.insert(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -9639,7 +12644,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_instances_rest_interceptors(null_interceptor): +def test_insert_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9653,14 +12658,14 @@ def test_create_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_create_instances" + transports.InstanceGroupManagersRestInterceptor, "post_insert" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_create_instances" + transports.InstanceGroupManagersRestInterceptor, "pre_insert" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.CreateInstancesInstanceGroupManagerRequest.pb( - compute.CreateInstancesInstanceGroupManagerRequest() + pb_message = compute.InsertInstanceGroupManagerRequest.pb( + compute.InsertInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9671,10 +12676,11 @@ def test_create_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.CreateInstancesInstanceGroupManagerRequest() + request = compute.InsertInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -9682,7 +12688,7 @@ def test_create_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.create_instances( + client.insert( request, metadata=[ ("key", "val"), @@ -9694,18 +12700,12 @@ def test_create_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_rest_bad_request( - request_type=compute.DeleteInstanceGroupManagerRequest, -): +def test_list_rest_bad_request(request_type=compute.ListInstanceGroupManagersRequest): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "zone": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "zone": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9719,55 +12719,34 @@ def test_delete_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list(request) @pytest.mark.parametrize( "request_type", [ - compute.DeleteInstanceGroupManagerRequest, + compute.ListInstanceGroupManagersRequest, dict, ], ) -def test_delete_rest_call_success(request_type): +def test_list_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "zone": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "zone": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", + return_value = compute.InstanceGroupManagerList( + id="id_value", kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", + next_page_token="next_page_token_value", self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", ) # Wrap the value into a proper Response obj @@ -9775,40 +12754,23 @@ def test_delete_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.InstanceGroupManagerList.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" + assert isinstance(response, pagers.ListPager) + assert response.id == "id_value" assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" + assert response.next_page_token == "next_page_token_value" assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_rest_interceptors(null_interceptor): +def test_list_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9822,14 +12784,14 @@ def test_delete_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_delete" + transports.InstanceGroupManagersRestInterceptor, "post_list" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_delete" + transports.InstanceGroupManagersRestInterceptor, "pre_list" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.DeleteInstanceGroupManagerRequest.pb( - compute.DeleteInstanceGroupManagerRequest() + pb_message = compute.ListInstanceGroupManagersRequest.pb( + compute.ListInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -9840,18 +12802,21 @@ def test_delete_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.InstanceGroupManagerList.to_json( + compute.InstanceGroupManagerList() + ) req.return_value.content = return_value - request = compute.DeleteInstanceGroupManagerRequest() + request = compute.ListInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.InstanceGroupManagerList() - client.delete( + client.list( request, metadata=[ ("key", "val"), @@ -9863,8 +12828,8 @@ def test_delete_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_instances_rest_bad_request( - request_type=compute.DeleteInstancesInstanceGroupManagerRequest, +def test_list_errors_rest_bad_request( + request_type=compute.ListErrorsInstanceGroupManagersRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -9888,17 +12853,18 @@ def test_delete_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_errors(request) @pytest.mark.parametrize( "request_type", [ - compute.DeleteInstancesInstanceGroupManagerRequest, + compute.ListErrorsInstanceGroupManagersRequest, dict, ], ) -def test_delete_instances_rest_call_success(request_type): +def test_list_errors_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -9909,120 +12875,13 @@ def test_delete_instances_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_delete_instances_request_resource"] = { - "instances": ["instances_value1", "instances_value2"], - "skip_instances_on_validation_error": True, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = compute.DeleteInstancesInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_delete_instances_request_resource" - ] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "instance_group_managers_delete_instances_request_resource" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range( - 0, - len( - request_init[ - "instance_group_managers_delete_instances_request_resource" - ][field] - ), - ): - del request_init[ - "instance_group_managers_delete_instances_request_resource" - ][field][i][subfield] - else: - del request_init[ - "instance_group_managers_delete_instances_request_resource" - ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", - kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", - self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", + return_value = compute.InstanceGroupManagersListErrorsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -10030,40 +12889,20 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.InstanceGroupManagersListErrorsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_errors(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" - assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" - assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListErrorsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_instances_rest_interceptors(null_interceptor): +def test_list_errors_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10077,14 +12916,14 @@ def test_delete_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_delete_instances" + transports.InstanceGroupManagersRestInterceptor, "post_list_errors" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_delete_instances" + transports.InstanceGroupManagersRestInterceptor, "pre_list_errors" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.DeleteInstancesInstanceGroupManagerRequest.pb( - compute.DeleteInstancesInstanceGroupManagerRequest() + pb_message = compute.ListErrorsInstanceGroupManagersRequest.pb( + compute.ListErrorsInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -10095,18 +12934,21 @@ def test_delete_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.InstanceGroupManagersListErrorsResponse.to_json( + compute.InstanceGroupManagersListErrorsResponse() + ) req.return_value.content = return_value - request = compute.DeleteInstancesInstanceGroupManagerRequest() + request = compute.ListErrorsInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.InstanceGroupManagersListErrorsResponse() - client.delete_instances( + client.list_errors( request, metadata=[ ("key", "val"), @@ -10118,8 +12960,8 @@ def test_delete_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_per_instance_configs_rest_bad_request( - request_type=compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, +def test_list_managed_instances_rest_bad_request( + request_type=compute.ListManagedInstancesInstanceGroupManagersRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -10143,17 +12985,18 @@ def test_delete_per_instance_configs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_managed_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.DeletePerInstanceConfigsInstanceGroupManagerRequest, + compute.ListManagedInstancesInstanceGroupManagersRequest, dict, ], ) -def test_delete_per_instance_configs_rest_call_success(request_type): +def test_list_managed_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10164,121 +13007,13 @@ def test_delete_per_instance_configs_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_delete_per_instance_configs_req_resource"] = { - "names": ["names_value1", "names_value2"] - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = ( - compute.DeletePerInstanceConfigsInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_delete_per_instance_configs_req_resource" - ] - ) - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "instance_group_managers_delete_per_instance_configs_req_resource" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range( - 0, - len( - request_init[ - "instance_group_managers_delete_per_instance_configs_req_resource" - ][field] - ), - ): - del request_init[ - "instance_group_managers_delete_per_instance_configs_req_resource" - ][field][i][subfield] - else: - del request_init[ - "instance_group_managers_delete_per_instance_configs_req_resource" - ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", - kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", - self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", + return_value = compute.InstanceGroupManagersListManagedInstancesResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -10286,40 +13021,22 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.InstanceGroupManagersListManagedInstancesResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_managed_instances(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" - assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" - assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListManagedInstancesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_per_instance_configs_rest_interceptors(null_interceptor): +def test_list_managed_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10333,16 +13050,14 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "post_delete_per_instance_configs", + transports.InstanceGroupManagersRestInterceptor, "post_list_managed_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "pre_delete_per_instance_configs", + transports.InstanceGroupManagersRestInterceptor, "pre_list_managed_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.DeletePerInstanceConfigsInstanceGroupManagerRequest.pb( - compute.DeletePerInstanceConfigsInstanceGroupManagerRequest() + pb_message = compute.ListManagedInstancesInstanceGroupManagersRequest.pb( + compute.ListManagedInstancesInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -10353,18 +13068,23 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ( + compute.InstanceGroupManagersListManagedInstancesResponse.to_json( + compute.InstanceGroupManagersListManagedInstancesResponse() + ) + ) req.return_value.content = return_value - request = compute.DeletePerInstanceConfigsInstanceGroupManagerRequest() + request = compute.ListManagedInstancesInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.InstanceGroupManagersListManagedInstancesResponse() - client.delete_per_instance_configs( + client.list_managed_instances( request, metadata=[ ("key", "val"), @@ -10376,7 +13096,9 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_rest_bad_request(request_type=compute.GetInstanceGroupManagerRequest): +def test_list_per_instance_configs_rest_bad_request( + request_type=compute.ListPerInstanceConfigsInstanceGroupManagersRequest, +): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10399,17 +13121,18 @@ def test_get_rest_bad_request(request_type=compute.GetInstanceGroupManagerReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.GetInstanceGroupManagerRequest, + compute.ListPerInstanceConfigsInstanceGroupManagersRequest, dict, ], ) -def test_get_rest_call_success(request_type): +def test_list_per_instance_configs_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10425,24 +13148,8 @@ def test_get_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManager( - base_instance_name="base_instance_name_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - fingerprint="fingerprint_value", - id=205, - instance_group="instance_group_value", - instance_template="instance_template_value", - kind="kind_value", - list_managed_instances_results="list_managed_instances_results_value", - name="name_value", - region="region_value", - satisfies_pzi=True, - satisfies_pzs=True, - self_link="self_link_value", - target_pools=["target_pools_value"], - target_size=1185, - zone="zone_value", + return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -10450,38 +13157,22 @@ def test_get_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManager.pb(return_value) + return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_per_instance_configs(request) # Establish that the response is the type that we expect. - assert isinstance(response, compute.InstanceGroupManager) - assert response.base_instance_name == "base_instance_name_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.fingerprint == "fingerprint_value" - assert response.id == 205 - assert response.instance_group == "instance_group_value" - assert response.instance_template == "instance_template_value" - assert response.kind == "kind_value" - assert ( - response.list_managed_instances_results - == "list_managed_instances_results_value" - ) - assert response.name == "name_value" - assert response.region == "region_value" - assert response.satisfies_pzi is True - assert response.satisfies_pzs is True - assert response.self_link == "self_link_value" - assert response.target_pools == ["target_pools_value"] - assert response.target_size == 1185 - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListPerInstanceConfigsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_rest_interceptors(null_interceptor): +def test_list_per_instance_configs_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10495,14 +13186,15 @@ def test_get_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_get" + transports.InstanceGroupManagersRestInterceptor, + "post_list_per_instance_configs", ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_get" + transports.InstanceGroupManagersRestInterceptor, "pre_list_per_instance_configs" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.GetInstanceGroupManagerRequest.pb( - compute.GetInstanceGroupManagerRequest() + pb_message = compute.ListPerInstanceConfigsInstanceGroupManagersRequest.pb( + compute.ListPerInstanceConfigsInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -10513,20 +13205,21 @@ def test_get_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.InstanceGroupManager.to_json( - compute.InstanceGroupManager() + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp.to_json( + compute.InstanceGroupManagersListPerInstanceConfigsResp() ) req.return_value.content = return_value - request = compute.GetInstanceGroupManagerRequest() + request = compute.ListPerInstanceConfigsInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManager() + post.return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp() - client.get( + client.list_per_instance_configs( request, metadata=[ ("key", "val"), @@ -10538,14 +13231,16 @@ def test_get_rest_interceptors(null_interceptor): post.assert_called_once() -def test_insert_rest_bad_request( - request_type=compute.InsertInstanceGroupManagerRequest, -): +def test_patch_rest_bad_request(request_type=compute.PatchInstanceGroupManagerRequest): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1", "zone": "sample2"} + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -10559,23 +13254,28 @@ def test_insert_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.insert(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.patch(request) @pytest.mark.parametrize( "request_type", [ - compute.InsertInstanceGroupManagerRequest, + compute.PatchInstanceGroupManagerRequest, dict, ], ) -def test_insert_rest_call_success(request_type): +def test_patch_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1", "zone": "sample2"} + request_init = { + "project": "sample1", + "zone": "sample2", + "instance_group_manager": "sample3", + } request_init["instance_group_manager_resource"] = { "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, "auto_healing_policies": [ @@ -10620,6 +13320,7 @@ def test_insert_rest_call_success(request_type): "satisfies_pzi": True, "satisfies_pzs": True, "self_link": "self_link_value", + "standby_policy": {"initial_delay_sec": 1778, "mode": "mode_value"}, "stateful_policy": { "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} }, @@ -10638,6 +13339,8 @@ def test_insert_rest_call_success(request_type): }, "target_pools": ["target_pools_value1", "target_pools_value2"], "target_size": 1185, + "target_stopped_size": 2047, + "target_suspended_size": 2251, "update_policy": { "instance_redistribution_type": "instance_redistribution_type_value", "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, @@ -10661,7 +13364,7 @@ def test_insert_rest_call_success(request_type): # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.InsertInstanceGroupManagerRequest.meta.fields[ + test_field = compute.PatchInstanceGroupManagerRequest.meta.fields[ "instance_group_manager_resource" ] @@ -10770,7 +13473,8 @@ 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 - response = client.insert(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.patch(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -10799,7 +13503,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_insert_rest_interceptors(null_interceptor): +def test_patch_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10813,14 +13517,14 @@ def test_insert_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_insert" + transports.InstanceGroupManagersRestInterceptor, "post_patch" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_insert" + transports.InstanceGroupManagersRestInterceptor, "pre_patch" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.InsertInstanceGroupManagerRequest.pb( - compute.InsertInstanceGroupManagerRequest() + pb_message = compute.PatchInstanceGroupManagerRequest.pb( + compute.PatchInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -10831,10 +13535,11 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.InsertInstanceGroupManagerRequest() + request = compute.PatchInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -10842,132 +13547,7 @@ def test_insert_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.insert( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_rest_bad_request(request_type=compute.ListInstanceGroupManagersRequest): - client = InstanceGroupManagersClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"project": "sample1", "zone": "sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list(request) - - -@pytest.mark.parametrize( - "request_type", - [ - compute.ListInstanceGroupManagersRequest, - dict, - ], -) -def test_list_rest_call_success(request_type): - client = InstanceGroupManagersClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"project": "sample1", "zone": "sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManagerList( - id="id_value", - kind="kind_value", - next_page_token="next_page_token_value", - self_link="self_link_value", - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = compute.InstanceGroupManagerList.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.list(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPager) - assert response.id == "id_value" - assert response.kind == "kind_value" - assert response.next_page_token == "next_page_token_value" - assert response.self_link == "self_link_value" - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_rest_interceptors(null_interceptor): - transport = transports.InstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.InstanceGroupManagersRestInterceptor(), - ) - client = InstanceGroupManagersClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_list" - ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_list" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = compute.ListInstanceGroupManagersRequest.pb( - compute.ListInstanceGroupManagersRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = compute.InstanceGroupManagerList.to_json( - compute.InstanceGroupManagerList() - ) - req.return_value.content = return_value - - request = compute.ListInstanceGroupManagersRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManagerList() - - client.list( + client.patch( request, metadata=[ ("key", "val"), @@ -10979,8 +13559,8 @@ def test_list_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_errors_rest_bad_request( - request_type=compute.ListErrorsInstanceGroupManagersRequest, +def test_patch_per_instance_configs_rest_bad_request( + request_type=compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11004,17 +13584,18 @@ def test_list_errors_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_errors(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.patch_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.ListErrorsInstanceGroupManagersRequest, + compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, dict, ], ) -def test_list_errors_rest_call_success(request_type): +def test_patch_per_instance_configs_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11025,13 +13606,131 @@ def test_list_errors_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } + request_init["instance_group_managers_patch_per_instance_configs_req_resource"] = { + "per_instance_configs": [ + { + "fingerprint": "fingerprint_value", + "name": "name_value", + "preserved_state": { + "disks": {}, + "external_i_ps": {}, + "internal_i_ps": {}, + "metadata": {}, + }, + "status": "status_value", + } + ] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_patch_per_instance_configs_req_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_patch_per_instance_configs_req_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_patch_per_instance_configs_req_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_patch_per_instance_configs_req_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_patch_per_instance_configs_req_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManagersListErrorsResponse( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -11039,19 +13738,41 @@ def test_list_errors_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManagersListErrorsResponse.pb(return_value) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_errors(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.patch_per_instance_configs(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListErrorsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_errors_rest_interceptors(null_interceptor): +def test_patch_per_instance_configs_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11065,14 +13786,16 @@ def test_list_errors_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_list_errors" + transports.InstanceGroupManagersRestInterceptor, + "post_patch_per_instance_configs", ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_list_errors" + transports.InstanceGroupManagersRestInterceptor, + "pre_patch_per_instance_configs", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ListErrorsInstanceGroupManagersRequest.pb( - compute.ListErrorsInstanceGroupManagersRequest() + pb_message = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest.pb( + compute.PatchPerInstanceConfigsInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11083,20 +13806,19 @@ def test_list_errors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.InstanceGroupManagersListErrorsResponse.to_json( - compute.InstanceGroupManagersListErrorsResponse() - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListErrorsInstanceGroupManagersRequest() + request = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManagersListErrorsResponse() + post.return_value = compute.Operation() - client.list_errors( + client.patch_per_instance_configs( request, metadata=[ ("key", "val"), @@ -11108,8 +13830,8 @@ def test_list_errors_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_managed_instances_rest_bad_request( - request_type=compute.ListManagedInstancesInstanceGroupManagersRequest, +def test_recreate_instances_rest_bad_request( + request_type=compute.RecreateInstancesInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11133,17 +13855,18 @@ def test_list_managed_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_managed_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.recreate_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.ListManagedInstancesInstanceGroupManagersRequest, + compute.RecreateInstancesInstanceGroupManagerRequest, dict, ], ) -def test_list_managed_instances_rest_call_success(request_type): +def test_recreate_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11154,13 +13877,119 @@ def test_list_managed_instances_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } + request_init["instance_group_managers_recreate_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.RecreateInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_recreate_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_recreate_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_recreate_instances_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_recreate_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_recreate_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManagersListManagedInstancesResponse( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -11168,21 +13997,41 @@ def test_list_managed_instances_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManagersListManagedInstancesResponse.pb( - return_value - ) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_managed_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.recreate_instances(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListManagedInstancesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_managed_instances_rest_interceptors(null_interceptor): +def test_recreate_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11196,14 +14045,14 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_list_managed_instances" + transports.InstanceGroupManagersRestInterceptor, "post_recreate_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_list_managed_instances" + transports.InstanceGroupManagersRestInterceptor, "pre_recreate_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ListManagedInstancesInstanceGroupManagersRequest.pb( - compute.ListManagedInstancesInstanceGroupManagersRequest() + pb_message = compute.RecreateInstancesInstanceGroupManagerRequest.pb( + compute.RecreateInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11213,23 +14062,20 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): } req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = ( - compute.InstanceGroupManagersListManagedInstancesResponse.to_json( - compute.InstanceGroupManagersListManagedInstancesResponse() - ) - ) + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListManagedInstancesInstanceGroupManagersRequest() + request = compute.RecreateInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManagersListManagedInstancesResponse() + post.return_value = compute.Operation() - client.list_managed_instances( + client.recreate_instances( request, metadata=[ ("key", "val"), @@ -11241,8 +14087,8 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_per_instance_configs_rest_bad_request( - request_type=compute.ListPerInstanceConfigsInstanceGroupManagersRequest, +def test_resize_rest_bad_request( + request_type=compute.ResizeInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11266,17 +14112,18 @@ def test_list_per_instance_configs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.resize(request) @pytest.mark.parametrize( "request_type", [ - compute.ListPerInstanceConfigsInstanceGroupManagersRequest, + compute.ResizeInstanceGroupManagerRequest, dict, ], ) -def test_list_per_instance_configs_rest_call_success(request_type): +def test_resize_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11292,8 +14139,29 @@ def test_list_per_instance_configs_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -11301,21 +14169,41 @@ def test_list_per_instance_configs_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp.pb( - return_value - ) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.resize(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPerInstanceConfigsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_per_instance_configs_rest_interceptors(null_interceptor): +def test_resize_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11329,15 +14217,14 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "post_list_per_instance_configs", + transports.InstanceGroupManagersRestInterceptor, "post_resize" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_list_per_instance_configs" + transports.InstanceGroupManagersRestInterceptor, "pre_resize" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ListPerInstanceConfigsInstanceGroupManagersRequest.pb( - compute.ListPerInstanceConfigsInstanceGroupManagersRequest() + pb_message = compute.ResizeInstanceGroupManagerRequest.pb( + compute.ResizeInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11348,20 +14235,19 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp.to_json( - compute.InstanceGroupManagersListPerInstanceConfigsResp() - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListPerInstanceConfigsInstanceGroupManagersRequest() + request = compute.ResizeInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManagersListPerInstanceConfigsResp() + post.return_value = compute.Operation() - client.list_per_instance_configs( + client.resize( request, metadata=[ ("key", "val"), @@ -11373,7 +14259,9 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_patch_rest_bad_request(request_type=compute.PatchInstanceGroupManagerRequest): +def test_resume_instances_rest_bad_request( + request_type=compute.ResumeInstancesInstanceGroupManagerRequest, +): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11396,17 +14284,18 @@ def test_patch_rest_bad_request(request_type=compute.PatchInstanceGroupManagerRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.patch(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.resume_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.PatchInstanceGroupManagerRequest, + compute.ResumeInstancesInstanceGroupManagerRequest, dict, ], ) -def test_patch_rest_call_success(request_type): +def test_resume_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11417,93 +14306,16 @@ def test_patch_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_manager_resource"] = { - "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, - "auto_healing_policies": [ - {"health_check": "health_check_value", "initial_delay_sec": 1778} - ], - "base_instance_name": "base_instance_name_value", - "creation_timestamp": "creation_timestamp_value", - "current_actions": { - "abandoning": 1041, - "creating": 845, - "creating_without_retries": 2589, - "deleting": 844, - "none": 432, - "recreating": 1060, - "refreshing": 1069, - "restarting": 1091, - "resuming": 874, - "starting": 876, - "stopping": 884, - "suspending": 1088, - "verifying": 979, - }, - "description": "description_value", - "distribution_policy": { - "target_shape": "target_shape_value", - "zones": [{"zone": "zone_value"}], - }, - "fingerprint": "fingerprint_value", - "id": 205, - "instance_flexibility_policy": {"instance_selections": {}}, - "instance_group": "instance_group_value", - "instance_lifecycle_policy": { - "default_action_on_failure": "default_action_on_failure_value", - "force_update_on_repair": "force_update_on_repair_value", - }, - "instance_template": "instance_template_value", - "kind": "kind_value", - "list_managed_instances_results": "list_managed_instances_results_value", - "name": "name_value", - "named_ports": [{"name": "name_value", "port": 453}], - "region": "region_value", - "satisfies_pzi": True, - "satisfies_pzs": True, - "self_link": "self_link_value", - "stateful_policy": { - "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} - }, - "status": { - "all_instances_config": { - "current_revision": "current_revision_value", - "effective": True, - }, - "autoscaler": "autoscaler_value", - "is_stable": True, - "stateful": { - "has_stateful_config": True, - "per_instance_configs": {"all_effective": True}, - }, - "version_target": {"is_reached": True}, - }, - "target_pools": ["target_pools_value1", "target_pools_value2"], - "target_size": 1185, - "update_policy": { - "instance_redistribution_type": "instance_redistribution_type_value", - "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, - "max_unavailable": {}, - "minimal_action": "minimal_action_value", - "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", - "replacement_method": "replacement_method_value", - "type_": "type__value", - }, - "versions": [ - { - "instance_template": "instance_template_value", - "name": "name_value", - "target_size": {}, - } - ], - "zone": "zone_value", + request_init["instance_group_managers_resume_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.PatchInstanceGroupManagerRequest.meta.fields[ - "instance_group_manager_resource" + test_field = compute.ResumeInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_resume_instances_request_resource" ] def get_message_fields(field): @@ -11533,7 +14345,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_manager_resource" + "instance_group_managers_resume_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -11565,13 +14377,20 @@ def get_message_fields(field): if subfield: if field_repeated: for i in range( - 0, len(request_init["instance_group_manager_resource"][field]) + 0, + len( + request_init[ + "instance_group_managers_resume_instances_request_resource" + ][field] + ), ): - del request_init["instance_group_manager_resource"][field][i][ - subfield - ] + del request_init[ + "instance_group_managers_resume_instances_request_resource" + ][field][i][subfield] else: - del request_init["instance_group_manager_resource"][field][subfield] + del request_init[ + "instance_group_managers_resume_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -11611,7 +14430,8 @@ 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 - response = client.patch(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.resume_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11640,7 +14460,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_patch_rest_interceptors(null_interceptor): +def test_resume_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11654,14 +14474,14 @@ def test_patch_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_patch" + transports.InstanceGroupManagersRestInterceptor, "post_resume_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_patch" + transports.InstanceGroupManagersRestInterceptor, "pre_resume_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.PatchInstanceGroupManagerRequest.pb( - compute.PatchInstanceGroupManagerRequest() + pb_message = compute.ResumeInstancesInstanceGroupManagerRequest.pb( + compute.ResumeInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11672,10 +14492,11 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.PatchInstanceGroupManagerRequest() + request = compute.ResumeInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -11683,7 +14504,7 @@ def test_patch_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.patch( + client.resume_instances( request, metadata=[ ("key", "val"), @@ -11695,8 +14516,8 @@ def test_patch_rest_interceptors(null_interceptor): post.assert_called_once() -def test_patch_per_instance_configs_rest_bad_request( - request_type=compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, +def test_set_instance_template_rest_bad_request( + request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11720,17 +14541,18 @@ def test_patch_per_instance_configs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.patch_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.set_instance_template(request) @pytest.mark.parametrize( "request_type", [ - compute.PatchPerInstanceConfigsInstanceGroupManagerRequest, + compute.SetInstanceTemplateInstanceGroupManagerRequest, dict, ], ) -def test_patch_per_instance_configs_rest_call_success(request_type): +def test_set_instance_template_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11741,28 +14563,16 @@ def test_patch_per_instance_configs_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_patch_per_instance_configs_req_resource"] = { - "per_instance_configs": [ - { - "fingerprint": "fingerprint_value", - "name": "name_value", - "preserved_state": { - "disks": {}, - "external_i_ps": {}, - "internal_i_ps": {}, - "metadata": {}, - }, - "status": "status_value", - } - ] + request_init["instance_group_managers_set_instance_template_request_resource"] = { + "instance_template": "instance_template_value" } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_patch_per_instance_configs_req_resource" + test_field = compute.SetInstanceTemplateInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_set_instance_template_request_resource" ] def get_message_fields(field): @@ -11792,7 +14602,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_patch_per_instance_configs_req_resource" + "instance_group_managers_set_instance_template_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -11827,16 +14637,16 @@ def get_message_fields(field): 0, len( request_init[ - "instance_group_managers_patch_per_instance_configs_req_resource" + "instance_group_managers_set_instance_template_request_resource" ][field] ), ): del request_init[ - "instance_group_managers_patch_per_instance_configs_req_resource" + "instance_group_managers_set_instance_template_request_resource" ][field][i][subfield] else: del request_init[ - "instance_group_managers_patch_per_instance_configs_req_resource" + "instance_group_managers_set_instance_template_request_resource" ][field][subfield] request = request_type(**request_init) @@ -11877,7 +14687,8 @@ 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 - response = client.patch_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.set_instance_template(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11906,7 +14717,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_patch_per_instance_configs_rest_interceptors(null_interceptor): +def test_set_instance_template_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11920,16 +14731,14 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "post_patch_per_instance_configs", + transports.InstanceGroupManagersRestInterceptor, "post_set_instance_template" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, - "pre_patch_per_instance_configs", + transports.InstanceGroupManagersRestInterceptor, "pre_set_instance_template" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest.pb( - compute.PatchPerInstanceConfigsInstanceGroupManagerRequest() + post.assert_not_called() + pb_message = compute.SetInstanceTemplateInstanceGroupManagerRequest.pb( + compute.SetInstanceTemplateInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11940,10 +14749,11 @@ def test_patch_per_instance_configs_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.PatchPerInstanceConfigsInstanceGroupManagerRequest() + request = compute.SetInstanceTemplateInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -11951,7 +14761,7 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.patch_per_instance_configs( + client.set_instance_template( request, metadata=[ ("key", "val"), @@ -11963,8 +14773,8 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_recreate_instances_rest_bad_request( - request_type=compute.RecreateInstancesInstanceGroupManagerRequest, +def test_set_target_pools_rest_bad_request( + request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11988,17 +14798,18 @@ def test_recreate_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.recreate_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.set_target_pools(request) @pytest.mark.parametrize( "request_type", [ - compute.RecreateInstancesInstanceGroupManagerRequest, + compute.SetTargetPoolsInstanceGroupManagerRequest, dict, ], ) -def test_recreate_instances_rest_call_success(request_type): +def test_set_target_pools_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12009,16 +14820,17 @@ def test_recreate_instances_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_recreate_instances_request_resource"] = { - "instances": ["instances_value1", "instances_value2"] + request_init["instance_group_managers_set_target_pools_request_resource"] = { + "fingerprint": "fingerprint_value", + "target_pools": ["target_pools_value1", "target_pools_value2"], } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.RecreateInstancesInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_recreate_instances_request_resource" + test_field = compute.SetTargetPoolsInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_set_target_pools_request_resource" ] def get_message_fields(field): @@ -12048,7 +14860,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_recreate_instances_request_resource" + "instance_group_managers_set_target_pools_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -12083,16 +14895,16 @@ def get_message_fields(field): 0, len( request_init[ - "instance_group_managers_recreate_instances_request_resource" + "instance_group_managers_set_target_pools_request_resource" ][field] ), ): del request_init[ - "instance_group_managers_recreate_instances_request_resource" + "instance_group_managers_set_target_pools_request_resource" ][field][i][subfield] else: del request_init[ - "instance_group_managers_recreate_instances_request_resource" + "instance_group_managers_set_target_pools_request_resource" ][field][subfield] request = request_type(**request_init) @@ -12133,7 +14945,8 @@ 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 - response = client.recreate_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.set_target_pools(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12162,7 +14975,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_recreate_instances_rest_interceptors(null_interceptor): +def test_set_target_pools_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12176,14 +14989,14 @@ def test_recreate_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_recreate_instances" + transports.InstanceGroupManagersRestInterceptor, "post_set_target_pools" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_recreate_instances" + transports.InstanceGroupManagersRestInterceptor, "pre_set_target_pools" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.RecreateInstancesInstanceGroupManagerRequest.pb( - compute.RecreateInstancesInstanceGroupManagerRequest() + pb_message = compute.SetTargetPoolsInstanceGroupManagerRequest.pb( + compute.SetTargetPoolsInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12194,10 +15007,11 @@ def test_recreate_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.RecreateInstancesInstanceGroupManagerRequest() + request = compute.SetTargetPoolsInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12205,7 +15019,7 @@ def test_recreate_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.recreate_instances( + client.set_target_pools( request, metadata=[ ("key", "val"), @@ -12217,8 +15031,8 @@ def test_recreate_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_resize_rest_bad_request( - request_type=compute.ResizeInstanceGroupManagerRequest, +def test_start_instances_rest_bad_request( + request_type=compute.StartInstancesInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -12242,17 +15056,18 @@ def test_resize_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.resize(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.start_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.ResizeInstanceGroupManagerRequest, + compute.StartInstancesInstanceGroupManagerRequest, dict, ], ) -def test_resize_rest_call_success(request_type): +def test_start_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12263,6 +15078,91 @@ def test_resize_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } + request_init["instance_group_managers_start_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.StartInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_start_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "instance_group_managers_start_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "instance_group_managers_start_instances_request_resource" + ][field] + ), + ): + del request_init[ + "instance_group_managers_start_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "instance_group_managers_start_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12302,7 +15202,8 @@ def test_resize_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 - response = client.resize(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.start_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12331,7 +15232,7 @@ def test_resize_rest_call_success(request_type): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_resize_rest_interceptors(null_interceptor): +def test_start_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12345,14 +15246,14 @@ def test_resize_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_resize" + transports.InstanceGroupManagersRestInterceptor, "post_start_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_resize" + transports.InstanceGroupManagersRestInterceptor, "pre_start_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ResizeInstanceGroupManagerRequest.pb( - compute.ResizeInstanceGroupManagerRequest() + pb_message = compute.StartInstancesInstanceGroupManagerRequest.pb( + compute.StartInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12363,10 +15264,11 @@ def test_resize_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ResizeInstanceGroupManagerRequest() + request = compute.StartInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12374,7 +15276,7 @@ def test_resize_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.resize( + client.start_instances( request, metadata=[ ("key", "val"), @@ -12386,8 +15288,8 @@ def test_resize_rest_interceptors(null_interceptor): post.assert_called_once() -def test_set_instance_template_rest_bad_request( - request_type=compute.SetInstanceTemplateInstanceGroupManagerRequest, +def test_stop_instances_rest_bad_request( + request_type=compute.StopInstancesInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -12411,17 +15313,18 @@ def test_set_instance_template_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.set_instance_template(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.stop_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.SetInstanceTemplateInstanceGroupManagerRequest, + compute.StopInstancesInstanceGroupManagerRequest, dict, ], ) -def test_set_instance_template_rest_call_success(request_type): +def test_stop_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12432,16 +15335,17 @@ def test_set_instance_template_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_set_instance_template_request_resource"] = { - "instance_template": "instance_template_value" + request_init["instance_group_managers_stop_instances_request_resource"] = { + "force_stop": True, + "instances": ["instances_value1", "instances_value2"], } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.SetInstanceTemplateInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_set_instance_template_request_resource" + test_field = compute.StopInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_stop_instances_request_resource" ] def get_message_fields(field): @@ -12471,7 +15375,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_set_instance_template_request_resource" + "instance_group_managers_stop_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -12506,16 +15410,16 @@ def get_message_fields(field): 0, len( request_init[ - "instance_group_managers_set_instance_template_request_resource" + "instance_group_managers_stop_instances_request_resource" ][field] ), ): del request_init[ - "instance_group_managers_set_instance_template_request_resource" + "instance_group_managers_stop_instances_request_resource" ][field][i][subfield] else: del request_init[ - "instance_group_managers_set_instance_template_request_resource" + "instance_group_managers_stop_instances_request_resource" ][field][subfield] request = request_type(**request_init) @@ -12556,7 +15460,8 @@ 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 - response = client.set_instance_template(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.stop_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12585,7 +15490,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_instance_template_rest_interceptors(null_interceptor): +def test_stop_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12599,14 +15504,14 @@ def test_set_instance_template_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_set_instance_template" + transports.InstanceGroupManagersRestInterceptor, "post_stop_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_set_instance_template" + transports.InstanceGroupManagersRestInterceptor, "pre_stop_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.SetInstanceTemplateInstanceGroupManagerRequest.pb( - compute.SetInstanceTemplateInstanceGroupManagerRequest() + pb_message = compute.StopInstancesInstanceGroupManagerRequest.pb( + compute.StopInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12617,10 +15522,11 @@ def test_set_instance_template_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.SetInstanceTemplateInstanceGroupManagerRequest() + request = compute.StopInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12628,7 +15534,7 @@ def test_set_instance_template_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.set_instance_template( + client.stop_instances( request, metadata=[ ("key", "val"), @@ -12640,8 +15546,8 @@ def test_set_instance_template_rest_interceptors(null_interceptor): post.assert_called_once() -def test_set_target_pools_rest_bad_request( - request_type=compute.SetTargetPoolsInstanceGroupManagerRequest, +def test_suspend_instances_rest_bad_request( + request_type=compute.SuspendInstancesInstanceGroupManagerRequest, ): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -12665,17 +15571,18 @@ def test_set_target_pools_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.set_target_pools(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.suspend_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.SetTargetPoolsInstanceGroupManagerRequest, + compute.SuspendInstancesInstanceGroupManagerRequest, dict, ], ) -def test_set_target_pools_rest_call_success(request_type): +def test_suspend_instances_rest_call_success(request_type): client = InstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12686,17 +15593,17 @@ def test_set_target_pools_rest_call_success(request_type): "zone": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_managers_set_target_pools_request_resource"] = { - "fingerprint": "fingerprint_value", - "target_pools": ["target_pools_value1", "target_pools_value2"], + request_init["instance_group_managers_suspend_instances_request_resource"] = { + "force_suspend": True, + "instances": ["instances_value1", "instances_value2"], } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.SetTargetPoolsInstanceGroupManagerRequest.meta.fields[ - "instance_group_managers_set_target_pools_request_resource" + test_field = compute.SuspendInstancesInstanceGroupManagerRequest.meta.fields[ + "instance_group_managers_suspend_instances_request_resource" ] def get_message_fields(field): @@ -12726,7 +15633,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_managers_set_target_pools_request_resource" + "instance_group_managers_suspend_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -12761,16 +15668,16 @@ def get_message_fields(field): 0, len( request_init[ - "instance_group_managers_set_target_pools_request_resource" + "instance_group_managers_suspend_instances_request_resource" ][field] ), ): del request_init[ - "instance_group_managers_set_target_pools_request_resource" + "instance_group_managers_suspend_instances_request_resource" ][field][i][subfield] else: del request_init[ - "instance_group_managers_set_target_pools_request_resource" + "instance_group_managers_suspend_instances_request_resource" ][field][subfield] request = request_type(**request_init) @@ -12811,7 +15718,8 @@ 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 - response = client.set_target_pools(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.suspend_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12840,7 +15748,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_target_pools_rest_interceptors(null_interceptor): +def test_suspend_instances_rest_interceptors(null_interceptor): transport = transports.InstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12854,14 +15762,14 @@ def test_set_target_pools_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "post_set_target_pools" + transports.InstanceGroupManagersRestInterceptor, "post_suspend_instances" ) as post, mock.patch.object( - transports.InstanceGroupManagersRestInterceptor, "pre_set_target_pools" + transports.InstanceGroupManagersRestInterceptor, "pre_suspend_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.SetTargetPoolsInstanceGroupManagerRequest.pb( - compute.SetTargetPoolsInstanceGroupManagerRequest() + pb_message = compute.SuspendInstancesInstanceGroupManagerRequest.pb( + compute.SuspendInstancesInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12872,10 +15780,11 @@ def test_set_target_pools_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.SetTargetPoolsInstanceGroupManagerRequest() + request = compute.SuspendInstancesInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12883,7 +15792,7 @@ def test_set_target_pools_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.set_target_pools( + client.suspend_instances( request, metadata=[ ("key", "val"), @@ -12920,6 +15829,7 @@ def test_update_per_instance_configs_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.update_per_instance_configs(request) @@ -13079,6 +15989,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_per_instance_configs(request) # Establish that the response is the type that we expect. @@ -13142,6 +16053,7 @@ def test_update_per_instance_configs_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -13526,6 +16438,26 @@ def test_resize_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_resume_instances_unary_empty_call_rest(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.resume_instances), "__call__") as call: + client.resume_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.ResumeInstancesInstanceGroupManagerRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_set_instance_template_unary_empty_call_rest(): @@ -13568,6 +16500,68 @@ def test_set_target_pools_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_start_instances_unary_empty_call_rest(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.start_instances), "__call__") as call: + client.start_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.StartInstancesInstanceGroupManagerRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_stop_instances_unary_empty_call_rest(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.stop_instances), "__call__") as call: + client.stop_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.StopInstancesInstanceGroupManagerRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_suspend_instances_unary_empty_call_rest(): + client = InstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.suspend_instances), "__call__" + ) as call: + client.suspend_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.SuspendInstancesInstanceGroupManagerRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_update_per_instance_configs_unary_empty_call_rest(): @@ -13629,8 +16623,12 @@ def test_instance_group_managers_base_transport(): "patch_per_instance_configs", "recreate_instances", "resize", + "resume_instances", "set_instance_template", "set_target_pools", + "start_instances", + "stop_instances", + "suspend_instances", "update_per_instance_configs", ) for method in methods: @@ -13820,12 +16818,24 @@ def test_instance_group_managers_client_transport_session_collision(transport_na session1 = client1.transport.resize._session session2 = client2.transport.resize._session assert session1 != session2 + session1 = client1.transport.resume_instances._session + session2 = client2.transport.resume_instances._session + assert session1 != session2 session1 = client1.transport.set_instance_template._session session2 = client2.transport.set_instance_template._session assert session1 != session2 session1 = client1.transport.set_target_pools._session session2 = client2.transport.set_target_pools._session assert session1 != session2 + session1 = client1.transport.start_instances._session + session2 = client2.transport.start_instances._session + assert session1 != session2 + session1 = client1.transport.stop_instances._session + session2 = client2.transport.stop_instances._session + assert session1 != session2 + session1 = client1.transport.suspend_instances._session + session2 = client2.transport.suspend_instances._session + assert session1 != session2 session1 = client1.transport.update_per_instance_configs._session session2 = client2.transport.update_per_instance_configs._session assert session1 != session2 diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_groups.py index 95e87f3db9cd..a6e30fd275a0 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_groups.py @@ -1019,6 +1019,7 @@ def test_add_instances_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.add_instances(request) @@ -1083,6 +1084,7 @@ def test_add_instances_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.add_instances(**mock_args) @@ -1234,6 +1236,7 @@ def test_add_instances_unary_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.add_instances_unary(request) @@ -1298,6 +1301,7 @@ def test_add_instances_unary_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.add_instances_unary(**mock_args) @@ -1446,6 +1450,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1504,6 +1509,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1722,6 +1728,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteInstanceGroupReq 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(request) @@ -1782,6 +1789,7 @@ def test_delete_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.delete(**mock_args) @@ -1929,6 +1937,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1989,6 +1998,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2128,6 +2138,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstanceGroupRequest): 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(request) @@ -2188,6 +2199,7 @@ def test_get_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(**mock_args) @@ -2330,6 +2342,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertInstanceGroupReq 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.insert(request) @@ -2388,6 +2401,7 @@ def test_insert_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.insert(**mock_args) @@ -2534,6 +2548,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2592,6 +2607,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2739,6 +2755,7 @@ def test_list_rest_required_fields(request_type=compute.ListInstanceGroupsReques 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(request) @@ -2801,6 +2818,7 @@ def test_list_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(**mock_args) @@ -3013,6 +3031,7 @@ def test_list_instances_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.list_instances(request) @@ -3085,6 +3104,7 @@ def test_list_instances_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_instances(**mock_args) @@ -3310,6 +3330,7 @@ def test_remove_instances_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.remove_instances(request) @@ -3374,6 +3395,7 @@ def test_remove_instances_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.remove_instances(**mock_args) @@ -3527,6 +3549,7 @@ def test_remove_instances_unary_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.remove_instances_unary(request) @@ -3591,6 +3614,7 @@ def test_remove_instances_unary_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.remove_instances_unary(**mock_args) @@ -3742,6 +3766,7 @@ def test_set_named_ports_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_named_ports(request) @@ -3806,6 +3831,7 @@ def test_set_named_ports_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_named_ports(**mock_args) @@ -3957,6 +3983,7 @@ def test_set_named_ports_unary_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_named_ports_unary(request) @@ -4021,6 +4048,7 @@ def test_set_named_ports_unary_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_named_ports_unary(**mock_args) @@ -4162,6 +4190,7 @@ def test_add_instances_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.add_instances(request) @@ -4307,6 +4336,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.add_instances(request) # Establish that the response is the type that we expect. @@ -4368,6 +4398,7 @@ def test_add_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4412,6 +4443,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -4451,6 +4483,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -4495,6 +4528,7 @@ def test_aggregated_list_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 = compute.InstanceGroupAggregatedList.to_json( compute.InstanceGroupAggregatedList() ) @@ -4543,6 +4577,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteInstanceGroupRequest 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(request) @@ -4603,6 +4638,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4664,6 +4700,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4710,6 +4747,7 @@ def test_get_rest_bad_request(request_type=compute.GetInstanceGroupRequest): 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(request) @@ -4760,6 +4798,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4811,6 +4850,7 @@ def test_get_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 = compute.InstanceGroup.to_json(compute.InstanceGroup()) req.return_value.content = return_value @@ -4853,6 +4893,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertInstanceGroupRequest 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.insert(request) @@ -4995,6 +5036,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.insert(request) # Establish that the response is the type that we expect. @@ -5056,6 +5098,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5098,6 +5141,7 @@ def test_list_rest_bad_request(request_type=compute.ListInstanceGroupsRequest): 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(request) @@ -5136,6 +5180,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5179,6 +5224,7 @@ def test_list_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 = compute.InstanceGroupList.to_json(compute.InstanceGroupList()) req.return_value.content = return_value @@ -5227,6 +5273,7 @@ def test_list_instances_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.list_instances(request) @@ -5354,6 +5401,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.list_instances(request) # Establish that the response is the type that we expect. @@ -5397,6 +5445,7 @@ def test_list_instances_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 = compute.InstanceGroupsListInstances.to_json( compute.InstanceGroupsListInstances() ) @@ -5447,6 +5496,7 @@ def test_remove_instances_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.remove_instances(request) @@ -5592,6 +5642,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.remove_instances(request) # Establish that the response is the type that we expect. @@ -5653,6 +5704,7 @@ def test_remove_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5701,6 +5753,7 @@ def test_set_named_ports_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_named_ports(request) @@ -5847,6 +5900,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.set_named_ports(request) # Establish that the response is the type that we expect. @@ -5908,6 +5962,7 @@ def test_set_named_ports_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_settings_service.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_settings_service.py index 9801d874beae..70a016423df3 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_settings_service.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_settings_service.py @@ -1051,6 +1051,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstanceSettingRequest 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(request) @@ -1105,6 +1106,7 @@ def test_get_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(**mock_args) @@ -1251,6 +1253,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchInstanceSettingReq 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.patch(request) @@ -1314,6 +1317,7 @@ def test_patch_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.patch(**mock_args) @@ -1465,6 +1469,7 @@ def test_patch_unary_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.patch_unary(request) @@ -1528,6 +1533,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -1662,6 +1668,7 @@ def test_get_rest_bad_request(request_type=compute.GetInstanceSettingRequest): 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(request) @@ -1699,6 +1706,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1741,6 +1749,7 @@ def test_get_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 = compute.InstanceSettings.to_json(compute.InstanceSettings()) req.return_value.content = return_value @@ -1783,6 +1792,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchInstanceSettingRequest 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.patch(request) @@ -1918,6 +1928,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.patch(request) # Establish that the response is the type that we expect. @@ -1979,6 +1990,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_templates.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_templates.py index c535e17bf157..852af628bbae 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_templates.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instance_templates.py @@ -1044,6 +1044,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1102,6 +1103,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1318,6 +1320,7 @@ def test_delete_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.delete(request) @@ -1372,6 +1375,7 @@ def test_delete_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.delete(**mock_args) @@ -1514,6 +1518,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1568,6 +1573,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1702,6 +1708,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstanceTemplateReques 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(request) @@ -1756,6 +1763,7 @@ def test_get_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(**mock_args) @@ -1894,6 +1902,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) @@ -1948,6 +1957,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) @@ -2087,6 +2097,7 @@ def test_insert_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.insert(request) @@ -2143,6 +2154,7 @@ def test_insert_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.insert(**mock_args) @@ -2284,6 +2296,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2340,6 +2353,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2482,6 +2496,7 @@ def test_list_rest_required_fields(request_type=compute.ListInstanceTemplatesReq 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(request) @@ -2538,6 +2553,7 @@ def test_list_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(**mock_args) @@ -2735,6 +2751,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) @@ -2793,6 +2810,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) @@ -2937,6 +2955,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) @@ -2995,6 +3014,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) @@ -3131,6 +3151,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3169,6 +3190,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3212,6 +3234,7 @@ def test_aggregated_list_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 = compute.InstanceTemplateAggregatedList.to_json( compute.InstanceTemplateAggregatedList() ) @@ -3256,6 +3279,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteInstanceTemplateRequ 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(request) @@ -3312,6 +3336,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3373,6 +3398,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3415,6 +3441,7 @@ def test_get_rest_bad_request(request_type=compute.GetInstanceTemplateRequest): 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(request) @@ -3457,6 +3484,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3504,6 +3532,7 @@ def test_get_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 = compute.InstanceTemplate.to_json(compute.InstanceTemplate()) req.return_value.content = return_value @@ -3548,6 +3577,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) @@ -3585,6 +3615,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. @@ -3627,6 +3658,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3669,6 +3701,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertInstanceTemplateRequ 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.insert(request) @@ -3995,6 +4028,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.insert(request) # Establish that the response is the type that we expect. @@ -4056,6 +4090,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4098,6 +4133,7 @@ def test_list_rest_bad_request(request_type=compute.ListInstanceTemplatesRequest 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(request) @@ -4136,6 +4172,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4179,6 +4216,7 @@ def test_list_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 = compute.InstanceTemplateList.to_json( compute.InstanceTemplateList() ) @@ -4225,6 +4263,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) @@ -4378,6 +4417,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4420,6 +4460,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4464,6 +4505,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) @@ -4577,6 +4619,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4617,6 +4660,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instances.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instances.py index 4739891329c4..6f428a2c81bd 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instances.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instances.py @@ -1004,6 +1004,7 @@ def test_add_access_config_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.add_access_config(request) @@ -1080,6 +1081,7 @@ def test_add_access_config_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.add_access_config(**mock_args) @@ -1246,6 +1248,7 @@ def test_add_access_config_unary_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.add_access_config_unary(request) @@ -1322,6 +1325,7 @@ def test_add_access_config_unary_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.add_access_config_unary(**mock_args) @@ -1479,6 +1483,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -1543,6 +1548,7 @@ def test_add_resource_policies_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.add_resource_policies(**mock_args) @@ -1699,6 +1705,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(request) @@ -1763,6 +1770,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(**mock_args) @@ -1911,6 +1919,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1969,6 +1978,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -2190,6 +2200,7 @@ def test_attach_disk_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.attach_disk(request) @@ -2259,6 +2270,7 @@ def test_attach_disk_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.attach_disk(**mock_args) @@ -2415,6 +2427,7 @@ def test_attach_disk_unary_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.attach_disk_unary(request) @@ -2484,6 +2497,7 @@ def test_attach_disk_unary_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.attach_disk_unary(**mock_args) @@ -2631,6 +2645,7 @@ def test_bulk_insert_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.bulk_insert(request) @@ -2689,6 +2704,7 @@ def test_bulk_insert_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.bulk_insert(**mock_args) @@ -2835,6 +2851,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(request) @@ -2893,6 +2910,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(**mock_args) @@ -3040,6 +3058,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteInstanceRequest) 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(request) @@ -3100,6 +3119,7 @@ def test_delete_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.delete(**mock_args) @@ -3245,6 +3265,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteInstanceRe 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_unary(request) @@ -3305,6 +3326,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -3476,6 +3498,7 @@ def test_delete_access_config_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.delete_access_config(request) @@ -3555,6 +3578,7 @@ def test_delete_access_config_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.delete_access_config(**mock_args) @@ -3728,6 +3752,7 @@ def test_delete_access_config_unary_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.delete_access_config_unary(request) @@ -3807,6 +3832,7 @@ def test_delete_access_config_unary_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.delete_access_config_unary(**mock_args) @@ -3968,6 +3994,7 @@ def test_detach_disk_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.detach_disk(request) @@ -4040,6 +4067,7 @@ def test_detach_disk_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.detach_disk(**mock_args) @@ -4200,6 +4228,7 @@ def test_detach_disk_unary_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.detach_disk_unary(request) @@ -4272,6 +4301,7 @@ def test_detach_disk_unary_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.detach_disk_unary(**mock_args) @@ -4412,6 +4442,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstanceRequest): 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(request) @@ -4472,6 +4503,7 @@ def test_get_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(**mock_args) @@ -4629,6 +4661,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -4696,6 +4729,7 @@ def test_get_effective_firewalls_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_effective_firewalls(**mock_args) @@ -4849,6 +4883,7 @@ def test_get_guest_attributes_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_guest_attributes(request) @@ -4914,6 +4949,7 @@ def test_get_guest_attributes_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_guest_attributes(**mock_args) @@ -5057,6 +5093,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) @@ -5117,6 +5154,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) @@ -5258,6 +5296,7 @@ def test_get_screenshot_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_screenshot(request) @@ -5318,6 +5357,7 @@ def test_get_screenshot_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_screenshot(**mock_args) @@ -5471,6 +5511,7 @@ def test_get_serial_port_output_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_serial_port_output(request) @@ -5536,6 +5577,7 @@ def test_get_serial_port_output_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_serial_port_output(**mock_args) @@ -5682,6 +5724,7 @@ def test_get_shielded_instance_identity_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_shielded_instance_identity(request) @@ -5744,6 +5787,7 @@ def test_get_shielded_instance_identity_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_shielded_instance_identity(**mock_args) @@ -5892,6 +5936,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertInstanceRequest) 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.insert(request) @@ -5958,6 +6003,7 @@ def test_insert_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.insert(**mock_args) @@ -6110,6 +6156,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertInstanceRe 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.insert_unary(request) @@ -6176,6 +6223,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -6325,6 +6373,7 @@ def test_list_rest_required_fields(request_type=compute.ListInstancesRequest): 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(request) @@ -6387,6 +6436,7 @@ def test_list_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(**mock_args) @@ -6598,6 +6648,7 @@ def test_list_referrers_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.list_referrers(request) @@ -6666,6 +6717,7 @@ def test_list_referrers_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_referrers(**mock_args) @@ -6882,6 +6934,7 @@ def test_perform_maintenance_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.perform_maintenance(request) @@ -6942,6 +6995,7 @@ def test_perform_maintenance_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.perform_maintenance(**mock_args) @@ -7093,6 +7147,7 @@ def test_perform_maintenance_unary_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.perform_maintenance_unary(request) @@ -7153,6 +7208,7 @@ def test_perform_maintenance_unary_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.perform_maintenance_unary(**mock_args) @@ -7306,6 +7362,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -7370,6 +7427,7 @@ def test_remove_resource_policies_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.remove_resource_policies(**mock_args) @@ -7526,6 +7584,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(request) @@ -7590,6 +7649,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(**mock_args) @@ -7738,6 +7798,7 @@ def test_reset_rest_required_fields(request_type=compute.ResetInstanceRequest): 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.reset(request) @@ -7798,6 +7859,7 @@ def test_reset_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.reset(**mock_args) @@ -7943,6 +8005,7 @@ def test_reset_unary_rest_required_fields(request_type=compute.ResetInstanceRequ 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.reset_unary(request) @@ -8003,6 +8066,7 @@ def test_reset_unary_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.reset_unary(**mock_args) @@ -8148,6 +8212,7 @@ def test_resume_rest_required_fields(request_type=compute.ResumeInstanceRequest) 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(request) @@ -8208,6 +8273,7 @@ def test_resume_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(**mock_args) @@ -8353,6 +8419,7 @@ def test_resume_unary_rest_required_fields(request_type=compute.ResumeInstanceRe 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_unary(request) @@ -8413,6 +8480,7 @@ def test_resume_unary_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_unary(**mock_args) @@ -8561,6 +8629,7 @@ def test_send_diagnostic_interrupt_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.send_diagnostic_interrupt(request) @@ -8621,6 +8690,7 @@ def test_send_diagnostic_interrupt_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.send_diagnostic_interrupt(**mock_args) @@ -8778,6 +8848,7 @@ def test_set_deletion_protection_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_deletion_protection(request) @@ -8843,6 +8914,7 @@ def test_set_deletion_protection_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_deletion_protection(**mock_args) @@ -9000,6 +9072,7 @@ def test_set_deletion_protection_unary_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_deletion_protection_unary(request) @@ -9065,6 +9138,7 @@ def test_set_deletion_protection_unary_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_deletion_protection_unary(**mock_args) @@ -9236,6 +9310,7 @@ def test_set_disk_auto_delete_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_disk_auto_delete(request) @@ -9315,6 +9390,7 @@ def test_set_disk_auto_delete_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_disk_auto_delete(**mock_args) @@ -9488,6 +9564,7 @@ def test_set_disk_auto_delete_unary_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_disk_auto_delete_unary(request) @@ -9567,6 +9644,7 @@ def test_set_disk_auto_delete_unary_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_disk_auto_delete_unary(**mock_args) @@ -9711,6 +9789,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) @@ -9775,6 +9854,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) @@ -9924,6 +10004,7 @@ def test_set_labels_rest_required_fields(request_type=compute.SetLabelsInstanceR 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_labels(request) @@ -9988,6 +10069,7 @@ def test_set_labels_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_labels(**mock_args) @@ -10139,6 +10221,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -10203,6 +10286,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -10359,6 +10443,7 @@ def test_set_machine_resources_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_machine_resources(request) @@ -10423,6 +10508,7 @@ def test_set_machine_resources_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_machine_resources(**mock_args) @@ -10579,6 +10665,7 @@ def test_set_machine_resources_unary_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_machine_resources_unary(request) @@ -10643,6 +10730,7 @@ def test_set_machine_resources_unary_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_machine_resources_unary(**mock_args) @@ -10796,6 +10884,7 @@ def test_set_machine_type_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_machine_type(request) @@ -10860,6 +10949,7 @@ def test_set_machine_type_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_machine_type(**mock_args) @@ -11013,6 +11103,7 @@ def test_set_machine_type_unary_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_machine_type_unary(request) @@ -11077,6 +11168,7 @@ def test_set_machine_type_unary_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_machine_type_unary(**mock_args) @@ -11228,6 +11320,7 @@ def test_set_metadata_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_metadata(request) @@ -11290,6 +11383,7 @@ def test_set_metadata_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_metadata(**mock_args) @@ -11439,6 +11533,7 @@ def test_set_metadata_unary_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_metadata_unary(request) @@ -11501,6 +11596,7 @@ def test_set_metadata_unary_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_metadata_unary(**mock_args) @@ -11654,6 +11750,7 @@ def test_set_min_cpu_platform_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_min_cpu_platform(request) @@ -11718,6 +11815,7 @@ def test_set_min_cpu_platform_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_min_cpu_platform(**mock_args) @@ -11873,6 +11971,7 @@ def test_set_min_cpu_platform_unary_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_min_cpu_platform_unary(request) @@ -11937,6 +12036,7 @@ def test_set_min_cpu_platform_unary_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_min_cpu_platform_unary(**mock_args) @@ -12086,6 +12186,7 @@ def test_set_name_rest_required_fields(request_type=compute.SetNameInstanceReque 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_name(request) @@ -12150,6 +12251,7 @@ def test_set_name_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_name(**mock_args) @@ -12301,6 +12403,7 @@ def test_set_name_unary_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_name_unary(request) @@ -12365,6 +12468,7 @@ def test_set_name_unary_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_name_unary(**mock_args) @@ -12516,6 +12620,7 @@ def test_set_scheduling_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_scheduling(request) @@ -12578,6 +12683,7 @@ def test_set_scheduling_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_scheduling(**mock_args) @@ -12727,6 +12833,7 @@ def test_set_scheduling_unary_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_scheduling_unary(request) @@ -12789,6 +12896,7 @@ def test_set_scheduling_unary_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_scheduling_unary(**mock_args) @@ -12942,6 +13050,7 @@ def test_set_security_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_security_policy(request) @@ -13006,6 +13115,7 @@ def test_set_security_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_security_policy(**mock_args) @@ -13161,6 +13271,7 @@ def test_set_security_policy_unary_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_security_policy_unary(request) @@ -13225,6 +13336,7 @@ def test_set_security_policy_unary_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_security_policy_unary(**mock_args) @@ -13380,6 +13492,7 @@ def test_set_service_account_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_service_account(request) @@ -13444,6 +13557,7 @@ def test_set_service_account_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_service_account(**mock_args) @@ -13599,6 +13713,7 @@ def test_set_service_account_unary_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_service_account_unary(request) @@ -13663,6 +13778,7 @@ def test_set_service_account_unary_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_service_account_unary(**mock_args) @@ -13823,6 +13939,7 @@ def test_set_shielded_instance_integrity_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_shielded_instance_integrity_policy(request) @@ -13889,6 +14006,7 @@ def test_set_shielded_instance_integrity_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_shielded_instance_integrity_policy(**mock_args) @@ -14051,6 +14169,7 @@ def test_set_shielded_instance_integrity_policy_unary_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_shielded_instance_integrity_policy_unary(request) @@ -14117,6 +14236,7 @@ def test_set_shielded_instance_integrity_policy_unary_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_shielded_instance_integrity_policy_unary(**mock_args) @@ -14268,6 +14388,7 @@ def test_set_tags_rest_required_fields(request_type=compute.SetTagsInstanceReque 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_tags(request) @@ -14330,6 +14451,7 @@ def test_set_tags_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_tags(**mock_args) @@ -14479,6 +14601,7 @@ def test_set_tags_unary_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_tags_unary(request) @@ -14541,6 +14664,7 @@ def test_set_tags_unary_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_tags_unary(**mock_args) @@ -14699,6 +14823,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(request) @@ -14764,6 +14889,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(**mock_args) @@ -14921,6 +15047,7 @@ def test_simulate_maintenance_event_unary_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.simulate_maintenance_event_unary(request) @@ -14986,6 +15113,7 @@ def test_simulate_maintenance_event_unary_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.simulate_maintenance_event_unary(**mock_args) @@ -15131,6 +15259,7 @@ def test_start_rest_required_fields(request_type=compute.StartInstanceRequest): 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.start(request) @@ -15191,6 +15320,7 @@ def test_start_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.start(**mock_args) @@ -15336,6 +15466,7 @@ def test_start_unary_rest_required_fields(request_type=compute.StartInstanceRequ 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.start_unary(request) @@ -15396,6 +15527,7 @@ def test_start_unary_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.start_unary(**mock_args) @@ -15549,6 +15681,7 @@ def test_start_with_encryption_key_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.start_with_encryption_key(request) @@ -15619,6 +15752,7 @@ def test_start_with_encryption_key_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.start_with_encryption_key(**mock_args) @@ -15781,6 +15915,7 @@ def test_start_with_encryption_key_unary_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.start_with_encryption_key_unary(request) @@ -15851,6 +15986,7 @@ def test_start_with_encryption_key_unary_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.start_with_encryption_key_unary(**mock_args) @@ -16010,6 +16146,7 @@ def test_stop_rest_required_fields(request_type=compute.StopInstanceRequest): 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.stop(request) @@ -16075,6 +16212,7 @@ def test_stop_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.stop(**mock_args) @@ -16225,6 +16363,7 @@ def test_stop_unary_rest_required_fields(request_type=compute.StopInstanceReques 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.stop_unary(request) @@ -16290,6 +16429,7 @@ def test_stop_unary_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.stop_unary(**mock_args) @@ -16440,6 +16580,7 @@ def test_suspend_rest_required_fields(request_type=compute.SuspendInstanceReques 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.suspend(request) @@ -16505,6 +16646,7 @@ def test_suspend_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.suspend(**mock_args) @@ -16657,6 +16799,7 @@ def test_suspend_unary_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.suspend_unary(request) @@ -16722,6 +16865,7 @@ def test_suspend_unary_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.suspend_unary(**mock_args) @@ -16868,6 +17012,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) @@ -16932,6 +17077,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) @@ -17087,6 +17233,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateInstanceRequest) 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(request) @@ -17159,6 +17306,7 @@ def test_update_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(**mock_args) @@ -17316,6 +17464,7 @@ def test_update_unary_rest_required_fields(request_type=compute.UpdateInstanceRe 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_unary(request) @@ -17388,6 +17537,7 @@ def test_update_unary_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_unary(**mock_args) @@ -17557,6 +17707,7 @@ def test_update_access_config_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.update_access_config(request) @@ -17633,6 +17784,7 @@ def test_update_access_config_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_access_config(**mock_args) @@ -17801,6 +17953,7 @@ def test_update_access_config_unary_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.update_access_config_unary(request) @@ -17877,6 +18030,7 @@ def test_update_access_config_unary_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_access_config_unary(**mock_args) @@ -18034,6 +18188,7 @@ def test_update_display_device_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.update_display_device(request) @@ -18096,6 +18251,7 @@ def test_update_display_device_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_display_device(**mock_args) @@ -18250,6 +18406,7 @@ def test_update_display_device_unary_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.update_display_device_unary(request) @@ -18312,6 +18469,7 @@ def test_update_display_device_unary_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_display_device_unary(**mock_args) @@ -18478,6 +18636,7 @@ def test_update_network_interface_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.update_network_interface(request) @@ -18556,6 +18715,7 @@ def test_update_network_interface_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_network_interface(**mock_args) @@ -18727,6 +18887,7 @@ def test_update_network_interface_unary_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.update_network_interface_unary(request) @@ -18805,6 +18966,7 @@ def test_update_network_interface_unary_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_network_interface_unary(**mock_args) @@ -18964,6 +19126,7 @@ def test_update_shielded_instance_config_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.update_shielded_instance_config(request) @@ -19030,6 +19193,7 @@ def test_update_shielded_instance_config_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_shielded_instance_config(**mock_args) @@ -19186,6 +19350,7 @@ def test_update_shielded_instance_config_unary_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.update_shielded_instance_config_unary(request) @@ -19252,6 +19417,7 @@ def test_update_shielded_instance_config_unary_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_shielded_instance_config_unary(**mock_args) @@ -19391,6 +19557,7 @@ def test_add_access_config_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.add_access_config(request) @@ -19530,6 +19697,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.add_access_config(request) # Establish that the response is the type that we expect. @@ -19589,6 +19757,7 @@ def test_add_access_config_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -19633,6 +19802,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -19774,6 +19944,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.add_resource_policies(request) # Establish that the response is the type that we expect. @@ -19833,6 +20004,7 @@ def test_add_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -19877,6 +20049,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -19916,6 +20089,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -19958,6 +20132,7 @@ def test_aggregated_list_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 = compute.InstanceAggregatedList.to_json( compute.InstanceAggregatedList() ) @@ -20002,6 +20177,7 @@ def test_attach_disk_rest_bad_request(request_type=compute.AttachDiskInstanceReq 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.attach_disk(request) @@ -20181,6 +20357,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.attach_disk(request) # Establish that the response is the type that we expect. @@ -20240,6 +20417,7 @@ def test_attach_disk_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -20282,6 +20460,7 @@ def test_bulk_insert_rest_bad_request(request_type=compute.BulkInsertInstanceReq 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.bulk_insert(request) @@ -20601,6 +20780,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.bulk_insert(request) # Establish that the response is the type that we expect. @@ -20660,6 +20840,7 @@ def test_bulk_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -20702,6 +20883,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteInstanceRequest): 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(request) @@ -20758,6 +20940,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -20815,6 +20998,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -20859,6 +21043,7 @@ def test_delete_access_config_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.delete_access_config(request) @@ -20915,6 +21100,7 @@ def test_delete_access_config_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.delete_access_config(request) # Establish that the response is the type that we expect. @@ -20974,6 +21160,7 @@ def test_delete_access_config_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -21016,6 +21203,7 @@ def test_detach_disk_rest_bad_request(request_type=compute.DetachDiskInstanceReq 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.detach_disk(request) @@ -21072,6 +21260,7 @@ def test_detach_disk_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.detach_disk(request) # Establish that the response is the type that we expect. @@ -21131,6 +21320,7 @@ def test_detach_disk_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -21173,6 +21363,7 @@ def test_get_rest_bad_request(request_type=compute.GetInstanceRequest): 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(request) @@ -21234,6 +21425,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -21296,6 +21488,7 @@ def test_get_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 = compute.Instance.to_json(compute.Instance()) req.return_value.content = return_value @@ -21340,6 +21533,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -21373,6 +21567,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) # Establish that the response is the type that we expect. @@ -21410,6 +21605,7 @@ def test_get_effective_firewalls_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 = compute.InstancesGetEffectiveFirewallsResponse.to_json( compute.InstancesGetEffectiveFirewallsResponse() ) @@ -21456,6 +21652,7 @@ def test_get_guest_attributes_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_guest_attributes(request) @@ -21495,6 +21692,7 @@ def test_get_guest_attributes_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_guest_attributes(request) # Establish that the response is the type that we expect. @@ -21537,6 +21735,7 @@ def test_get_guest_attributes_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 = compute.GuestAttributes.to_json(compute.GuestAttributes()) req.return_value.content = return_value @@ -21581,6 +21780,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) @@ -21618,6 +21818,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. @@ -21658,6 +21859,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -21702,6 +21904,7 @@ def test_get_screenshot_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_screenshot(request) @@ -21738,6 +21941,7 @@ def test_get_screenshot_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_screenshot(request) # Establish that the response is the type that we expect. @@ -21777,6 +21981,7 @@ def test_get_screenshot_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 = compute.Screenshot.to_json(compute.Screenshot()) req.return_value.content = return_value @@ -21821,6 +22026,7 @@ def test_get_serial_port_output_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_serial_port_output(request) @@ -21860,6 +22066,7 @@ def test_get_serial_port_output_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_serial_port_output(request) # Establish that the response is the type that we expect. @@ -21902,6 +22109,7 @@ def test_get_serial_port_output_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 = compute.SerialPortOutput.to_json(compute.SerialPortOutput()) req.return_value.content = return_value @@ -21946,6 +22154,7 @@ def test_get_shielded_instance_identity_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_shielded_instance_identity(request) @@ -21981,6 +22190,7 @@ def test_get_shielded_instance_identity_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_shielded_instance_identity(request) # Establish that the response is the type that we expect. @@ -22019,6 +22229,7 @@ def test_get_shielded_instance_identity_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 = compute.ShieldedInstanceIdentity.to_json( compute.ShieldedInstanceIdentity() ) @@ -22063,6 +22274,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertInstanceRequest): 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.insert(request) @@ -22390,6 +22602,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.insert(request) # Establish that the response is the type that we expect. @@ -22447,6 +22660,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -22489,6 +22703,7 @@ def test_list_rest_bad_request(request_type=compute.ListInstancesRequest): 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(request) @@ -22527,6 +22742,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -22566,6 +22782,7 @@ def test_list_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 = compute.InstanceList.to_json(compute.InstanceList()) req.return_value.content = return_value @@ -22610,6 +22827,7 @@ def test_list_referrers_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.list_referrers(request) @@ -22648,6 +22866,7 @@ def test_list_referrers_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_referrers(request) # Establish that the response is the type that we expect. @@ -22689,6 +22908,7 @@ def test_list_referrers_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 = compute.InstanceListReferrers.to_json( compute.InstanceListReferrers() ) @@ -22735,6 +22955,7 @@ def test_perform_maintenance_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.perform_maintenance(request) @@ -22791,6 +23012,7 @@ def test_perform_maintenance_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.perform_maintenance(request) # Establish that the response is the type that we expect. @@ -22850,6 +23072,7 @@ def test_perform_maintenance_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -22894,6 +23117,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -23035,6 +23259,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.remove_resource_policies(request) # Establish that the response is the type that we expect. @@ -23094,6 +23319,7 @@ def test_remove_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -23136,6 +23362,7 @@ def test_reset_rest_bad_request(request_type=compute.ResetInstanceRequest): 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.reset(request) @@ -23192,6 +23419,7 @@ def test_reset_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.reset(request) # Establish that the response is the type that we expect. @@ -23249,6 +23477,7 @@ def test_reset_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -23291,6 +23520,7 @@ def test_resume_rest_bad_request(request_type=compute.ResumeInstanceRequest): 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(request) @@ -23347,6 +23577,7 @@ def test_resume_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(request) # Establish that the response is the type that we expect. @@ -23404,6 +23635,7 @@ def test_resume_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -23448,6 +23680,7 @@ def test_send_diagnostic_interrupt_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.send_diagnostic_interrupt(request) @@ -23481,6 +23714,7 @@ def test_send_diagnostic_interrupt_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.send_diagnostic_interrupt(request) # Establish that the response is the type that we expect. @@ -23518,6 +23752,7 @@ def test_send_diagnostic_interrupt_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 = compute.SendDiagnosticInterruptInstanceResponse.to_json( compute.SendDiagnosticInterruptInstanceResponse() ) @@ -23564,6 +23799,7 @@ def test_set_deletion_protection_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_deletion_protection(request) @@ -23620,6 +23856,7 @@ def test_set_deletion_protection_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_deletion_protection(request) # Establish that the response is the type that we expect. @@ -23679,6 +23916,7 @@ def test_set_deletion_protection_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -23723,6 +23961,7 @@ def test_set_disk_auto_delete_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_disk_auto_delete(request) @@ -23779,6 +24018,7 @@ def test_set_disk_auto_delete_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_disk_auto_delete(request) # Establish that the response is the type that we expect. @@ -23838,6 +24078,7 @@ def test_set_disk_auto_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -23882,6 +24123,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) @@ -24035,6 +24277,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -24075,6 +24318,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -24117,6 +24361,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsInstanceReque 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_labels(request) @@ -24254,6 +24499,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.set_labels(request) # Establish that the response is the type that we expect. @@ -24313,6 +24559,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -24357,6 +24604,7 @@ def test_set_machine_resources_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_machine_resources(request) @@ -24500,6 +24748,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.set_machine_resources(request) # Establish that the response is the type that we expect. @@ -24559,6 +24808,7 @@ def test_set_machine_resources_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -24603,6 +24853,7 @@ def test_set_machine_type_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_machine_type(request) @@ -24744,6 +24995,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.set_machine_type(request) # Establish that the response is the type that we expect. @@ -24803,6 +25055,7 @@ def test_set_machine_type_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -24845,6 +25098,7 @@ def test_set_metadata_rest_bad_request(request_type=compute.SetMetadataInstanceR 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_metadata(request) @@ -24973,6 +25227,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.set_metadata(request) # Establish that the response is the type that we expect. @@ -25032,6 +25287,7 @@ def test_set_metadata_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -25076,6 +25332,7 @@ def test_set_min_cpu_platform_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_min_cpu_platform(request) @@ -25217,6 +25474,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.set_min_cpu_platform(request) # Establish that the response is the type that we expect. @@ -25276,6 +25534,7 @@ def test_set_min_cpu_platform_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -25318,6 +25577,7 @@ def test_set_name_rest_bad_request(request_type=compute.SetNameInstanceRequest): 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_name(request) @@ -25453,6 +25713,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.set_name(request) # Establish that the response is the type that we expect. @@ -25510,6 +25771,7 @@ def test_set_name_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -25554,6 +25816,7 @@ def test_set_scheduling_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_scheduling(request) @@ -25698,6 +25961,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.set_scheduling(request) # Establish that the response is the type that we expect. @@ -25757,6 +26021,7 @@ def test_set_scheduling_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -25801,6 +26066,7 @@ def test_set_security_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_security_policy(request) @@ -25946,6 +26212,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.set_security_policy(request) # Establish that the response is the type that we expect. @@ -26005,6 +26272,7 @@ def test_set_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -26049,6 +26317,7 @@ def test_set_service_account_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_service_account(request) @@ -26191,6 +26460,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.set_service_account(request) # Establish that the response is the type that we expect. @@ -26250,6 +26520,7 @@ def test_set_service_account_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -26294,6 +26565,7 @@ def test_set_shielded_instance_integrity_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_shielded_instance_integrity_policy(request) @@ -26435,6 +26707,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.set_shielded_instance_integrity_policy(request) # Establish that the response is the type that we expect. @@ -26496,6 +26769,7 @@ def test_set_shielded_instance_integrity_policy_rest_interceptors(null_intercept 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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -26538,6 +26812,7 @@ def test_set_tags_rest_bad_request(request_type=compute.SetTagsInstanceRequest): 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_tags(request) @@ -26665,6 +26940,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.set_tags(request) # Establish that the response is the type that we expect. @@ -26722,6 +26998,7 @@ def test_set_tags_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -26766,6 +27043,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(request) @@ -26822,6 +27100,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(request) # Establish that the response is the type that we expect. @@ -26881,6 +27160,7 @@ def test_simulate_maintenance_event_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -26923,6 +27203,7 @@ def test_start_rest_bad_request(request_type=compute.StartInstanceRequest): 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.start(request) @@ -26979,6 +27260,7 @@ def test_start_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.start(request) # Establish that the response is the type that we expect. @@ -27036,6 +27318,7 @@ def test_start_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -27080,6 +27363,7 @@ def test_start_with_encryption_key_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.start_with_encryption_key(request) @@ -27232,6 +27516,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.start_with_encryption_key(request) # Establish that the response is the type that we expect. @@ -27291,6 +27576,7 @@ def test_start_with_encryption_key_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -27333,6 +27619,7 @@ def test_stop_rest_bad_request(request_type=compute.StopInstanceRequest): 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.stop(request) @@ -27389,6 +27676,7 @@ def test_stop_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.stop(request) # Establish that the response is the type that we expect. @@ -27446,6 +27734,7 @@ def test_stop_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -27488,6 +27777,7 @@ def test_suspend_rest_bad_request(request_type=compute.SuspendInstanceRequest): 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.suspend(request) @@ -27544,6 +27834,7 @@ def test_suspend_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.suspend(request) # Establish that the response is the type that we expect. @@ -27601,6 +27892,7 @@ def test_suspend_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -27645,6 +27937,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) @@ -27758,6 +28051,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -27796,6 +28090,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -27840,6 +28135,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateInstanceRequest): 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(request) @@ -28167,6 +28463,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(request) # Establish that the response is the type that we expect. @@ -28224,6 +28521,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -28268,6 +28566,7 @@ def test_update_access_config_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.update_access_config(request) @@ -28407,6 +28706,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_access_config(request) # Establish that the response is the type that we expect. @@ -28466,6 +28766,7 @@ def test_update_access_config_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -28510,6 +28811,7 @@ def test_update_display_device_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.update_display_device(request) @@ -28638,6 +28940,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_display_device(request) # Establish that the response is the type that we expect. @@ -28697,6 +29000,7 @@ def test_update_display_device_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -28741,6 +29045,7 @@ def test_update_network_interface_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.update_network_interface(request) @@ -28906,6 +29211,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_network_interface(request) # Establish that the response is the type that we expect. @@ -28965,6 +29271,7 @@ def test_update_network_interface_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -29009,6 +29316,7 @@ def test_update_shielded_instance_config_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.update_shielded_instance_config(request) @@ -29145,6 +29453,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_shielded_instance_config(request) # Establish that the response is the type that we expect. @@ -29204,6 +29513,7 @@ def test_update_shielded_instance_config_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instant_snapshots.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instant_snapshots.py index 039e53bc7aed..67d5ca93669d 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instant_snapshots.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_instant_snapshots.py @@ -1036,6 +1036,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1094,6 +1095,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1312,6 +1314,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteInstantSnapshotR 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(request) @@ -1372,6 +1375,7 @@ def test_delete_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.delete(**mock_args) @@ -1519,6 +1523,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1579,6 +1584,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1718,6 +1724,7 @@ def test_get_rest_required_fields(request_type=compute.GetInstantSnapshotRequest 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(request) @@ -1778,6 +1785,7 @@ def test_get_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(**mock_args) @@ -1921,6 +1929,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) @@ -1981,6 +1990,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) @@ -2123,6 +2133,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertInstantSnapshotR 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.insert(request) @@ -2181,6 +2192,7 @@ def test_insert_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.insert(**mock_args) @@ -2327,6 +2339,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2385,6 +2398,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2532,6 +2546,7 @@ def test_list_rest_required_fields(request_type=compute.ListInstantSnapshotsRequ 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(request) @@ -2594,6 +2609,7 @@ def test_list_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(**mock_args) @@ -2796,6 +2812,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) @@ -2860,6 +2877,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) @@ -3011,6 +3029,7 @@ def test_set_labels_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_labels(request) @@ -3075,6 +3094,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3226,6 +3246,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3290,6 +3311,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3439,6 +3461,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) @@ -3503,6 +3526,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) @@ -3640,6 +3664,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3679,6 +3704,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3723,6 +3749,7 @@ def test_aggregated_list_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 = compute.InstantSnapshotAggregatedList.to_json( compute.InstantSnapshotAggregatedList() ) @@ -3771,6 +3798,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteInstantSnapshotReque 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(request) @@ -3831,6 +3859,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3892,6 +3921,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3938,6 +3968,7 @@ def test_get_rest_bad_request(request_type=compute.GetInstantSnapshotRequest): 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(request) @@ -3993,6 +4024,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4049,6 +4081,7 @@ def test_get_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 = compute.InstantSnapshot.to_json(compute.InstantSnapshot()) req.return_value.content = return_value @@ -4093,6 +4126,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) @@ -4130,6 +4164,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. @@ -4172,6 +4207,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4214,6 +4250,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertInstantSnapshotReque 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.insert(request) @@ -4364,6 +4401,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.insert(request) # Establish that the response is the type that we expect. @@ -4425,6 +4463,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4467,6 +4506,7 @@ def test_list_rest_bad_request(request_type=compute.ListInstantSnapshotsRequest) 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(request) @@ -4505,6 +4545,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4548,6 +4589,7 @@ def test_list_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 = compute.InstantSnapshotList.to_json( compute.InstantSnapshotList() ) @@ -4594,6 +4636,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) @@ -4747,6 +4790,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4789,6 +4833,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4833,6 +4878,7 @@ def test_set_labels_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_labels(request) @@ -4968,6 +5014,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.set_labels(request) # Establish that the response is the type that we expect. @@ -5029,6 +5076,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5073,6 +5121,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) @@ -5186,6 +5235,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5226,6 +5276,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_attachments.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_attachments.py index 0fea67a09c43..3ea3f85fad5c 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_attachments.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_attachments.py @@ -1062,6 +1062,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1120,6 +1121,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1342,6 +1344,7 @@ def test_delete_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.delete(request) @@ -1402,6 +1405,7 @@ def test_delete_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.delete(**mock_args) @@ -1551,6 +1555,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1611,6 +1616,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1754,6 +1760,7 @@ def test_get_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(request) @@ -1814,6 +1821,7 @@ def test_get_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(**mock_args) @@ -1963,6 +1971,7 @@ def test_insert_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.insert(request) @@ -2026,6 +2035,7 @@ def test_insert_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.insert(**mock_args) @@ -2177,6 +2187,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2240,6 +2251,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2389,6 +2401,7 @@ def test_list_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.list(request) @@ -2451,6 +2464,7 @@ def test_list_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(**mock_args) @@ -2663,6 +2677,7 @@ def test_patch_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.patch(request) @@ -2727,6 +2742,7 @@ def test_patch_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.patch(**mock_args) @@ -2880,6 +2896,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2944,6 +2961,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3095,6 +3113,7 @@ def test_set_labels_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_labels(request) @@ -3159,6 +3178,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3310,6 +3330,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3374,6 +3395,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3511,6 +3533,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3550,6 +3573,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3594,6 +3618,7 @@ def test_aggregated_list_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 = compute.InterconnectAttachmentAggregatedList.to_json( compute.InterconnectAttachmentAggregatedList() ) @@ -3644,6 +3669,7 @@ def test_delete_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.delete(request) @@ -3704,6 +3730,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3765,6 +3792,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3811,6 +3839,7 @@ def test_get_rest_bad_request(request_type=compute.GetInterconnectAttachmentRequ 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(request) @@ -3885,6 +3914,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3966,6 +3996,7 @@ def test_get_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 = compute.InterconnectAttachment.to_json( compute.InterconnectAttachment() ) @@ -4012,6 +4043,7 @@ def test_insert_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.insert(request) @@ -4198,6 +4230,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.insert(request) # Establish that the response is the type that we expect. @@ -4259,6 +4292,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4301,6 +4335,7 @@ def test_list_rest_bad_request(request_type=compute.ListInterconnectAttachmentsR 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(request) @@ -4339,6 +4374,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4382,6 +4418,7 @@ def test_list_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 = compute.InterconnectAttachmentList.to_json( compute.InterconnectAttachmentList() ) @@ -4432,6 +4469,7 @@ def test_patch_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.patch(request) @@ -4622,6 +4660,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.patch(request) # Establish that the response is the type that we expect. @@ -4683,6 +4722,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4727,6 +4767,7 @@ def test_set_labels_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_labels(request) @@ -4862,6 +4903,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4923,6 +4965,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_locations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_locations.py index e3d47b09cf5c..4bf17a1cc2d0 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_locations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_locations.py @@ -1043,6 +1043,7 @@ def test_get_rest_required_fields(request_type=compute.GetInterconnectLocationRe 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(request) @@ -1097,6 +1098,7 @@ def test_get_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(**mock_args) @@ -1239,6 +1241,7 @@ def test_list_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.list(request) @@ -1295,6 +1298,7 @@ def test_list_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(**mock_args) @@ -1486,6 +1490,7 @@ def test_get_rest_bad_request(request_type=compute.GetInterconnectLocationReques 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(request) @@ -1537,6 +1542,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1595,6 +1601,7 @@ def test_get_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 = compute.InterconnectLocation.to_json( compute.InterconnectLocation() ) @@ -1639,6 +1646,7 @@ def test_list_rest_bad_request(request_type=compute.ListInterconnectLocationsReq 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(request) @@ -1677,6 +1685,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1720,6 +1729,7 @@ def test_list_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 = compute.InterconnectLocationList.to_json( compute.InterconnectLocationList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_remote_locations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_remote_locations.py index cd8e2d9c5c72..02065dfc9b7c 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_remote_locations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnect_remote_locations.py @@ -1066,6 +1066,7 @@ def test_get_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(request) @@ -1123,6 +1124,7 @@ def test_get_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(**mock_args) @@ -1265,6 +1267,7 @@ def test_list_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.list(request) @@ -1321,6 +1324,7 @@ def test_list_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(**mock_args) @@ -1516,6 +1520,7 @@ def test_get_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(request) @@ -1567,6 +1572,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1625,6 +1631,7 @@ def test_get_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 = compute.InterconnectRemoteLocation.to_json( compute.InterconnectRemoteLocation() ) @@ -1671,6 +1678,7 @@ def test_list_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.list(request) @@ -1709,6 +1717,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1752,6 +1761,7 @@ def test_list_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 = compute.InterconnectRemoteLocationList.to_json( compute.InterconnectRemoteLocationList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnects.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnects.py index 51359bb6cb71..c69a038c4195 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnects.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_interconnects.py @@ -1008,6 +1008,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteInterconnectRequ 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(request) @@ -1062,6 +1063,7 @@ def test_delete_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.delete(**mock_args) @@ -1204,6 +1206,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1258,6 +1261,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1392,6 +1396,7 @@ def test_get_rest_required_fields(request_type=compute.GetInterconnectRequest): 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(request) @@ -1446,6 +1451,7 @@ def test_get_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(**mock_args) @@ -1582,6 +1588,7 @@ def test_get_diagnostics_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_diagnostics(request) @@ -1636,6 +1643,7 @@ def test_get_diagnostics_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_diagnostics(**mock_args) @@ -1774,6 +1782,7 @@ def test_get_macsec_config_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_macsec_config(request) @@ -1828,6 +1837,7 @@ def test_get_macsec_config_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_macsec_config(**mock_args) @@ -1965,6 +1975,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertInterconnectRequ 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.insert(request) @@ -2019,6 +2030,7 @@ def test_insert_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.insert(**mock_args) @@ -2158,6 +2170,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2212,6 +2225,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2352,6 +2366,7 @@ def test_list_rest_required_fields(request_type=compute.ListInterconnectsRequest 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(request) @@ -2408,6 +2423,7 @@ def test_list_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(**mock_args) @@ -2609,6 +2625,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchInterconnectReques 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.patch(request) @@ -2665,6 +2682,7 @@ def test_patch_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.patch(**mock_args) @@ -2809,6 +2827,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2865,6 +2884,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3007,6 +3027,7 @@ def test_set_labels_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_labels(request) @@ -3065,6 +3086,7 @@ def test_set_labels_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_labels(**mock_args) @@ -3209,6 +3231,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3267,6 +3290,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3401,6 +3425,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteInterconnectRequest) 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(request) @@ -3457,6 +3482,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3518,6 +3544,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3560,6 +3587,7 @@ def test_get_rest_bad_request(request_type=compute.GetInterconnectRequest): 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(request) @@ -3620,6 +3648,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3683,6 +3712,7 @@ def test_get_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 = compute.Interconnect.to_json(compute.Interconnect()) req.return_value.content = return_value @@ -3727,6 +3757,7 @@ def test_get_diagnostics_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_diagnostics(request) @@ -3760,6 +3791,7 @@ def test_get_diagnostics_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_diagnostics(request) # Establish that the response is the type that we expect. @@ -3799,6 +3831,7 @@ def test_get_diagnostics_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 = compute.InterconnectsGetDiagnosticsResponse.to_json( compute.InterconnectsGetDiagnosticsResponse() ) @@ -3845,6 +3878,7 @@ def test_get_macsec_config_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_macsec_config(request) @@ -3880,6 +3914,7 @@ def test_get_macsec_config_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_macsec_config(request) # Establish that the response is the type that we expect. @@ -3920,6 +3955,7 @@ def test_get_macsec_config_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 = compute.InterconnectsGetMacsecConfigResponse.to_json( compute.InterconnectsGetMacsecConfigResponse() ) @@ -3964,6 +4000,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertInterconnectRequest) 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.insert(request) @@ -4155,6 +4192,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.insert(request) # Establish that the response is the type that we expect. @@ -4216,6 +4254,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4258,6 +4297,7 @@ def test_list_rest_bad_request(request_type=compute.ListInterconnectsRequest): 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(request) @@ -4296,6 +4336,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4339,6 +4380,7 @@ def test_list_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 = compute.InterconnectList.to_json(compute.InterconnectList()) req.return_value.content = return_value @@ -4381,6 +4423,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchInterconnectRequest): 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.patch(request) @@ -4572,6 +4615,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.patch(request) # Establish that the response is the type that we expect. @@ -4633,6 +4677,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4675,6 +4720,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsInterconnectR 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_labels(request) @@ -4810,6 +4856,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4871,6 +4918,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_license_codes.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_license_codes.py index 334143e0fd3a..e452c3388bf3 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_license_codes.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_license_codes.py @@ -981,6 +981,7 @@ def test_get_rest_required_fields(request_type=compute.GetLicenseCodeRequest): 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(request) @@ -1035,6 +1036,7 @@ def test_get_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(**mock_args) @@ -1176,6 +1178,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) @@ -1234,6 +1237,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) @@ -1368,6 +1372,7 @@ def test_get_rest_bad_request(request_type=compute.GetLicenseCodeRequest): 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(request) @@ -1410,6 +1415,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1455,6 +1461,7 @@ def test_get_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 = compute.LicenseCode.to_json(compute.LicenseCode()) req.return_value.content = return_value @@ -1499,6 +1506,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) @@ -1612,6 +1620,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -1652,6 +1661,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_licenses.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_licenses.py index c4cdcdb95e12..389b933d59cf 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_licenses.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_licenses.py @@ -984,6 +984,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteLicenseRequest): 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(request) @@ -1048,6 +1049,7 @@ def test_delete_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.delete(**mock_args) @@ -1196,6 +1198,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteLicenseReq 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_unary(request) @@ -1260,6 +1263,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1399,6 +1403,7 @@ def test_get_rest_required_fields(request_type=compute.GetLicenseRequest): 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(request) @@ -1458,6 +1463,7 @@ def test_get_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(**mock_args) @@ -1596,6 +1602,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) @@ -1650,6 +1657,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) @@ -1787,6 +1795,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertLicenseRequest): 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.insert(request) @@ -1841,6 +1850,7 @@ def test_insert_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.insert(**mock_args) @@ -1977,6 +1987,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertLicenseReq 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.insert_unary(request) @@ -2031,6 +2042,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2170,6 +2182,7 @@ def test_list_rest_required_fields(request_type=compute.ListLicensesRequest): 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(request) @@ -2226,6 +2239,7 @@ def test_list_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(**mock_args) @@ -2422,6 +2436,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) @@ -2480,6 +2495,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) @@ -2624,6 +2640,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) @@ -2682,6 +2699,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) @@ -2816,6 +2834,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteLicenseRequest): 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(request) @@ -2872,6 +2891,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2929,6 +2949,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2971,6 +2992,7 @@ def test_get_rest_bad_request(request_type=compute.GetLicenseRequest): 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(request) @@ -3014,6 +3036,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3058,6 +3081,7 @@ def test_get_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 = compute.License.to_json(compute.License()) req.return_value.content = return_value @@ -3102,6 +3126,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) @@ -3139,6 +3164,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. @@ -3179,6 +3205,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3221,6 +3248,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertLicenseRequest): 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.insert(request) @@ -3356,6 +3384,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.insert(request) # Establish that the response is the type that we expect. @@ -3413,6 +3442,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3455,6 +3485,7 @@ def test_list_rest_bad_request(request_type=compute.ListLicensesRequest): 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(request) @@ -3492,6 +3523,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3530,6 +3562,7 @@ def test_list_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 = compute.LicensesListResponse.to_json( compute.LicensesListResponse() ) @@ -3576,6 +3609,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) @@ -3729,6 +3763,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -3769,6 +3804,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3813,6 +3849,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) @@ -3926,6 +3963,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -3964,6 +4002,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_images.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_images.py index 57836c3a368a..7f6207057db0 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_images.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_images.py @@ -1008,6 +1008,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteMachineImageRequ 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(request) @@ -1062,6 +1063,7 @@ def test_delete_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.delete(**mock_args) @@ -1204,6 +1206,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1258,6 +1261,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1392,6 +1396,7 @@ def test_get_rest_required_fields(request_type=compute.GetMachineImageRequest): 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(request) @@ -1446,6 +1451,7 @@ def test_get_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(**mock_args) @@ -1584,6 +1590,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) @@ -1638,6 +1645,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) @@ -1780,6 +1788,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertMachineImageRequ 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.insert(request) @@ -1841,6 +1850,7 @@ def test_insert_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.insert(**mock_args) @@ -1987,6 +1997,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2048,6 +2059,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2190,6 +2202,7 @@ def test_list_rest_required_fields(request_type=compute.ListMachineImagesRequest 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(request) @@ -2246,6 +2259,7 @@ def test_list_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(**mock_args) @@ -2443,6 +2457,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) @@ -2501,6 +2516,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) @@ -2645,6 +2661,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) @@ -2703,6 +2720,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) @@ -2837,6 +2855,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteMachineImageRequest) 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(request) @@ -2893,6 +2912,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2954,6 +2974,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2996,6 +3017,7 @@ def test_get_rest_bad_request(request_type=compute.GetMachineImageRequest): 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(request) @@ -3043,6 +3065,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3093,6 +3116,7 @@ def test_get_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 = compute.MachineImage.to_json(compute.MachineImage()) req.return_value.content = return_value @@ -3137,6 +3161,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) @@ -3174,6 +3199,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. @@ -3216,6 +3242,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3258,6 +3285,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertMachineImageRequest) 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.insert(request) @@ -3623,6 +3651,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.insert(request) # Establish that the response is the type that we expect. @@ -3684,6 +3713,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3726,6 +3756,7 @@ def test_list_rest_bad_request(request_type=compute.ListMachineImagesRequest): 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(request) @@ -3764,6 +3795,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3807,6 +3839,7 @@ def test_list_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 = compute.MachineImageList.to_json(compute.MachineImageList()) req.return_value.content = return_value @@ -3851,6 +3884,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) @@ -4004,6 +4038,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4046,6 +4081,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4090,6 +4126,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) @@ -4203,6 +4240,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4243,6 +4281,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_types.py index 6983bb5ab44e..a2b42a4bf3c8 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_machine_types.py @@ -992,6 +992,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1050,6 +1051,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1260,6 +1262,7 @@ def test_get_rest_required_fields(request_type=compute.GetMachineTypeRequest): 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(request) @@ -1320,6 +1323,7 @@ def test_get_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(**mock_args) @@ -1465,6 +1469,7 @@ def test_list_rest_required_fields(request_type=compute.ListMachineTypesRequest) 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(request) @@ -1527,6 +1532,7 @@ def test_list_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(**mock_args) @@ -1721,6 +1727,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1760,6 +1767,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -1804,6 +1812,7 @@ def test_aggregated_list_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 = compute.MachineTypeAggregatedList.to_json( compute.MachineTypeAggregatedList() ) @@ -1848,6 +1857,7 @@ def test_get_rest_bad_request(request_type=compute.GetMachineTypeRequest): 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(request) @@ -1896,6 +1906,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1947,6 +1958,7 @@ def test_get_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 = compute.MachineType.to_json(compute.MachineType()) req.return_value.content = return_value @@ -1989,6 +2001,7 @@ def test_list_rest_bad_request(request_type=compute.ListMachineTypesRequest): 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(request) @@ -2027,6 +2040,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2070,6 +2084,7 @@ def test_list_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 = compute.MachineTypeList.to_json(compute.MachineTypeList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_attachments.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_attachments.py index bce42b021bd6..414ace4b7790 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_attachments.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_attachments.py @@ -1048,6 +1048,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1106,6 +1107,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1326,6 +1328,7 @@ def test_delete_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.delete(request) @@ -1386,6 +1389,7 @@ def test_delete_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.delete(**mock_args) @@ -1533,6 +1537,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1593,6 +1598,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1732,6 +1738,7 @@ def test_get_rest_required_fields(request_type=compute.GetNetworkAttachmentReque 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(request) @@ -1792,6 +1799,7 @@ def test_get_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(**mock_args) @@ -1935,6 +1943,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) @@ -1995,6 +2004,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) @@ -2139,6 +2149,7 @@ def test_insert_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.insert(request) @@ -2201,6 +2212,7 @@ def test_insert_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.insert(**mock_args) @@ -2351,6 +2363,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2413,6 +2426,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2564,6 +2578,7 @@ def test_list_rest_required_fields(request_type=compute.ListNetworkAttachmentsRe 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(request) @@ -2626,6 +2641,7 @@ def test_list_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(**mock_args) @@ -2832,6 +2848,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchNetworkAttachmentR 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.patch(request) @@ -2900,6 +2917,7 @@ def test_patch_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.patch(**mock_args) @@ -3055,6 +3073,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3123,6 +3142,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3272,6 +3292,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) @@ -3336,6 +3357,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) @@ -3485,6 +3507,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) @@ -3549,6 +3572,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) @@ -3686,6 +3710,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3724,6 +3749,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3767,6 +3793,7 @@ def test_aggregated_list_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 = compute.NetworkAttachmentAggregatedList.to_json( compute.NetworkAttachmentAggregatedList() ) @@ -3815,6 +3842,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteNetworkAttachmentReq 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(request) @@ -3875,6 +3903,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3936,6 +3965,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3982,6 +4012,7 @@ def test_get_rest_bad_request(request_type=compute.GetNetworkAttachmentRequest): 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(request) @@ -4034,6 +4065,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4087,6 +4119,7 @@ def test_get_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 = compute.NetworkAttachment.to_json(compute.NetworkAttachment()) req.return_value.content = return_value @@ -4131,6 +4164,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) @@ -4168,6 +4202,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. @@ -4210,6 +4245,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4252,6 +4288,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertNetworkAttachmentReq 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.insert(request) @@ -4417,6 +4454,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.insert(request) # Establish that the response is the type that we expect. @@ -4478,6 +4516,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4520,6 +4559,7 @@ def test_list_rest_bad_request(request_type=compute.ListNetworkAttachmentsReques 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(request) @@ -4558,6 +4598,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4601,6 +4642,7 @@ def test_list_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 = compute.NetworkAttachmentList.to_json( compute.NetworkAttachmentList() ) @@ -4649,6 +4691,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchNetworkAttachmentReque 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.patch(request) @@ -4818,6 +4861,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.patch(request) # Establish that the response is the type that we expect. @@ -4879,6 +4923,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4923,6 +4968,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) @@ -5076,6 +5122,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5118,6 +5165,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5162,6 +5210,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) @@ -5275,6 +5324,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5315,6 +5365,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_edge_security_services.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_edge_security_services.py index 2a65e7f6c25e..13ad68322b4b 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_edge_security_services.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_edge_security_services.py @@ -1078,6 +1078,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1136,6 +1137,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1362,6 +1364,7 @@ def test_delete_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.delete(request) @@ -1422,6 +1425,7 @@ def test_delete_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.delete(**mock_args) @@ -1574,6 +1578,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1634,6 +1639,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1780,6 +1786,7 @@ def test_get_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(request) @@ -1840,6 +1847,7 @@ def test_get_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(**mock_args) @@ -1989,6 +1997,7 @@ def test_insert_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.insert(request) @@ -2052,6 +2061,7 @@ def test_insert_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.insert(**mock_args) @@ -2203,6 +2213,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2266,6 +2277,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2427,6 +2439,7 @@ def test_patch_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.patch(request) @@ -2497,6 +2510,7 @@ def test_patch_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.patch(**mock_args) @@ -2659,6 +2673,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2729,6 +2744,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2866,6 +2882,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -2906,6 +2923,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -2951,6 +2969,7 @@ def test_aggregated_list_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 = compute.NetworkEdgeSecurityServiceAggregatedList.to_json( compute.NetworkEdgeSecurityServiceAggregatedList() ) @@ -3001,6 +3020,7 @@ def test_delete_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.delete(request) @@ -3061,6 +3081,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3122,6 +3143,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3170,6 +3192,7 @@ def test_get_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(request) @@ -3218,6 +3241,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3267,6 +3291,7 @@ def test_get_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 = compute.NetworkEdgeSecurityService.to_json( compute.NetworkEdgeSecurityService() ) @@ -3313,6 +3338,7 @@ def test_insert_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.insert(request) @@ -3459,6 +3485,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.insert(request) # Establish that the response is the type that we expect. @@ -3520,6 +3547,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3568,6 +3596,7 @@ def test_patch_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.patch(request) @@ -3718,6 +3747,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.patch(request) # Establish that the response is the type that we expect. @@ -3779,6 +3809,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_endpoint_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_endpoint_groups.py index 02700a8eeccc..ef914d3162e5 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_endpoint_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_endpoint_groups.py @@ -1060,6 +1060,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1118,6 +1119,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1344,6 +1346,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -1410,6 +1413,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(**mock_args) @@ -1568,6 +1572,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(request) @@ -1634,6 +1639,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(**mock_args) @@ -1786,6 +1792,7 @@ def test_delete_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.delete(request) @@ -1846,6 +1853,7 @@ def test_delete_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.delete(**mock_args) @@ -1993,6 +2001,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2053,6 +2062,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2206,6 +2216,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -2272,6 +2283,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(**mock_args) @@ -2430,6 +2442,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(request) @@ -2496,6 +2509,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(**mock_args) @@ -2640,6 +2654,7 @@ def test_get_rest_required_fields(request_type=compute.GetNetworkEndpointGroupRe 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(request) @@ -2700,6 +2715,7 @@ def test_get_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(**mock_args) @@ -2844,6 +2860,7 @@ def test_insert_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.insert(request) @@ -2902,6 +2919,7 @@ def test_insert_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.insert(**mock_args) @@ -3048,6 +3066,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3106,6 +3125,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3255,6 +3275,7 @@ def test_list_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.list(request) @@ -3317,6 +3338,7 @@ def test_list_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(**mock_args) @@ -3536,6 +3558,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -3610,6 +3633,7 @@ def test_list_network_endpoints_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_network_endpoints(**mock_args) @@ -3834,6 +3858,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) @@ -3898,6 +3923,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) @@ -4035,6 +4061,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -4074,6 +4101,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -4118,6 +4146,7 @@ def test_aggregated_list_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 = compute.NetworkEndpointGroupAggregatedList.to_json( compute.NetworkEndpointGroupAggregatedList() ) @@ -4168,6 +4197,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -4323,6 +4353,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.attach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4384,6 +4415,7 @@ def test_attach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4432,6 +4464,7 @@ def test_delete_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.delete(request) @@ -4492,6 +4525,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4553,6 +4587,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4601,6 +4636,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -4756,6 +4792,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.detach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4817,6 +4854,7 @@ def test_detach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4863,6 +4901,7 @@ def test_get_rest_bad_request(request_type=compute.GetNetworkEndpointGroupReques 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(request) @@ -4915,6 +4954,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4968,6 +5008,7 @@ def test_get_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 = compute.NetworkEndpointGroup.to_json( compute.NetworkEndpointGroup() ) @@ -5014,6 +5055,7 @@ def test_insert_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.insert(request) @@ -5179,6 +5221,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.insert(request) # Establish that the response is the type that we expect. @@ -5240,6 +5283,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5282,6 +5326,7 @@ def test_list_rest_bad_request(request_type=compute.ListNetworkEndpointGroupsReq 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(request) @@ -5320,6 +5365,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5363,6 +5409,7 @@ def test_list_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 = compute.NetworkEndpointGroupList.to_json( compute.NetworkEndpointGroupList() ) @@ -5413,6 +5460,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -5541,6 +5589,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.list_network_endpoints(request) # Establish that the response is the type that we expect. @@ -5583,6 +5632,7 @@ def test_list_network_endpoints_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 = compute.NetworkEndpointGroupsListNetworkEndpoints.to_json( compute.NetworkEndpointGroupsListNetworkEndpoints() ) @@ -5629,6 +5679,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) @@ -5742,6 +5793,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5782,6 +5834,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py index 7aa671940d38..6938b9add120 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py @@ -1066,6 +1066,7 @@ def test_add_association_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.add_association(request) @@ -1129,6 +1130,7 @@ def test_add_association_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.add_association(**mock_args) @@ -1280,6 +1282,7 @@ def test_add_association_unary_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.add_association_unary(request) @@ -1343,6 +1346,7 @@ def test_add_association_unary_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.add_association_unary(**mock_args) @@ -1495,6 +1499,7 @@ def test_add_rule_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.add_rule(request) @@ -1559,6 +1564,7 @@ def test_add_rule_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.add_rule(**mock_args) @@ -1711,6 +1717,7 @@ def test_add_rule_unary_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.add_rule_unary(request) @@ -1775,6 +1782,7 @@ def test_add_rule_unary_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.add_rule_unary(**mock_args) @@ -1925,6 +1933,7 @@ def test_clone_rules_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.clone_rules(request) @@ -1984,6 +1993,7 @@ def test_clone_rules_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.clone_rules(**mock_args) @@ -2131,6 +2141,7 @@ def test_clone_rules_unary_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.clone_rules_unary(request) @@ -2190,6 +2201,7 @@ def test_clone_rules_unary_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.clone_rules_unary(**mock_args) @@ -2332,6 +2344,7 @@ def test_delete_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.delete(request) @@ -2386,6 +2399,7 @@ def test_delete_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.delete(**mock_args) @@ -2528,6 +2542,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2582,6 +2597,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2716,6 +2732,7 @@ def test_get_rest_required_fields(request_type=compute.GetNetworkFirewallPolicyR 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(request) @@ -2770,6 +2787,7 @@ def test_get_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(**mock_args) @@ -2908,6 +2926,7 @@ def test_get_association_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_association(request) @@ -2962,6 +2981,7 @@ def test_get_association_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_association(**mock_args) @@ -3100,6 +3120,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) @@ -3154,6 +3175,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) @@ -3292,6 +3314,7 @@ def test_get_rule_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_rule(request) @@ -3346,6 +3369,7 @@ def test_get_rule_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_rule(**mock_args) @@ -3485,6 +3509,7 @@ def test_insert_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.insert(request) @@ -3545,6 +3570,7 @@ def test_insert_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.insert(**mock_args) @@ -3690,6 +3716,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3750,6 +3777,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3898,6 +3926,7 @@ def test_list_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.list(request) @@ -3954,6 +3983,7 @@ def test_list_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(**mock_args) @@ -4157,6 +4187,7 @@ def test_patch_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.patch(request) @@ -4219,6 +4250,7 @@ def test_patch_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.patch(**mock_args) @@ -4369,6 +4401,7 @@ def test_patch_unary_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.patch_unary(request) @@ -4431,6 +4464,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -4586,6 +4620,7 @@ def test_patch_rule_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.patch_rule(request) @@ -4649,6 +4684,7 @@ def test_patch_rule_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.patch_rule(**mock_args) @@ -4800,6 +4836,7 @@ def test_patch_rule_unary_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.patch_rule_unary(request) @@ -4863,6 +4900,7 @@ def test_patch_rule_unary_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.patch_rule_unary(**mock_args) @@ -5017,6 +5055,7 @@ def test_remove_association_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.remove_association(request) @@ -5076,6 +5115,7 @@ def test_remove_association_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.remove_association(**mock_args) @@ -5227,6 +5267,7 @@ def test_remove_association_unary_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.remove_association_unary(request) @@ -5286,6 +5327,7 @@ def test_remove_association_unary_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.remove_association_unary(**mock_args) @@ -5433,6 +5475,7 @@ def test_remove_rule_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.remove_rule(request) @@ -5492,6 +5535,7 @@ def test_remove_rule_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.remove_rule(**mock_args) @@ -5639,6 +5683,7 @@ def test_remove_rule_unary_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.remove_rule_unary(request) @@ -5698,6 +5743,7 @@ def test_remove_rule_unary_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.remove_rule_unary(**mock_args) @@ -5835,6 +5881,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) @@ -5893,6 +5940,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) @@ -6037,6 +6085,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) @@ -6095,6 +6144,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) @@ -6231,6 +6281,7 @@ def test_add_association_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.add_association(request) @@ -6371,6 +6422,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.add_association(request) # Establish that the response is the type that we expect. @@ -6432,6 +6484,7 @@ def test_add_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6476,6 +6529,7 @@ def test_add_rule_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.add_rule(request) @@ -6660,6 +6714,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.add_rule(request) # Establish that the response is the type that we expect. @@ -6721,6 +6776,7 @@ def test_add_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6765,6 +6821,7 @@ def test_clone_rules_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.clone_rules(request) @@ -6821,6 +6878,7 @@ def test_clone_rules_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.clone_rules(request) # Establish that the response is the type that we expect. @@ -6882,6 +6940,7 @@ def test_clone_rules_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6926,6 +6985,7 @@ def test_delete_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.delete(request) @@ -6982,6 +7042,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -7043,6 +7104,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7085,6 +7147,7 @@ def test_get_rest_bad_request(request_type=compute.GetNetworkFirewallPolicyReque 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(request) @@ -7132,6 +7195,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -7184,6 +7248,7 @@ def test_get_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 = compute.FirewallPolicy.to_json(compute.FirewallPolicy()) req.return_value.content = return_value @@ -7228,6 +7293,7 @@ def test_get_association_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_association(request) @@ -7267,6 +7333,7 @@ def test_get_association_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_association(request) # Establish that the response is the type that we expect. @@ -7311,6 +7378,7 @@ def test_get_association_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 = compute.FirewallPolicyAssociation.to_json( compute.FirewallPolicyAssociation() ) @@ -7357,6 +7425,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) @@ -7394,6 +7463,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. @@ -7436,6 +7506,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -7480,6 +7551,7 @@ def test_get_rule_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_rule(request) @@ -7527,6 +7599,7 @@ def test_get_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -7579,6 +7652,7 @@ def test_get_rule_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 = compute.FirewallPolicyRule.to_json(compute.FirewallPolicyRule()) req.return_value.content = return_value @@ -7623,6 +7697,7 @@ def test_insert_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.insert(request) @@ -7838,6 +7913,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.insert(request) # Establish that the response is the type that we expect. @@ -7899,6 +7975,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7941,6 +8018,7 @@ def test_list_rest_bad_request(request_type=compute.ListNetworkFirewallPoliciesR 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(request) @@ -7978,6 +8056,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -8020,6 +8099,7 @@ def test_list_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 = compute.FirewallPolicyList.to_json(compute.FirewallPolicyList()) req.return_value.content = return_value @@ -8062,6 +8142,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchNetworkFirewallPolicyR 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.patch(request) @@ -8277,6 +8358,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.patch(request) # Establish that the response is the type that we expect. @@ -8338,6 +8420,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8382,6 +8465,7 @@ def test_patch_rule_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.patch_rule(request) @@ -8566,6 +8650,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.patch_rule(request) # Establish that the response is the type that we expect. @@ -8627,6 +8712,7 @@ def test_patch_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8671,6 +8757,7 @@ def test_remove_association_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.remove_association(request) @@ -8727,6 +8814,7 @@ def test_remove_association_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.remove_association(request) # Establish that the response is the type that we expect. @@ -8788,6 +8876,7 @@ def test_remove_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8832,6 +8921,7 @@ def test_remove_rule_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.remove_rule(request) @@ -8888,6 +8978,7 @@ def test_remove_rule_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.remove_rule(request) # Establish that the response is the type that we expect. @@ -8949,6 +9040,7 @@ def test_remove_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8993,6 +9085,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) @@ -9146,6 +9239,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -9188,6 +9282,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -9232,6 +9327,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) @@ -9345,6 +9441,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -9385,6 +9482,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_profiles.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_profiles.py new file mode 100644 index 000000000000..cef89ee04c6f --- /dev/null +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_profiles.py @@ -0,0 +1,2111 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock + +from collections.abc import AsyncIterable, Iterable +import json +import math + +from google.api_core import api_core_version +from google.protobuf import json_format +import grpc +from grpc.experimental import aio +from proto.marshal.rules import wrappers +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest +from requests import PreparedRequest, Request, Response +from requests.sessions import Session + +try: + from google.auth.aio import credentials as ga_credentials_async + + HAS_GOOGLE_AUTH_AIO = True +except ImportError: # pragma: NO COVER + HAS_GOOGLE_AUTH_AIO = False + +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import retry as retries +import google.auth +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.oauth2 import service_account + +from google.cloud.compute_v1.services.network_profiles import ( + NetworkProfilesClient, + pagers, + transports, +) +from google.cloud.compute_v1.types import compute + + +async def mock_async_gen(data, chunk_size=1): + for i in range(0, len(data)): # pragma: NO COVER + chunk = data[i : i + chunk_size] + yield chunk.encode("utf-8") + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. +# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. +def async_anonymous_credentials(): + if HAS_GOOGLE_AUTH_AIO: + return ga_credentials_async.AnonymousCredentials() + return ga_credentials.AnonymousCredentials() + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) + + +# If default endpoint template is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint template so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint_template(client): + return ( + "test.{UNIVERSE_DOMAIN}" + if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) + else client._DEFAULT_ENDPOINT_TEMPLATE + ) + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert NetworkProfilesClient._get_default_mtls_endpoint(None) is None + assert ( + NetworkProfilesClient._get_default_mtls_endpoint(api_endpoint) + == api_mtls_endpoint + ) + assert ( + NetworkProfilesClient._get_default_mtls_endpoint(api_mtls_endpoint) + == api_mtls_endpoint + ) + assert ( + NetworkProfilesClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + NetworkProfilesClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + NetworkProfilesClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + ) + + +def test__read_environment_variables(): + assert NetworkProfilesClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + assert NetworkProfilesClient._read_environment_variables() == ( + True, + "auto", + None, + ) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + assert NetworkProfilesClient._read_environment_variables() == ( + False, + "auto", + None, + ) + + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): + with pytest.raises(ValueError) as excinfo: + NetworkProfilesClient._read_environment_variables() + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + assert NetworkProfilesClient._read_environment_variables() == ( + False, + "never", + None, + ) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + assert NetworkProfilesClient._read_environment_variables() == ( + False, + "always", + None, + ) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): + assert NetworkProfilesClient._read_environment_variables() == ( + False, + "auto", + None, + ) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + NetworkProfilesClient._read_environment_variables() + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): + assert NetworkProfilesClient._read_environment_variables() == ( + False, + "auto", + "foo.com", + ) + + +def test__get_client_cert_source(): + mock_provided_cert_source = mock.Mock() + mock_default_cert_source = mock.Mock() + + assert NetworkProfilesClient._get_client_cert_source(None, False) is None + assert ( + NetworkProfilesClient._get_client_cert_source(mock_provided_cert_source, False) + is None + ) + assert ( + NetworkProfilesClient._get_client_cert_source(mock_provided_cert_source, True) + == mock_provided_cert_source + ) + + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", return_value=True + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_default_cert_source, + ): + assert ( + NetworkProfilesClient._get_client_cert_source(None, True) + is mock_default_cert_source + ) + assert ( + NetworkProfilesClient._get_client_cert_source( + mock_provided_cert_source, "true" + ) + is mock_provided_cert_source + ) + + +@mock.patch.object( + NetworkProfilesClient, + "_DEFAULT_ENDPOINT_TEMPLATE", + modify_default_endpoint_template(NetworkProfilesClient), +) +def test__get_api_endpoint(): + api_override = "foo.com" + mock_client_cert_source = mock.Mock() + default_universe = NetworkProfilesClient._DEFAULT_UNIVERSE + default_endpoint = NetworkProfilesClient._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=default_universe + ) + mock_universe = "bar.com" + mock_endpoint = NetworkProfilesClient._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=mock_universe + ) + + assert ( + NetworkProfilesClient._get_api_endpoint( + api_override, mock_client_cert_source, default_universe, "always" + ) + == api_override + ) + assert ( + NetworkProfilesClient._get_api_endpoint( + None, mock_client_cert_source, default_universe, "auto" + ) + == NetworkProfilesClient.DEFAULT_MTLS_ENDPOINT + ) + assert ( + NetworkProfilesClient._get_api_endpoint(None, None, default_universe, "auto") + == default_endpoint + ) + assert ( + NetworkProfilesClient._get_api_endpoint(None, None, default_universe, "always") + == NetworkProfilesClient.DEFAULT_MTLS_ENDPOINT + ) + assert ( + NetworkProfilesClient._get_api_endpoint( + None, mock_client_cert_source, default_universe, "always" + ) + == NetworkProfilesClient.DEFAULT_MTLS_ENDPOINT + ) + assert ( + NetworkProfilesClient._get_api_endpoint(None, None, mock_universe, "never") + == mock_endpoint + ) + assert ( + NetworkProfilesClient._get_api_endpoint(None, None, default_universe, "never") + == default_endpoint + ) + + with pytest.raises(MutualTLSChannelError) as excinfo: + NetworkProfilesClient._get_api_endpoint( + None, mock_client_cert_source, mock_universe, "auto" + ) + assert ( + str(excinfo.value) + == "mTLS is not supported in any universe other than googleapis.com." + ) + + +def test__get_universe_domain(): + client_universe_domain = "foo.com" + universe_domain_env = "bar.com" + + assert ( + NetworkProfilesClient._get_universe_domain( + client_universe_domain, universe_domain_env + ) + == client_universe_domain + ) + assert ( + NetworkProfilesClient._get_universe_domain(None, universe_domain_env) + == universe_domain_env + ) + assert ( + NetworkProfilesClient._get_universe_domain(None, None) + == NetworkProfilesClient._DEFAULT_UNIVERSE + ) + + with pytest.raises(ValueError) as excinfo: + NetworkProfilesClient._get_universe_domain("", None) + assert str(excinfo.value) == "Universe Domain cannot be an empty string." + + +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (NetworkProfilesClient, "rest"), + ], +) +def test_network_profiles_client_from_service_account_info( + client_class, transport_name +): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info, transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + "compute.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://compute.googleapis.com" + ) + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.NetworkProfilesRestTransport, "rest"), + ], +) +def test_network_profiles_client_service_account_always_use_jwt( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (NetworkProfilesClient, "rest"), + ], +) +def test_network_profiles_client_from_service_account_file( + client_class, transport_name +): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_file" + ) as factory: + factory.return_value = creds + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + "compute.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://compute.googleapis.com" + ) + + +def test_network_profiles_client_get_transport_class(): + transport = NetworkProfilesClient.get_transport_class() + available_transports = [ + transports.NetworkProfilesRestTransport, + ] + assert transport in available_transports + + transport = NetworkProfilesClient.get_transport_class("rest") + assert transport == transports.NetworkProfilesRestTransport + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (NetworkProfilesClient, transports.NetworkProfilesRestTransport, "rest"), + ], +) +@mock.patch.object( + NetworkProfilesClient, + "_DEFAULT_ENDPOINT_TEMPLATE", + modify_default_endpoint_template(NetworkProfilesClient), +) +def test_network_profiles_client_client_options( + client_class, transport_class, transport_name +): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(NetworkProfilesClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(NetworkProfilesClient, "get_transport_class") as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + client = client_class(transport=transport_name) + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): + with pytest.raises(ValueError) as excinfo: + client = client_class(transport=transport_name) + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions( + api_audience="https://language.googleapis.com" + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com", + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + ( + NetworkProfilesClient, + transports.NetworkProfilesRestTransport, + "rest", + "true", + ), + ( + NetworkProfilesClient, + transports.NetworkProfilesRestTransport, + "rest", + "false", + ), + ], +) +@mock.patch.object( + NetworkProfilesClient, + "_DEFAULT_ENDPOINT_TEMPLATE", + modify_default_endpoint_template(NetworkProfilesClient), +) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_network_profiles_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ) + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): + if use_client_cert_env == "false": + expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ) + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [NetworkProfilesClient]) +@mock.patch.object( + NetworkProfilesClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(NetworkProfilesClient), +) +def test_network_profiles_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + client_class.get_mtls_endpoint_and_cert_source() + + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): + with pytest.raises(ValueError) as excinfo: + client_class.get_mtls_endpoint_and_cert_source() + + assert ( + str(excinfo.value) + == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + + +@pytest.mark.parametrize("client_class", [NetworkProfilesClient]) +@mock.patch.object( + NetworkProfilesClient, + "_DEFAULT_ENDPOINT_TEMPLATE", + modify_default_endpoint_template(NetworkProfilesClient), +) +def test_network_profiles_client_client_api_endpoint(client_class): + mock_client_cert_source = client_cert_source_callback + api_override = "foo.com" + default_universe = NetworkProfilesClient._DEFAULT_UNIVERSE + default_endpoint = NetworkProfilesClient._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=default_universe + ) + mock_universe = "bar.com" + mock_endpoint = NetworkProfilesClient._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=mock_universe + ) + + # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", + # use ClientOptions.api_endpoint as the api endpoint regardless. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" + ): + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=api_override + ) + client = client_class( + client_options=options, + credentials=ga_credentials.AnonymousCredentials(), + ) + assert client.api_endpoint == api_override + + # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + client = client_class(credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == default_endpoint + + # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", + # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + client = client_class(credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + + # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), + # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, + # and ClientOptions.universe_domain="bar.com", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. + options = client_options.ClientOptions() + universe_exists = hasattr(options, "universe_domain") + if universe_exists: + options = client_options.ClientOptions(universe_domain=mock_universe) + client = client_class( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + else: + client = client_class( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + assert client.api_endpoint == ( + mock_endpoint if universe_exists else default_endpoint + ) + assert client.universe_domain == ( + mock_universe if universe_exists else default_universe + ) + + # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. + options = client_options.ClientOptions() + if hasattr(options, "universe_domain"): + delattr(options, "universe_domain") + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + client = client_class( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + assert client.api_endpoint == default_endpoint + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (NetworkProfilesClient, transports.NetworkProfilesRestTransport, "rest"), + ], +) +def test_network_profiles_client_client_options_scopes( + client_class, transport_class, transport_name +): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (NetworkProfilesClient, transports.NetworkProfilesRestTransport, "rest", None), + ], +) +def test_network_profiles_client_client_options_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +def test_get_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get] = mock_rpc + + request = {} + client.get(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_rest_required_fields(request_type=compute.GetNetworkProfileRequest): + transport_class = transports.NetworkProfilesRestTransport + + request_init = {} + request_init["network_profile"] = "" + request_init["project"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["networkProfile"] = "network_profile_value" + jsonified_request["project"] = "project_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "networkProfile" in jsonified_request + assert jsonified_request["networkProfile"] == "network_profile_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfile() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkProfile.pb(return_value) + 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(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_rest_unset_required_fields(): + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "networkProfile", + "project", + ) + ) + ) + + +def test_get_rest_flattened(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfile() + + # get arguments that satisfy an http rule for this method + sample_request = {"project": "sample1", "network_profile": "sample2"} + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + network_profile="network_profile_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.NetworkProfile.pb(return_value) + 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(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/global/networkProfiles/{network_profile}" + % client.transport._host, + args[1], + ) + + +def test_get_rest_flattened_error(transport: str = "rest"): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get( + compute.GetNetworkProfileRequest(), + project="project_value", + network_profile="network_profile_value", + ) + + +def test_list_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list] = mock_rpc + + request = {} + client.list(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_rest_required_fields(request_type=compute.ListNetworkProfilesRequest): + transport_class = transports.NetworkProfilesRestTransport + + request_init = {} + request_init["project"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["project"] = "project_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "max_results", + "order_by", + "page_token", + "return_partial_success", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfilesListResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkProfilesListResponse.pb(return_value) + 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(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_rest_unset_required_fields(): + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "maxResults", + "orderBy", + "pageToken", + "returnPartialSuccess", + ) + ) + & set(("project",)) + ) + + +def test_list_rest_flattened(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfilesListResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"project": "sample1"} + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.NetworkProfilesListResponse.pb(return_value) + 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(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/global/networkProfiles" + % client.transport._host, + args[1], + ) + + +def test_list_rest_flattened_error(transport: str = "rest"): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list( + compute.ListNetworkProfilesRequest(), + project="project_value", + ) + + +def test_list_rest_pager(transport: str = "rest"): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + compute.NetworkProfilesListResponse( + items=[ + compute.NetworkProfile(), + compute.NetworkProfile(), + compute.NetworkProfile(), + ], + next_page_token="abc", + ), + compute.NetworkProfilesListResponse( + items=[], + next_page_token="def", + ), + compute.NetworkProfilesListResponse( + items=[ + compute.NetworkProfile(), + ], + next_page_token="ghi", + ), + compute.NetworkProfilesListResponse( + items=[ + compute.NetworkProfile(), + compute.NetworkProfile(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + compute.NetworkProfilesListResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"project": "sample1"} + + pager = client.list(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, compute.NetworkProfile) for i in results) + + pages = list(client.list(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetworkProfilesClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = NetworkProfilesClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = NetworkProfilesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = NetworkProfilesClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = NetworkProfilesClient(transport=transport) + assert client.transport is transport + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.NetworkProfilesRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_rest(): + transport = NetworkProfilesClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_get_rest_bad_request(request_type=compute.GetNetworkProfileRequest): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"project": "sample1", "network_profile": "sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.GetNetworkProfileRequest, + dict, + ], +) +def test_get_rest_call_success(request_type): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"project": "sample1", "network_profile": "sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfile( + creation_timestamp="creation_timestamp_value", + description="description_value", + id=205, + kind="kind_value", + name="name_value", + self_link="self_link_value", + self_link_with_id="self_link_with_id_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkProfile.pb(return_value) + 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(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, compute.NetworkProfile) + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.id == 205 + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.self_link == "self_link_value" + assert response.self_link_with_id == "self_link_with_id_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_rest_interceptors(null_interceptor): + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.NetworkProfilesRestInterceptor(), + ) + client = NetworkProfilesClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.NetworkProfilesRestInterceptor, "post_get" + ) as post, mock.patch.object( + transports.NetworkProfilesRestInterceptor, "pre_get" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.GetNetworkProfileRequest.pb( + compute.GetNetworkProfileRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.NetworkProfile.to_json(compute.NetworkProfile()) + req.return_value.content = return_value + + request = compute.GetNetworkProfileRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.NetworkProfile() + + client.get( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_rest_bad_request(request_type=compute.ListNetworkProfilesRequest): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.ListNetworkProfilesRequest, + dict, + ], +) +def test_list_rest_call_success(request_type): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkProfilesListResponse( + etag="etag_value", + id="id_value", + kind="kind_value", + next_page_token="next_page_token_value", + self_link="self_link_value", + unreachables=["unreachables_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkProfilesListResponse.pb(return_value) + 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(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPager) + assert response.etag == "etag_value" + assert response.id == "id_value" + assert response.kind == "kind_value" + assert response.next_page_token == "next_page_token_value" + assert response.self_link == "self_link_value" + assert response.unreachables == ["unreachables_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_rest_interceptors(null_interceptor): + transport = transports.NetworkProfilesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.NetworkProfilesRestInterceptor(), + ) + client = NetworkProfilesClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.NetworkProfilesRestInterceptor, "post_list" + ) as post, mock.patch.object( + transports.NetworkProfilesRestInterceptor, "pre_list" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.ListNetworkProfilesRequest.pb( + compute.ListNetworkProfilesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.NetworkProfilesListResponse.to_json( + compute.NetworkProfilesListResponse() + ) + req.return_value.content = return_value + + request = compute.ListNetworkProfilesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.NetworkProfilesListResponse() + + client.list( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_initialize_client_w_rest(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_empty_call_rest(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get), "__call__") as call: + client.get(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.GetNetworkProfileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_empty_call_rest(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list), "__call__") as call: + client.list(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.ListNetworkProfilesRequest() + + assert args[0] == request_msg + + +def test_network_profiles_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.NetworkProfilesTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_network_profiles_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.cloud.compute_v1.services.network_profiles.transports.NetworkProfilesTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.NetworkProfilesTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "get", + "list", + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_network_profiles_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.compute_v1.services.network_profiles.transports.NetworkProfilesTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.NetworkProfilesTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform", + ), + quota_project_id="octopus", + ) + + +def test_network_profiles_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.compute_v1.services.network_profiles.transports.NetworkProfilesTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.NetworkProfilesTransport() + adc.assert_called_once() + + +def test_network_profiles_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + NetworkProfilesClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform", + ), + quota_project_id=None, + ) + + +def test_network_profiles_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch( + "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" + ) as mock_configure_mtls_channel: + transports.NetworkProfilesRestTransport( + credentials=cred, client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_network_profiles_host_no_port(transport_name): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="compute.googleapis.com" + ), + transport=transport_name, + ) + assert client.transport._host == ( + "compute.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://compute.googleapis.com" + ) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_network_profiles_host_with_port(transport_name): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="compute.googleapis.com:8000" + ), + transport=transport_name, + ) + assert client.transport._host == ( + "compute.googleapis.com:8000" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://compute.googleapis.com:8000" + ) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_network_profiles_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = NetworkProfilesClient( + credentials=creds1, + transport=transport_name, + ) + client2 = NetworkProfilesClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.get._session + session2 = client2.transport.get._session + assert session1 != session2 + session1 = client1.transport.list._session + session2 = client2.transport.list._session + assert session1 != session2 + + +def test_common_billing_account_path(): + billing_account = "squid" + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = NetworkProfilesClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = NetworkProfilesClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = NetworkProfilesClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "whelk" + expected = "folders/{folder}".format( + folder=folder, + ) + actual = NetworkProfilesClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = NetworkProfilesClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = NetworkProfilesClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "oyster" + expected = "organizations/{organization}".format( + organization=organization, + ) + actual = NetworkProfilesClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = NetworkProfilesClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = NetworkProfilesClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "cuttlefish" + expected = "projects/{project}".format( + project=project, + ) + actual = NetworkProfilesClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = NetworkProfilesClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = NetworkProfilesClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + expected = "projects/{project}/locations/{location}".format( + project=project, + location=location, + ) + actual = NetworkProfilesClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = NetworkProfilesClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = NetworkProfilesClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object( + transports.NetworkProfilesTransport, "_prep_wrapped_messages" + ) as prep: + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object( + transports.NetworkProfilesTransport, "_prep_wrapped_messages" + ) as prep: + transport_class = NetworkProfilesClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + +def test_transport_close_rest(): + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + with mock.patch.object( + type(getattr(client.transport, "_session")), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "rest", + ] + for transport in transports: + client = NetworkProfilesClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (NetworkProfilesClient, transports.NetworkProfilesRestTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format( + UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE + ), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py index 7f06d791adba..18c91606938f 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py @@ -979,6 +979,7 @@ def test_add_peering_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.add_peering(request) @@ -1037,6 +1038,7 @@ def test_add_peering_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.add_peering(**mock_args) @@ -1183,6 +1185,7 @@ def test_add_peering_unary_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.add_peering_unary(request) @@ -1241,6 +1244,7 @@ def test_add_peering_unary_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.add_peering_unary(**mock_args) @@ -1384,6 +1388,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteNetworkRequest): 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(request) @@ -1438,6 +1443,7 @@ def test_delete_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.delete(**mock_args) @@ -1578,6 +1584,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteNetworkReq 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_unary(request) @@ -1632,6 +1639,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1766,6 +1774,7 @@ def test_get_rest_required_fields(request_type=compute.GetNetworkRequest): 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(request) @@ -1820,6 +1829,7 @@ def test_get_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(**mock_args) @@ -1963,6 +1973,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -2017,6 +2028,7 @@ def test_get_effective_firewalls_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_effective_firewalls(**mock_args) @@ -2154,6 +2166,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertNetworkRequest): 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.insert(request) @@ -2208,6 +2221,7 @@ def test_insert_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.insert(**mock_args) @@ -2344,6 +2358,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertNetworkReq 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.insert_unary(request) @@ -2398,6 +2413,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2537,6 +2553,7 @@ def test_list_rest_required_fields(request_type=compute.ListNetworksRequest): 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(request) @@ -2593,6 +2610,7 @@ def test_list_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(**mock_args) @@ -2805,6 +2823,7 @@ def test_list_peering_routes_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.list_peering_routes(request) @@ -2870,6 +2889,7 @@ def test_list_peering_routes_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_peering_routes(**mock_args) @@ -3074,6 +3094,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchNetworkRequest): 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.patch(request) @@ -3130,6 +3151,7 @@ def test_patch_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.patch(**mock_args) @@ -3272,6 +3294,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchNetworkReque 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.patch_unary(request) @@ -3328,6 +3351,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3472,6 +3496,7 @@ def test_remove_peering_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.remove_peering(request) @@ -3530,6 +3555,7 @@ def test_remove_peering_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.remove_peering(**mock_args) @@ -3676,6 +3702,7 @@ def test_remove_peering_unary_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.remove_peering_unary(request) @@ -3734,6 +3761,7 @@ def test_remove_peering_unary_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.remove_peering_unary(**mock_args) @@ -3884,6 +3912,7 @@ def test_switch_to_custom_mode_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.switch_to_custom_mode(request) @@ -3938,6 +3967,7 @@ def test_switch_to_custom_mode_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.switch_to_custom_mode(**mock_args) @@ -4085,6 +4115,7 @@ def test_switch_to_custom_mode_unary_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.switch_to_custom_mode_unary(request) @@ -4139,6 +4170,7 @@ def test_switch_to_custom_mode_unary_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.switch_to_custom_mode_unary(**mock_args) @@ -4282,6 +4314,7 @@ def test_update_peering_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.update_peering(request) @@ -4340,6 +4373,7 @@ def test_update_peering_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_peering(**mock_args) @@ -4486,6 +4520,7 @@ def test_update_peering_unary_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.update_peering_unary(request) @@ -4544,6 +4579,7 @@ def test_update_peering_unary_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_peering_unary(**mock_args) @@ -4678,6 +4714,7 @@ def test_add_peering_rest_bad_request(request_type=compute.AddPeeringNetworkRequ 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.add_peering(request) @@ -4830,6 +4867,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.add_peering(request) # Establish that the response is the type that we expect. @@ -4889,6 +4927,7 @@ def test_add_peering_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4931,6 +4970,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteNetworkRequest): 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(request) @@ -4987,6 +5027,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -5044,6 +5085,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5086,6 +5128,7 @@ def test_get_rest_bad_request(request_type=compute.GetNetworkRequest): 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(request) @@ -5122,6 +5165,7 @@ def test_get_rest_call_success(request_type): mtu=342, name="name_value", network_firewall_policy_enforcement_order="network_firewall_policy_enforcement_order_value", + network_profile="network_profile_value", self_link="self_link_value", self_link_with_id="self_link_with_id_value", subnetworks=["subnetworks_value"], @@ -5136,6 +5180,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5156,6 +5201,7 @@ def test_get_rest_call_success(request_type): response.network_firewall_policy_enforcement_order == "network_firewall_policy_enforcement_order_value" ) + assert response.network_profile == "network_profile_value" assert response.self_link == "self_link_value" assert response.self_link_with_id == "self_link_with_id_value" assert response.subnetworks == ["subnetworks_value"] @@ -5190,6 +5236,7 @@ def test_get_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 = compute.Network.to_json(compute.Network()) req.return_value.content = return_value @@ -5234,6 +5281,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -5267,6 +5315,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) # Establish that the response is the type that we expect. @@ -5304,6 +5353,7 @@ def test_get_effective_firewalls_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 = compute.NetworksGetEffectiveFirewallsResponse.to_json( compute.NetworksGetEffectiveFirewallsResponse() ) @@ -5348,6 +5398,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertNetworkRequest): 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.insert(request) @@ -5379,6 +5430,7 @@ def test_insert_rest_call_success(request_type): "mtu": 342, "name": "name_value", "network_firewall_policy_enforcement_order": "network_firewall_policy_enforcement_order_value", + "network_profile": "network_profile_value", "peerings": [ { "auto_create_routes": True, @@ -5395,7 +5447,12 @@ def test_insert_rest_call_success(request_type): "state_details": "state_details_value", } ], - "routing_config": {"routing_mode": "routing_mode_value"}, + "routing_config": { + "bgp_always_compare_med": True, + "bgp_best_path_selection_mode": "bgp_best_path_selection_mode_value", + "bgp_inter_region_cost": "bgp_inter_region_cost_value", + "routing_mode": "routing_mode_value", + }, "self_link": "self_link_value", "self_link_with_id": "self_link_with_id_value", "subnetworks": ["subnetworks_value1", "subnetworks_value2"], @@ -5506,6 +5563,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.insert(request) # Establish that the response is the type that we expect. @@ -5563,6 +5621,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5605,6 +5664,7 @@ def test_list_rest_bad_request(request_type=compute.ListNetworksRequest): 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(request) @@ -5643,6 +5703,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5682,6 +5743,7 @@ def test_list_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 = compute.NetworkList.to_json(compute.NetworkList()) req.return_value.content = return_value @@ -5726,6 +5788,7 @@ def test_list_peering_routes_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.list_peering_routes(request) @@ -5764,6 +5827,7 @@ def test_list_peering_routes_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_peering_routes(request) # Establish that the response is the type that we expect. @@ -5805,6 +5869,7 @@ def test_list_peering_routes_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 = compute.ExchangedPeeringRoutesList.to_json( compute.ExchangedPeeringRoutesList() ) @@ -5849,6 +5914,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchNetworkRequest): 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.patch(request) @@ -5880,6 +5946,7 @@ def test_patch_rest_call_success(request_type): "mtu": 342, "name": "name_value", "network_firewall_policy_enforcement_order": "network_firewall_policy_enforcement_order_value", + "network_profile": "network_profile_value", "peerings": [ { "auto_create_routes": True, @@ -5896,7 +5963,12 @@ def test_patch_rest_call_success(request_type): "state_details": "state_details_value", } ], - "routing_config": {"routing_mode": "routing_mode_value"}, + "routing_config": { + "bgp_always_compare_med": True, + "bgp_best_path_selection_mode": "bgp_best_path_selection_mode_value", + "bgp_inter_region_cost": "bgp_inter_region_cost_value", + "routing_mode": "routing_mode_value", + }, "self_link": "self_link_value", "self_link_with_id": "self_link_with_id_value", "subnetworks": ["subnetworks_value1", "subnetworks_value2"], @@ -6007,6 +6079,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.patch(request) # Establish that the response is the type that we expect. @@ -6064,6 +6137,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6108,6 +6182,7 @@ def test_remove_peering_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.remove_peering(request) @@ -6245,6 +6320,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.remove_peering(request) # Establish that the response is the type that we expect. @@ -6304,6 +6380,7 @@ def test_remove_peering_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6348,6 +6425,7 @@ def test_switch_to_custom_mode_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.switch_to_custom_mode(request) @@ -6404,6 +6482,7 @@ def test_switch_to_custom_mode_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.switch_to_custom_mode(request) # Establish that the response is the type that we expect. @@ -6463,6 +6542,7 @@ def test_switch_to_custom_mode_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6507,6 +6587,7 @@ def test_update_peering_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.update_peering(request) @@ -6659,6 +6740,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_peering(request) # Establish that the response is the type that we expect. @@ -6718,6 +6800,7 @@ def test_update_peering_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_groups.py index dc3d2395332f..68be93a84380 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_groups.py @@ -992,6 +992,7 @@ def test_add_nodes_rest_required_fields(request_type=compute.AddNodesNodeGroupRe 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.add_nodes(request) @@ -1056,6 +1057,7 @@ def test_add_nodes_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.add_nodes(**mock_args) @@ -1207,6 +1209,7 @@ def test_add_nodes_unary_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.add_nodes_unary(request) @@ -1271,6 +1274,7 @@ def test_add_nodes_unary_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.add_nodes_unary(**mock_args) @@ -1419,6 +1423,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1477,6 +1482,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1690,6 +1696,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteNodeGroupRequest 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(request) @@ -1750,6 +1757,7 @@ def test_delete_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.delete(**mock_args) @@ -1895,6 +1903,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteNodeGroupR 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_unary(request) @@ -1955,6 +1964,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2103,6 +2113,7 @@ def test_delete_nodes_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.delete_nodes(request) @@ -2167,6 +2178,7 @@ def test_delete_nodes_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.delete_nodes(**mock_args) @@ -2318,6 +2330,7 @@ def test_delete_nodes_unary_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.delete_nodes_unary(request) @@ -2382,6 +2395,7 @@ def test_delete_nodes_unary_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.delete_nodes_unary(**mock_args) @@ -2524,6 +2538,7 @@ def test_get_rest_required_fields(request_type=compute.GetNodeGroupRequest): 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(request) @@ -2584,6 +2599,7 @@ def test_get_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(**mock_args) @@ -2727,6 +2743,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) @@ -2787,6 +2804,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) @@ -2941,6 +2959,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertNodeGroupRequest 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.insert(request) @@ -3011,6 +3030,7 @@ def test_insert_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.insert(**mock_args) @@ -3168,6 +3188,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertNodeGroupR 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.insert_unary(request) @@ -3238,6 +3259,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3386,6 +3408,7 @@ def test_list_rest_required_fields(request_type=compute.ListNodeGroupsRequest): 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(request) @@ -3448,6 +3471,7 @@ def test_list_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(**mock_args) @@ -3659,6 +3683,7 @@ def test_list_nodes_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.list_nodes(request) @@ -3727,6 +3752,7 @@ def test_list_nodes_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_nodes(**mock_args) @@ -3938,6 +3964,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchNodeGroupRequest): 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.patch(request) @@ -4002,6 +4029,7 @@ def test_patch_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.patch(**mock_args) @@ -4151,6 +4179,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchNodeGroupReq 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.patch_unary(request) @@ -4215,6 +4244,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -4370,6 +4400,7 @@ def test_perform_maintenance_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.perform_maintenance(request) @@ -4434,6 +4465,7 @@ def test_perform_maintenance_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.perform_maintenance(**mock_args) @@ -4589,6 +4621,7 @@ def test_perform_maintenance_unary_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.perform_maintenance_unary(request) @@ -4653,6 +4686,7 @@ def test_perform_maintenance_unary_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.perform_maintenance_unary(**mock_args) @@ -4798,6 +4832,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) @@ -4862,6 +4897,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) @@ -5015,6 +5051,7 @@ def test_set_node_template_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_node_template(request) @@ -5079,6 +5116,7 @@ def test_set_node_template_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_node_template(**mock_args) @@ -5232,6 +5270,7 @@ def test_set_node_template_unary_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_node_template_unary(request) @@ -5296,6 +5335,7 @@ def test_set_node_template_unary_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_node_template_unary(**mock_args) @@ -5452,6 +5492,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(request) @@ -5516,6 +5557,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(**mock_args) @@ -5672,6 +5714,7 @@ def test_simulate_maintenance_event_unary_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.simulate_maintenance_event_unary(request) @@ -5736,6 +5779,7 @@ def test_simulate_maintenance_event_unary_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.simulate_maintenance_event_unary(**mock_args) @@ -5885,6 +5929,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) @@ -5949,6 +5994,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) @@ -6084,6 +6130,7 @@ def test_add_nodes_rest_bad_request(request_type=compute.AddNodesNodeGroupReques 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.add_nodes(request) @@ -6221,6 +6268,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.add_nodes(request) # Establish that the response is the type that we expect. @@ -6282,6 +6330,7 @@ def test_add_nodes_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6326,6 +6375,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -6365,6 +6415,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -6409,6 +6460,7 @@ def test_aggregated_list_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 = compute.NodeGroupAggregatedList.to_json( compute.NodeGroupAggregatedList() ) @@ -6453,6 +6505,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteNodeGroupRequest): 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(request) @@ -6509,6 +6562,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -6568,6 +6622,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6612,6 +6667,7 @@ def test_delete_nodes_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.delete_nodes(request) @@ -6751,6 +6807,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.delete_nodes(request) # Establish that the response is the type that we expect. @@ -6812,6 +6869,7 @@ def test_delete_nodes_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6854,6 +6912,7 @@ def test_get_rest_bad_request(request_type=compute.GetNodeGroupRequest): 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(request) @@ -6902,6 +6961,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -6953,6 +7013,7 @@ def test_get_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 = compute.NodeGroup.to_json(compute.NodeGroup()) req.return_value.content = return_value @@ -6997,6 +7058,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) @@ -7034,6 +7096,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. @@ -7076,6 +7139,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -7118,6 +7182,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertNodeGroupRequest): 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.insert(request) @@ -7267,6 +7332,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.insert(request) # Establish that the response is the type that we expect. @@ -7326,6 +7392,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7368,6 +7435,7 @@ def test_list_rest_bad_request(request_type=compute.ListNodeGroupsRequest): 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(request) @@ -7406,6 +7474,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -7447,6 +7516,7 @@ def test_list_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 = compute.NodeGroupList.to_json(compute.NodeGroupList()) req.return_value.content = return_value @@ -7489,6 +7559,7 @@ def test_list_nodes_rest_bad_request(request_type=compute.ListNodesNodeGroupsReq 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_nodes(request) @@ -7527,6 +7598,7 @@ def test_list_nodes_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_nodes(request) # Establish that the response is the type that we expect. @@ -7570,6 +7642,7 @@ def test_list_nodes_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 = compute.NodeGroupsListNodes.to_json( compute.NodeGroupsListNodes() ) @@ -7614,6 +7687,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchNodeGroupRequest): 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.patch(request) @@ -7763,6 +7837,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.patch(request) # Establish that the response is the type that we expect. @@ -7822,6 +7897,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7866,6 +7942,7 @@ def test_perform_maintenance_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.perform_maintenance(request) @@ -8008,6 +8085,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.perform_maintenance(request) # Establish that the response is the type that we expect. @@ -8069,6 +8147,7 @@ def test_perform_maintenance_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8113,6 +8192,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) @@ -8266,6 +8346,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -8308,6 +8389,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -8352,6 +8434,7 @@ def test_set_node_template_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_node_template(request) @@ -8493,6 +8576,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.set_node_template(request) # Establish that the response is the type that we expect. @@ -8554,6 +8638,7 @@ def test_set_node_template_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8598,6 +8683,7 @@ def test_simulate_maintenance_event_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.simulate_maintenance_event(request) @@ -8739,6 +8825,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.simulate_maintenance_event(request) # Establish that the response is the type that we expect. @@ -8800,6 +8887,7 @@ def test_simulate_maintenance_event_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8844,6 +8932,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) @@ -8957,6 +9046,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -8997,6 +9087,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_templates.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_templates.py index 4fd0d1d2ff0d..7e3af94e8164 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_templates.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_templates.py @@ -1012,6 +1012,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1070,6 +1071,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1288,6 +1290,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteNodeTemplateRequ 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(request) @@ -1348,6 +1351,7 @@ def test_delete_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.delete(**mock_args) @@ -1495,6 +1499,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1555,6 +1560,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1694,6 +1700,7 @@ def test_get_rest_required_fields(request_type=compute.GetNodeTemplateRequest): 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(request) @@ -1754,6 +1761,7 @@ def test_get_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(**mock_args) @@ -1897,6 +1905,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) @@ -1957,6 +1966,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) @@ -2099,6 +2109,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertNodeTemplateRequ 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.insert(request) @@ -2157,6 +2168,7 @@ def test_insert_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.insert(**mock_args) @@ -2303,6 +2315,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2361,6 +2374,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2508,6 +2522,7 @@ def test_list_rest_required_fields(request_type=compute.ListNodeTemplatesRequest 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(request) @@ -2570,6 +2585,7 @@ def test_list_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(**mock_args) @@ -2772,6 +2788,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) @@ -2836,6 +2853,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) @@ -2985,6 +3003,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) @@ -3049,6 +3068,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) @@ -3186,6 +3206,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3225,6 +3246,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3269,6 +3291,7 @@ def test_aggregated_list_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 = compute.NodeTemplateAggregatedList.to_json( compute.NodeTemplateAggregatedList() ) @@ -3317,6 +3340,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteNodeTemplateRequest) 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(request) @@ -3377,6 +3401,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3438,6 +3463,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3484,6 +3510,7 @@ def test_get_rest_bad_request(request_type=compute.GetNodeTemplateRequest): 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(request) @@ -3533,6 +3560,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3581,6 +3609,7 @@ def test_get_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 = compute.NodeTemplate.to_json(compute.NodeTemplate()) req.return_value.content = return_value @@ -3625,6 +3654,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) @@ -3662,6 +3692,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. @@ -3704,6 +3735,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3746,6 +3778,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertNodeTemplateRequest) 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.insert(request) @@ -3897,6 +3930,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.insert(request) # Establish that the response is the type that we expect. @@ -3958,6 +3992,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4000,6 +4035,7 @@ def test_list_rest_bad_request(request_type=compute.ListNodeTemplatesRequest): 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(request) @@ -4038,6 +4074,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4081,6 +4118,7 @@ def test_list_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 = compute.NodeTemplateList.to_json(compute.NodeTemplateList()) req.return_value.content = return_value @@ -4125,6 +4163,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) @@ -4278,6 +4317,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4320,6 +4360,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4364,6 +4405,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) @@ -4477,6 +4519,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4517,6 +4560,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_types.py index af6654efc240..defaf1b6df74 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_node_types.py @@ -982,6 +982,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1040,6 +1041,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1247,6 +1249,7 @@ def test_get_rest_required_fields(request_type=compute.GetNodeTypeRequest): 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(request) @@ -1307,6 +1310,7 @@ def test_get_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(**mock_args) @@ -1452,6 +1456,7 @@ def test_list_rest_required_fields(request_type=compute.ListNodeTypesRequest): 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(request) @@ -1514,6 +1519,7 @@ def test_list_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(**mock_args) @@ -1708,6 +1714,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1747,6 +1754,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -1789,6 +1797,7 @@ def test_aggregated_list_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 = compute.NodeTypeAggregatedList.to_json( compute.NodeTypeAggregatedList() ) @@ -1833,6 +1842,7 @@ def test_get_rest_bad_request(request_type=compute.GetNodeTypeRequest): 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(request) @@ -1878,6 +1888,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1924,6 +1935,7 @@ def test_get_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 = compute.NodeType.to_json(compute.NodeType()) req.return_value.content = return_value @@ -1966,6 +1978,7 @@ def test_list_rest_bad_request(request_type=compute.ListNodeTypesRequest): 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(request) @@ -2004,6 +2017,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2043,6 +2057,7 @@ def test_list_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 = compute.NodeTypeList.to_json(compute.NodeTypeList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_packet_mirrorings.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_packet_mirrorings.py index 606ff885e03b..f7803ca9cf6a 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_packet_mirrorings.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_packet_mirrorings.py @@ -1036,6 +1036,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1094,6 +1095,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1312,6 +1314,7 @@ def test_delete_rest_required_fields(request_type=compute.DeletePacketMirroringR 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(request) @@ -1372,6 +1375,7 @@ def test_delete_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.delete(**mock_args) @@ -1519,6 +1523,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1579,6 +1584,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1718,6 +1724,7 @@ def test_get_rest_required_fields(request_type=compute.GetPacketMirroringRequest 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(request) @@ -1778,6 +1785,7 @@ def test_get_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(**mock_args) @@ -1920,6 +1928,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertPacketMirroringR 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.insert(request) @@ -1980,6 +1989,7 @@ def test_insert_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.insert(**mock_args) @@ -2128,6 +2138,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2188,6 +2199,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2337,6 +2349,7 @@ def test_list_rest_required_fields(request_type=compute.ListPacketMirroringsRequ 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(request) @@ -2399,6 +2412,7 @@ def test_list_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(**mock_args) @@ -2605,6 +2619,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchPacketMirroringReq 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.patch(request) @@ -2671,6 +2686,7 @@ def test_patch_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.patch(**mock_args) @@ -2824,6 +2840,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2890,6 +2907,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3041,6 +3059,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) @@ -3105,6 +3124,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) @@ -3242,6 +3262,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3281,6 +3302,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3325,6 +3347,7 @@ def test_aggregated_list_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 = compute.PacketMirroringAggregatedList.to_json( compute.PacketMirroringAggregatedList() ) @@ -3373,6 +3396,7 @@ def test_delete_rest_bad_request(request_type=compute.DeletePacketMirroringReque 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(request) @@ -3433,6 +3457,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3494,6 +3519,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3540,6 +3566,7 @@ def test_get_rest_bad_request(request_type=compute.GetPacketMirroringRequest): 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(request) @@ -3587,6 +3614,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3635,6 +3663,7 @@ def test_get_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 = compute.PacketMirroring.to_json(compute.PacketMirroring()) req.return_value.content = return_value @@ -3677,6 +3706,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertPacketMirroringReque 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.insert(request) @@ -3831,6 +3861,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.insert(request) # Establish that the response is the type that we expect. @@ -3892,6 +3923,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3934,6 +3966,7 @@ def test_list_rest_bad_request(request_type=compute.ListPacketMirroringsRequest) 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(request) @@ -3972,6 +4005,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4015,6 +4049,7 @@ def test_list_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 = compute.PacketMirroringList.to_json( compute.PacketMirroringList() ) @@ -4063,6 +4098,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchPacketMirroringRequest 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.patch(request) @@ -4221,6 +4257,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.patch(request) # Establish that the response is the type that we expect. @@ -4282,6 +4319,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4326,6 +4364,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) @@ -4439,6 +4478,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4479,6 +4519,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_projects.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_projects.py index e0ddb2c1f1e1..8709306363ab 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_projects.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_projects.py @@ -976,6 +976,7 @@ def test_disable_xpn_host_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.disable_xpn_host(request) @@ -1021,6 +1022,7 @@ def test_disable_xpn_host_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.disable_xpn_host(**mock_args) @@ -1159,6 +1161,7 @@ def test_disable_xpn_host_unary_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.disable_xpn_host_unary(request) @@ -1204,6 +1207,7 @@ def test_disable_xpn_host_unary_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.disable_xpn_host_unary(**mock_args) @@ -1345,6 +1349,7 @@ def test_disable_xpn_resource_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.disable_xpn_resource(request) @@ -1401,6 +1406,7 @@ def test_disable_xpn_resource_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.disable_xpn_resource(**mock_args) @@ -1546,6 +1552,7 @@ def test_disable_xpn_resource_unary_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.disable_xpn_resource_unary(request) @@ -1602,6 +1609,7 @@ def test_disable_xpn_resource_unary_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.disable_xpn_resource_unary(**mock_args) @@ -1742,6 +1750,7 @@ def test_enable_xpn_host_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.enable_xpn_host(request) @@ -1787,6 +1796,7 @@ def test_enable_xpn_host_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.enable_xpn_host(**mock_args) @@ -1923,6 +1933,7 @@ def test_enable_xpn_host_unary_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.enable_xpn_host_unary(request) @@ -1968,6 +1979,7 @@ def test_enable_xpn_host_unary_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.enable_xpn_host_unary(**mock_args) @@ -2109,6 +2121,7 @@ def test_enable_xpn_resource_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.enable_xpn_resource(request) @@ -2165,6 +2178,7 @@ def test_enable_xpn_resource_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.enable_xpn_resource(**mock_args) @@ -2310,6 +2324,7 @@ def test_enable_xpn_resource_unary_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.enable_xpn_resource_unary(request) @@ -2366,6 +2381,7 @@ def test_enable_xpn_resource_unary_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.enable_xpn_resource_unary(**mock_args) @@ -2498,6 +2514,7 @@ def test_get_rest_required_fields(request_type=compute.GetProjectRequest): 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(request) @@ -2543,6 +2560,7 @@ def test_get_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(**mock_args) @@ -2672,6 +2690,7 @@ def test_get_xpn_host_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_xpn_host(request) @@ -2717,6 +2736,7 @@ def test_get_xpn_host_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_xpn_host(**mock_args) @@ -2859,6 +2879,7 @@ def test_get_xpn_resources_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_xpn_resources(request) @@ -2915,6 +2936,7 @@ def test_get_xpn_resources_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_xpn_resources(**mock_args) @@ -3117,6 +3139,7 @@ def test_list_xpn_hosts_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.list_xpn_hosts(request) @@ -3181,6 +3204,7 @@ def test_list_xpn_hosts_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_xpn_hosts(**mock_args) @@ -3383,6 +3407,7 @@ def test_move_disk_rest_required_fields(request_type=compute.MoveDiskProjectRequ 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.move_disk(request) @@ -3439,6 +3464,7 @@ def test_move_disk_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.move_disk(**mock_args) @@ -3579,6 +3605,7 @@ def test_move_disk_unary_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.move_disk_unary(request) @@ -3635,6 +3662,7 @@ def test_move_disk_unary_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.move_disk_unary(**mock_args) @@ -3775,6 +3803,7 @@ def test_move_instance_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.move_instance(request) @@ -3831,6 +3860,7 @@ def test_move_instance_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.move_instance(**mock_args) @@ -3971,6 +4001,7 @@ def test_move_instance_unary_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.move_instance_unary(request) @@ -4027,6 +4058,7 @@ def test_move_instance_unary_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.move_instance_unary(**mock_args) @@ -4171,6 +4203,7 @@ def test_set_cloud_armor_tier_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_cloud_armor_tier(request) @@ -4227,6 +4260,7 @@ def test_set_cloud_armor_tier_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_cloud_armor_tier(**mock_args) @@ -4372,6 +4406,7 @@ def test_set_cloud_armor_tier_unary_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_cloud_armor_tier_unary(request) @@ -4428,6 +4463,7 @@ def test_set_cloud_armor_tier_unary_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_cloud_armor_tier_unary(**mock_args) @@ -4574,6 +4610,7 @@ def test_set_common_instance_metadata_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_common_instance_metadata(request) @@ -4628,6 +4665,7 @@ def test_set_common_instance_metadata_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_common_instance_metadata(**mock_args) @@ -4772,6 +4810,7 @@ def test_set_common_instance_metadata_unary_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_common_instance_metadata_unary(request) @@ -4826,6 +4865,7 @@ def test_set_common_instance_metadata_unary_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_common_instance_metadata_unary(**mock_args) @@ -4972,6 +5012,7 @@ def test_set_default_network_tier_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_default_network_tier(request) @@ -5028,6 +5069,7 @@ def test_set_default_network_tier_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_default_network_tier(**mock_args) @@ -5174,6 +5216,7 @@ def test_set_default_network_tier_unary_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_default_network_tier_unary(request) @@ -5230,6 +5273,7 @@ def test_set_default_network_tier_unary_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_default_network_tier_unary(**mock_args) @@ -5376,6 +5420,7 @@ def test_set_usage_export_bucket_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_usage_export_bucket(request) @@ -5432,6 +5477,7 @@ def test_set_usage_export_bucket_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_usage_export_bucket(**mock_args) @@ -5578,6 +5624,7 @@ def test_set_usage_export_bucket_unary_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_usage_export_bucket_unary(request) @@ -5634,6 +5681,7 @@ def test_set_usage_export_bucket_unary_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_usage_export_bucket_unary(**mock_args) @@ -5769,6 +5817,7 @@ def test_disable_xpn_host_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.disable_xpn_host(request) @@ -5825,6 +5874,7 @@ def test_disable_xpn_host_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.disable_xpn_host(request) # Establish that the response is the type that we expect. @@ -5884,6 +5934,7 @@ def test_disable_xpn_host_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5928,6 +5979,7 @@ def test_disable_xpn_resource_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.disable_xpn_resource(request) @@ -6069,6 +6121,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.disable_xpn_resource(request) # Establish that the response is the type that we expect. @@ -6128,6 +6181,7 @@ def test_disable_xpn_resource_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6172,6 +6226,7 @@ def test_enable_xpn_host_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.enable_xpn_host(request) @@ -6228,6 +6283,7 @@ def test_enable_xpn_host_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.enable_xpn_host(request) # Establish that the response is the type that we expect. @@ -6287,6 +6343,7 @@ def test_enable_xpn_host_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6331,6 +6388,7 @@ def test_enable_xpn_resource_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.enable_xpn_resource(request) @@ -6472,6 +6530,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.enable_xpn_resource(request) # Establish that the response is the type that we expect. @@ -6531,6 +6590,7 @@ def test_enable_xpn_resource_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6573,6 +6633,7 @@ def test_get_rest_bad_request(request_type=compute.GetProjectRequest): 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(request) @@ -6619,6 +6680,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -6666,6 +6728,7 @@ def test_get_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 = compute.Project.to_json(compute.Project()) req.return_value.content = return_value @@ -6708,6 +6771,7 @@ def test_get_xpn_host_rest_bad_request(request_type=compute.GetXpnHostProjectReq 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_xpn_host(request) @@ -6754,6 +6818,7 @@ def test_get_xpn_host_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_xpn_host(request) # Establish that the response is the type that we expect. @@ -6803,6 +6868,7 @@ def test_get_xpn_host_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 = compute.Project.to_json(compute.Project()) req.return_value.content = return_value @@ -6847,6 +6913,7 @@ def test_get_xpn_resources_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_xpn_resources(request) @@ -6883,6 +6950,7 @@ def test_get_xpn_resources_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_xpn_resources(request) # Establish that the response is the type that we expect. @@ -6922,6 +6990,7 @@ def test_get_xpn_resources_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 = compute.ProjectsGetXpnResources.to_json( compute.ProjectsGetXpnResources() ) @@ -6968,6 +7037,7 @@ def test_list_xpn_hosts_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.list_xpn_hosts(request) @@ -7089,6 +7159,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.list_xpn_hosts(request) # Establish that the response is the type that we expect. @@ -7130,6 +7201,7 @@ def test_list_xpn_hosts_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 = compute.XpnHostList.to_json(compute.XpnHostList()) req.return_value.content = return_value @@ -7172,6 +7244,7 @@ def test_move_disk_rest_bad_request(request_type=compute.MoveDiskProjectRequest) 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.move_disk(request) @@ -7305,6 +7378,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.move_disk(request) # Establish that the response is the type that we expect. @@ -7362,6 +7436,7 @@ def test_move_disk_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7406,6 +7481,7 @@ def test_move_instance_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.move_instance(request) @@ -7541,6 +7617,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.move_instance(request) # Establish that the response is the type that we expect. @@ -7600,6 +7677,7 @@ def test_move_instance_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7644,6 +7722,7 @@ def test_set_cloud_armor_tier_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_cloud_armor_tier(request) @@ -7785,6 +7864,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.set_cloud_armor_tier(request) # Establish that the response is the type that we expect. @@ -7844,6 +7924,7 @@ def test_set_cloud_armor_tier_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7888,6 +7969,7 @@ def test_set_common_instance_metadata_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_common_instance_metadata(request) @@ -8018,6 +8100,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.set_common_instance_metadata(request) # Establish that the response is the type that we expect. @@ -8077,6 +8160,7 @@ def test_set_common_instance_metadata_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8121,6 +8205,7 @@ def test_set_default_network_tier_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_default_network_tier(request) @@ -8262,6 +8347,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.set_default_network_tier(request) # Establish that the response is the type that we expect. @@ -8321,6 +8407,7 @@ def test_set_default_network_tier_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8365,6 +8452,7 @@ def test_set_usage_export_bucket_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_usage_export_bucket(request) @@ -8500,6 +8588,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.set_usage_export_bucket(request) # Establish that the response is the type that we expect. @@ -8559,6 +8648,7 @@ def test_set_usage_export_bucket_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_advertised_prefixes.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_advertised_prefixes.py index d801f651e993..0b8bc67f75c3 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_advertised_prefixes.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_advertised_prefixes.py @@ -1066,6 +1066,7 @@ def test_announce_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.announce(request) @@ -1120,6 +1121,7 @@ def test_announce_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.announce(**mock_args) @@ -1264,6 +1266,7 @@ def test_announce_unary_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.announce_unary(request) @@ -1318,6 +1321,7 @@ def test_announce_unary_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.announce_unary(**mock_args) @@ -1462,6 +1466,7 @@ def test_delete_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.delete(request) @@ -1516,6 +1521,7 @@ def test_delete_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.delete(**mock_args) @@ -1660,6 +1666,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1714,6 +1721,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1852,6 +1860,7 @@ def test_get_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(request) @@ -1906,6 +1915,7 @@ def test_get_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(**mock_args) @@ -2045,6 +2055,7 @@ def test_insert_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.insert(request) @@ -2101,6 +2112,7 @@ def test_insert_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.insert(**mock_args) @@ -2242,6 +2254,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2298,6 +2311,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2442,6 +2456,7 @@ def test_list_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.list(request) @@ -2498,6 +2513,7 @@ def test_list_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(**mock_args) @@ -2705,6 +2721,7 @@ def test_patch_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.patch(request) @@ -2763,6 +2780,7 @@ def test_patch_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.patch(**mock_args) @@ -2911,6 +2929,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2969,6 +2988,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3116,6 +3136,7 @@ def test_withdraw_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.withdraw(request) @@ -3170,6 +3191,7 @@ def test_withdraw_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.withdraw(**mock_args) @@ -3314,6 +3336,7 @@ def test_withdraw_unary_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.withdraw_unary(request) @@ -3368,6 +3391,7 @@ def test_withdraw_unary_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.withdraw_unary(**mock_args) @@ -3501,6 +3525,7 @@ def test_announce_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.announce(request) @@ -3557,6 +3582,7 @@ def test_announce_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.announce(request) # Establish that the response is the type that we expect. @@ -3618,6 +3644,7 @@ def test_announce_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3662,6 +3689,7 @@ def test_delete_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.delete(request) @@ -3718,6 +3746,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3779,6 +3808,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3821,6 +3851,7 @@ def test_get_rest_bad_request(request_type=compute.GetPublicAdvertisedPrefixeReq 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(request) @@ -3868,6 +3899,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3920,6 +3952,7 @@ def test_get_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 = compute.PublicAdvertisedPrefix.to_json( compute.PublicAdvertisedPrefix() ) @@ -3966,6 +3999,7 @@ def test_insert_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.insert(request) @@ -4121,6 +4155,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.insert(request) # Establish that the response is the type that we expect. @@ -4182,6 +4217,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4226,6 +4262,7 @@ def test_list_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.list(request) @@ -4264,6 +4301,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4307,6 +4345,7 @@ def test_list_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 = compute.PublicAdvertisedPrefixList.to_json( compute.PublicAdvertisedPrefixList() ) @@ -4353,6 +4392,7 @@ def test_patch_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.patch(request) @@ -4508,6 +4548,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.patch(request) # Establish that the response is the type that we expect. @@ -4569,6 +4610,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4613,6 +4655,7 @@ def test_withdraw_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.withdraw(request) @@ -4669,6 +4712,7 @@ def test_withdraw_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.withdraw(request) # Establish that the response is the type that we expect. @@ -4730,6 +4774,7 @@ def test_withdraw_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_delegated_prefixes.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_delegated_prefixes.py index db4a041cba8f..82c3569094ad 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_delegated_prefixes.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_public_delegated_prefixes.py @@ -1062,6 +1062,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1120,6 +1121,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1340,6 +1342,7 @@ def test_announce_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.announce(request) @@ -1400,6 +1403,7 @@ def test_announce_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.announce(**mock_args) @@ -1547,6 +1551,7 @@ def test_announce_unary_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.announce_unary(request) @@ -1607,6 +1612,7 @@ def test_announce_unary_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.announce_unary(**mock_args) @@ -1754,6 +1760,7 @@ def test_delete_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.delete(request) @@ -1814,6 +1821,7 @@ def test_delete_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.delete(**mock_args) @@ -1961,6 +1969,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2021,6 +2030,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2162,6 +2172,7 @@ def test_get_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(request) @@ -2222,6 +2233,7 @@ def test_get_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(**mock_args) @@ -2366,6 +2378,7 @@ def test_insert_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.insert(request) @@ -2424,6 +2437,7 @@ def test_insert_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.insert(**mock_args) @@ -2570,6 +2584,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2628,6 +2643,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2777,6 +2793,7 @@ def test_list_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.list(request) @@ -2839,6 +2856,7 @@ def test_list_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(**mock_args) @@ -3047,6 +3065,7 @@ def test_patch_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.patch(request) @@ -3111,6 +3130,7 @@ def test_patch_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.patch(**mock_args) @@ -3262,6 +3282,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3326,6 +3347,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3476,6 +3498,7 @@ def test_withdraw_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.withdraw(request) @@ -3536,6 +3559,7 @@ def test_withdraw_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.withdraw(**mock_args) @@ -3683,6 +3707,7 @@ def test_withdraw_unary_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.withdraw_unary(request) @@ -3743,6 +3768,7 @@ def test_withdraw_unary_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.withdraw_unary(**mock_args) @@ -3877,6 +3903,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3916,6 +3943,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3960,6 +3988,7 @@ def test_aggregated_list_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 = compute.PublicDelegatedPrefixAggregatedList.to_json( compute.PublicDelegatedPrefixAggregatedList() ) @@ -4010,6 +4039,7 @@ def test_announce_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.announce(request) @@ -4070,6 +4100,7 @@ def test_announce_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.announce(request) # Establish that the response is the type that we expect. @@ -4131,6 +4162,7 @@ def test_announce_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4179,6 +4211,7 @@ def test_delete_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.delete(request) @@ -4239,6 +4272,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4300,6 +4334,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4346,6 +4381,7 @@ def test_get_rest_bad_request(request_type=compute.GetPublicDelegatedPrefixeRequ 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(request) @@ -4399,6 +4435,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4453,6 +4490,7 @@ def test_get_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 = compute.PublicDelegatedPrefix.to_json( compute.PublicDelegatedPrefix() ) @@ -4499,6 +4537,7 @@ def test_insert_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.insert(request) @@ -4660,6 +4699,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.insert(request) # Establish that the response is the type that we expect. @@ -4721,6 +4761,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4763,6 +4804,7 @@ def test_list_rest_bad_request(request_type=compute.ListPublicDelegatedPrefixesR 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(request) @@ -4801,6 +4843,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4844,6 +4887,7 @@ def test_list_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 = compute.PublicDelegatedPrefixList.to_json( compute.PublicDelegatedPrefixList() ) @@ -4894,6 +4938,7 @@ def test_patch_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.patch(request) @@ -5059,6 +5104,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.patch(request) # Establish that the response is the type that we expect. @@ -5120,6 +5166,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5168,6 +5215,7 @@ def test_withdraw_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.withdraw(request) @@ -5228,6 +5276,7 @@ def test_withdraw_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.withdraw(request) # Establish that the response is the type that we expect. @@ -5289,6 +5338,7 @@ def test_withdraw_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_autoscalers.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_autoscalers.py index 22d3737e2648..0e036605b668 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_autoscalers.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_autoscalers.py @@ -1046,6 +1046,7 @@ def test_delete_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.delete(request) @@ -1106,6 +1107,7 @@ def test_delete_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.delete(**mock_args) @@ -1253,6 +1255,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1313,6 +1316,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1452,6 +1456,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionAutoscalerReques 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(request) @@ -1512,6 +1517,7 @@ def test_get_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(**mock_args) @@ -1656,6 +1662,7 @@ def test_insert_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.insert(request) @@ -1714,6 +1721,7 @@ def test_insert_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.insert(**mock_args) @@ -1860,6 +1868,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1918,6 +1927,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2065,6 +2075,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionAutoscalersReq 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(request) @@ -2127,6 +2138,7 @@ def test_list_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(**mock_args) @@ -2334,6 +2346,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchRegionAutoscalerRe 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.patch(request) @@ -2397,6 +2410,7 @@ def test_patch_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.patch(**mock_args) @@ -2548,6 +2562,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2611,6 +2626,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2762,6 +2778,7 @@ def test_update_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.update(request) @@ -2825,6 +2842,7 @@ def test_update_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(**mock_args) @@ -2976,6 +2994,7 @@ def test_update_unary_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.update_unary(request) @@ -3039,6 +3058,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3173,6 +3193,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionAutoscalerRequ 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(request) @@ -3229,6 +3250,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3290,6 +3312,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3332,6 +3355,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionAutoscalerRequest): 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(request) @@ -3377,6 +3401,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3427,6 +3452,7 @@ def test_get_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 = compute.Autoscaler.to_json(compute.Autoscaler()) req.return_value.content = return_value @@ -3469,6 +3495,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionAutoscalerRequ 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.insert(request) @@ -3638,6 +3665,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.insert(request) # Establish that the response is the type that we expect. @@ -3699,6 +3727,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3741,6 +3770,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionAutoscalersRequest 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(request) @@ -3779,6 +3809,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3822,6 +3853,7 @@ def test_list_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 = compute.RegionAutoscalerList.to_json( compute.RegionAutoscalerList() ) @@ -3866,6 +3898,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionAutoscalerReques 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.patch(request) @@ -4033,6 +4066,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.patch(request) # Establish that the response is the type that we expect. @@ -4094,6 +4128,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4136,6 +4171,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRegionAutoscalerRequ 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(request) @@ -4305,6 +4341,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(request) # Establish that the response is the type that we expect. @@ -4366,6 +4403,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_backend_services.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_backend_services.py index 0a1ed93c9c78..197baeef6c17 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_backend_services.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_backend_services.py @@ -1062,6 +1062,7 @@ def test_delete_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.delete(request) @@ -1122,6 +1123,7 @@ def test_delete_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.delete(**mock_args) @@ -1269,6 +1271,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1329,6 +1332,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1468,6 +1472,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionBackendServiceRe 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(request) @@ -1528,6 +1533,7 @@ def test_get_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(**mock_args) @@ -1670,6 +1676,7 @@ def test_get_health_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_health(request) @@ -1734,6 +1741,7 @@ def test_get_health_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_health(**mock_args) @@ -1880,6 +1888,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) @@ -1940,6 +1949,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) @@ -2084,6 +2094,7 @@ def test_insert_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.insert(request) @@ -2142,6 +2153,7 @@ def test_insert_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.insert(**mock_args) @@ -2288,6 +2300,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2346,6 +2359,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2495,6 +2509,7 @@ def test_list_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.list(request) @@ -2557,6 +2572,7 @@ def test_list_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(**mock_args) @@ -2764,6 +2780,7 @@ def test_list_usable_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.list_usable(request) @@ -2826,6 +2843,7 @@ def test_list_usable_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_usable(**mock_args) @@ -3034,6 +3052,7 @@ def test_patch_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.patch(request) @@ -3098,6 +3117,7 @@ def test_patch_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.patch(**mock_args) @@ -3249,6 +3269,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3313,6 +3334,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3458,6 +3480,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) @@ -3522,6 +3545,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) @@ -3677,6 +3701,7 @@ def test_set_security_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_security_policy(request) @@ -3741,6 +3766,7 @@ def test_set_security_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_security_policy(**mock_args) @@ -3896,6 +3922,7 @@ def test_set_security_policy_unary_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_security_policy_unary(request) @@ -3960,6 +3987,7 @@ def test_set_security_policy_unary_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_security_policy_unary(**mock_args) @@ -4109,6 +4137,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) @@ -4173,6 +4202,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) @@ -4324,6 +4354,7 @@ def test_update_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.update(request) @@ -4388,6 +4419,7 @@ def test_update_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(**mock_args) @@ -4539,6 +4571,7 @@ def test_update_unary_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.update_unary(request) @@ -4603,6 +4636,7 @@ def test_update_unary_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_unary(**mock_args) @@ -4744,6 +4778,7 @@ def test_delete_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.delete(request) @@ -4804,6 +4839,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4865,6 +4901,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4911,6 +4948,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionBackendServiceReques 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(request) @@ -4976,6 +5014,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5042,6 +5081,7 @@ def test_get_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 = compute.BackendService.to_json(compute.BackendService()) req.return_value.content = return_value @@ -5090,6 +5130,7 @@ def test_get_health_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_health(request) @@ -5205,6 +5246,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.get_health(request) # Establish that the response is the type that we expect. @@ -5245,6 +5287,7 @@ def test_get_health_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 = compute.BackendServiceGroupHealth.to_json( compute.BackendServiceGroupHealth() ) @@ -5291,6 +5334,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) @@ -5328,6 +5372,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. @@ -5370,6 +5415,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5414,6 +5460,7 @@ def test_insert_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.insert(request) @@ -5711,6 +5758,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.insert(request) # Establish that the response is the type that we expect. @@ -5772,6 +5820,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5814,6 +5863,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionBackendServicesReq 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(request) @@ -5852,6 +5902,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5895,6 +5946,7 @@ def test_list_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 = compute.BackendServiceList.to_json(compute.BackendServiceList()) req.return_value.content = return_value @@ -5939,6 +5991,7 @@ def test_list_usable_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.list_usable(request) @@ -5977,6 +6030,7 @@ def test_list_usable_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_usable(request) # Establish that the response is the type that we expect. @@ -6020,6 +6074,7 @@ def test_list_usable_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 = compute.BackendServiceListUsable.to_json( compute.BackendServiceListUsable() ) @@ -6068,6 +6123,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionBackendServiceRe 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.patch(request) @@ -6369,6 +6425,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.patch(request) # Establish that the response is the type that we expect. @@ -6430,6 +6487,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6474,6 +6532,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) @@ -6627,6 +6686,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -6669,6 +6729,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -6717,6 +6778,7 @@ def test_set_security_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_security_policy(request) @@ -6855,6 +6917,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.set_security_policy(request) # Establish that the response is the type that we expect. @@ -6916,6 +6979,7 @@ def test_set_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6960,6 +7024,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) @@ -7073,6 +7138,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -7113,6 +7179,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -7163,6 +7230,7 @@ def test_update_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.update(request) @@ -7464,6 +7532,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(request) # Establish that the response is the type that we expect. @@ -7525,6 +7594,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_commitments.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_commitments.py index a207351e4ecf..d75aa1635141 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_commitments.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_commitments.py @@ -1044,6 +1044,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1102,6 +1103,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1312,6 +1314,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionCommitmentReques 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(request) @@ -1372,6 +1375,7 @@ def test_get_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(**mock_args) @@ -1516,6 +1520,7 @@ def test_insert_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.insert(request) @@ -1572,6 +1577,7 @@ def test_insert_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.insert(**mock_args) @@ -1716,6 +1722,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1772,6 +1779,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -1917,6 +1925,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionCommitmentsReq 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(request) @@ -1979,6 +1988,7 @@ def test_list_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(**mock_args) @@ -2193,6 +2203,7 @@ def test_update_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.update(request) @@ -2261,6 +2272,7 @@ def test_update_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(**mock_args) @@ -2416,6 +2428,7 @@ def test_update_unary_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.update_unary(request) @@ -2484,6 +2497,7 @@ def test_update_unary_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_unary(**mock_args) @@ -2619,6 +2633,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -2658,6 +2673,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -2702,6 +2718,7 @@ def test_aggregated_list_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 = compute.CommitmentAggregatedList.to_json( compute.CommitmentAggregatedList() ) @@ -2746,6 +2763,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionCommitmentRequest): 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(request) @@ -2799,6 +2817,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2857,6 +2876,7 @@ def test_get_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 = compute.Commitment.to_json(compute.Commitment()) req.return_value.content = return_value @@ -2899,6 +2919,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionCommitmentRequ 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.insert(request) @@ -3121,6 +3142,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.insert(request) # Establish that the response is the type that we expect. @@ -3182,6 +3204,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3224,6 +3247,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionCommitmentsRequest 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(request) @@ -3262,6 +3286,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3305,6 +3330,7 @@ def test_list_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 = compute.CommitmentList.to_json(compute.CommitmentList()) req.return_value.content = return_value @@ -3347,6 +3373,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRegionCommitmentRequ 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(request) @@ -3569,6 +3596,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(request) # Establish that the response is the type that we expect. @@ -3630,6 +3658,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disk_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disk_types.py index 995fcdedbf99..a96d22545472 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disk_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disk_types.py @@ -1017,6 +1017,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionDiskTypeRequest) 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(request) @@ -1077,6 +1078,7 @@ def test_get_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(**mock_args) @@ -1222,6 +1224,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionDiskTypesReque 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(request) @@ -1284,6 +1287,7 @@ def test_list_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(**mock_args) @@ -1476,6 +1480,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionDiskTypeRequest): 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(request) @@ -1520,6 +1525,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1569,6 +1575,7 @@ def test_get_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 = compute.DiskType.to_json(compute.DiskType()) req.return_value.content = return_value @@ -1611,6 +1618,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionDiskTypesRequest): 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(request) @@ -1649,6 +1657,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1692,6 +1701,7 @@ def test_list_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 = compute.RegionDiskTypeList.to_json(compute.RegionDiskTypeList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disks.py index cd41e2c06498..f41249aef4d7 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_disks.py @@ -1003,6 +1003,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -1063,6 +1064,7 @@ def test_add_resource_policies_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.add_resource_policies(**mock_args) @@ -1219,6 +1221,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(request) @@ -1279,6 +1282,7 @@ def test_add_resource_policies_unary_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.add_resource_policies_unary(**mock_args) @@ -1426,6 +1430,7 @@ def test_bulk_insert_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.bulk_insert(request) @@ -1484,6 +1489,7 @@ def test_bulk_insert_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.bulk_insert(**mock_args) @@ -1630,6 +1636,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(request) @@ -1688,6 +1695,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(**mock_args) @@ -1838,6 +1846,7 @@ def test_create_snapshot_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.create_snapshot(request) @@ -1896,6 +1905,7 @@ def test_create_snapshot_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_snapshot(**mock_args) @@ -2045,6 +2055,7 @@ def test_create_snapshot_unary_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.create_snapshot_unary(request) @@ -2103,6 +2114,7 @@ def test_create_snapshot_unary_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_snapshot_unary(**mock_args) @@ -2249,6 +2261,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRegionDiskReques 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(request) @@ -2305,6 +2318,7 @@ def test_delete_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.delete(**mock_args) @@ -2452,6 +2466,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2508,6 +2523,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2647,6 +2663,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionDiskRequest): 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(request) @@ -2703,6 +2720,7 @@ def test_get_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(**mock_args) @@ -2846,6 +2864,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) @@ -2906,6 +2925,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) @@ -3053,6 +3073,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertRegionDiskReques 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.insert(request) @@ -3114,6 +3135,7 @@ def test_insert_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.insert(**mock_args) @@ -3263,6 +3285,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3324,6 +3347,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3469,6 +3493,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionDisksRequest): 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(request) @@ -3531,6 +3556,7 @@ def test_list_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(**mock_args) @@ -3744,6 +3770,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -3804,6 +3831,7 @@ def test_remove_resource_policies_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.remove_resource_policies(**mock_args) @@ -3960,6 +3988,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(request) @@ -4020,6 +4049,7 @@ def test_remove_resource_policies_unary_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.remove_resource_policies_unary(**mock_args) @@ -4169,6 +4199,7 @@ def test_resize_rest_required_fields(request_type=compute.ResizeRegionDiskReques 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.resize(request) @@ -4229,6 +4260,7 @@ def test_resize_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.resize(**mock_args) @@ -4380,6 +4412,7 @@ def test_resize_unary_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.resize_unary(request) @@ -4440,6 +4473,7 @@ def test_resize_unary_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.resize_unary(**mock_args) @@ -4585,6 +4619,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) @@ -4649,6 +4684,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) @@ -4800,6 +4836,7 @@ def test_set_labels_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_labels(request) @@ -4864,6 +4901,7 @@ def test_set_labels_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_labels(**mock_args) @@ -5015,6 +5053,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -5079,6 +5118,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -5235,6 +5275,7 @@ def test_start_async_replication_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.start_async_replication(request) @@ -5295,6 +5336,7 @@ def test_start_async_replication_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.start_async_replication(**mock_args) @@ -5451,6 +5493,7 @@ def test_start_async_replication_unary_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.start_async_replication_unary(request) @@ -5511,6 +5554,7 @@ def test_start_async_replication_unary_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.start_async_replication_unary(**mock_args) @@ -5666,6 +5710,7 @@ def test_stop_async_replication_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.stop_async_replication(request) @@ -5722,6 +5767,7 @@ def test_stop_async_replication_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.stop_async_replication(**mock_args) @@ -5874,6 +5920,7 @@ def test_stop_async_replication_unary_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.stop_async_replication_unary(request) @@ -5930,6 +5977,7 @@ def test_stop_async_replication_unary_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.stop_async_replication_unary(**mock_args) @@ -6079,6 +6127,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(request) @@ -6137,6 +6186,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(**mock_args) @@ -6288,6 +6338,7 @@ def test_stop_group_async_replication_unary_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.stop_group_async_replication_unary(request) @@ -6346,6 +6397,7 @@ def test_stop_group_async_replication_unary_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.stop_group_async_replication_unary(**mock_args) @@ -6496,6 +6548,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) @@ -6560,6 +6613,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) @@ -6715,6 +6769,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateRegionDiskReques 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(request) @@ -6779,6 +6834,7 @@ def test_update_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(**mock_args) @@ -6934,6 +6990,7 @@ def test_update_unary_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.update_unary(request) @@ -6998,6 +7055,7 @@ def test_update_unary_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_unary(**mock_args) @@ -7133,6 +7191,7 @@ def test_add_resource_policies_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.add_resource_policies(request) @@ -7274,6 +7333,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.add_resource_policies(request) # Establish that the response is the type that we expect. @@ -7335,6 +7395,7 @@ def test_add_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7377,6 +7438,7 @@ def test_bulk_insert_rest_bad_request(request_type=compute.BulkInsertRegionDiskR 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.bulk_insert(request) @@ -7511,6 +7573,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.bulk_insert(request) # Establish that the response is the type that we expect. @@ -7572,6 +7635,7 @@ def test_bulk_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7616,6 +7680,7 @@ def test_create_snapshot_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.create_snapshot(request) @@ -7785,6 +7850,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_snapshot(request) # Establish that the response is the type that we expect. @@ -7846,6 +7912,7 @@ def test_create_snapshot_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7888,6 +7955,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionDiskRequest): 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(request) @@ -7944,6 +8012,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -8005,6 +8074,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8047,6 +8117,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionDiskRequest): 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(request) @@ -8122,6 +8193,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -8206,6 +8278,7 @@ def test_get_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 = compute.Disk.to_json(compute.Disk()) req.return_value.content = return_value @@ -8250,6 +8323,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) @@ -8287,6 +8361,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. @@ -8329,6 +8404,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -8371,6 +8447,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionDiskRequest): 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.insert(request) @@ -8560,6 +8637,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.insert(request) # Establish that the response is the type that we expect. @@ -8621,6 +8699,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8663,6 +8742,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionDisksRequest): 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(request) @@ -8701,6 +8781,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -8742,6 +8823,7 @@ def test_list_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 = compute.DiskList.to_json(compute.DiskList()) req.return_value.content = return_value @@ -8786,6 +8868,7 @@ def test_remove_resource_policies_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.remove_resource_policies(request) @@ -8927,6 +9010,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.remove_resource_policies(request) # Establish that the response is the type that we expect. @@ -8988,6 +9072,7 @@ def test_remove_resource_policies_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9030,6 +9115,7 @@ def test_resize_rest_bad_request(request_type=compute.ResizeRegionDiskRequest): 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.resize(request) @@ -9164,6 +9250,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.resize(request) # Establish that the response is the type that we expect. @@ -9225,6 +9312,7 @@ def test_resize_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9269,6 +9357,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) @@ -9422,6 +9511,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -9464,6 +9554,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -9506,6 +9597,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsRegionDiskReq 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_labels(request) @@ -9641,6 +9733,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.set_labels(request) # Establish that the response is the type that we expect. @@ -9702,6 +9795,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9746,6 +9840,7 @@ def test_start_async_replication_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.start_async_replication(request) @@ -9887,6 +9982,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.start_async_replication(request) # Establish that the response is the type that we expect. @@ -9948,6 +10044,7 @@ def test_start_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9992,6 +10089,7 @@ def test_stop_async_replication_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.stop_async_replication(request) @@ -10048,6 +10146,7 @@ def test_stop_async_replication_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.stop_async_replication(request) # Establish that the response is the type that we expect. @@ -10109,6 +10208,7 @@ def test_stop_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10153,6 +10253,7 @@ def test_stop_group_async_replication_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.stop_group_async_replication(request) @@ -10294,6 +10395,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.stop_group_async_replication(request) # Establish that the response is the type that we expect. @@ -10355,6 +10457,7 @@ def test_stop_group_async_replication_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -10399,6 +10502,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) @@ -10512,6 +10616,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -10552,6 +10657,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -10596,6 +10702,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRegionDiskRequest): 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(request) @@ -10785,6 +10892,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(request) # Establish that the response is the type that we expect. @@ -10846,6 +10954,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_check_services.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_check_services.py index ddb0b71a61fb..61243c2c0224 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_check_services.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_check_services.py @@ -1074,6 +1074,7 @@ def test_delete_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.delete(request) @@ -1134,6 +1135,7 @@ def test_delete_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.delete(**mock_args) @@ -1281,6 +1283,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1341,6 +1344,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1482,6 +1486,7 @@ def test_get_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(request) @@ -1542,6 +1547,7 @@ def test_get_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(**mock_args) @@ -1686,6 +1692,7 @@ def test_insert_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.insert(request) @@ -1744,6 +1751,7 @@ def test_insert_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.insert(**mock_args) @@ -1890,6 +1898,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1948,6 +1957,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2097,6 +2107,7 @@ def test_list_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.list(request) @@ -2159,6 +2170,7 @@ def test_list_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(**mock_args) @@ -2367,6 +2379,7 @@ def test_patch_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.patch(request) @@ -2431,6 +2444,7 @@ def test_patch_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.patch(**mock_args) @@ -2582,6 +2596,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2646,6 +2661,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2787,6 +2803,7 @@ def test_delete_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.delete(request) @@ -2847,6 +2864,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2908,6 +2926,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2954,6 +2973,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionHealthCheckServiceRe 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(request) @@ -3004,6 +3024,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3058,6 +3079,7 @@ def test_get_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 = compute.HealthCheckService.to_json(compute.HealthCheckService()) req.return_value.content = return_value @@ -3102,6 +3124,7 @@ def test_insert_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.insert(request) @@ -3253,6 +3276,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.insert(request) # Establish that the response is the type that we expect. @@ -3314,6 +3338,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3358,6 +3383,7 @@ def test_list_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.list(request) @@ -3396,6 +3422,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3439,6 +3466,7 @@ def test_list_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 = compute.HealthCheckServicesList.to_json( compute.HealthCheckServicesList() ) @@ -3489,6 +3517,7 @@ def test_patch_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.patch(request) @@ -3644,6 +3673,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.patch(request) # Establish that the response is the type that we expect. @@ -3705,6 +3735,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_checks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_checks.py index d927db1ea0f8..4c9953b753ac 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_checks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_health_checks.py @@ -1050,6 +1050,7 @@ def test_delete_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.delete(request) @@ -1110,6 +1111,7 @@ def test_delete_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.delete(**mock_args) @@ -1257,6 +1259,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1317,6 +1320,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1456,6 +1460,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionHealthCheckReque 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(request) @@ -1516,6 +1521,7 @@ def test_get_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(**mock_args) @@ -1660,6 +1666,7 @@ def test_insert_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.insert(request) @@ -1716,6 +1723,7 @@ def test_insert_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.insert(**mock_args) @@ -1860,6 +1868,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1916,6 +1925,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2061,6 +2071,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionHealthChecksRe 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(request) @@ -2123,6 +2134,7 @@ def test_list_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(**mock_args) @@ -2329,6 +2341,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchRegionHealthCheckR 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.patch(request) @@ -2391,6 +2404,7 @@ def test_patch_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.patch(**mock_args) @@ -2540,6 +2554,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2602,6 +2617,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2751,6 +2767,7 @@ def test_update_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.update(request) @@ -2813,6 +2830,7 @@ def test_update_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(**mock_args) @@ -2962,6 +2980,7 @@ def test_update_unary_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.update_unary(request) @@ -3024,6 +3043,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3161,6 +3181,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionHealthCheckReq 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(request) @@ -3221,6 +3242,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3282,6 +3304,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3328,6 +3351,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionHealthCheckRequest): 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(request) @@ -3379,6 +3403,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3431,6 +3456,7 @@ def test_get_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 = compute.HealthCheck.to_json(compute.HealthCheck()) req.return_value.content = return_value @@ -3473,6 +3499,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionHealthCheckReq 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.insert(request) @@ -3665,6 +3692,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.insert(request) # Establish that the response is the type that we expect. @@ -3726,6 +3754,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3768,6 +3797,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionHealthChecksReques 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(request) @@ -3806,6 +3836,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3849,6 +3880,7 @@ def test_list_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 = compute.HealthCheckList.to_json(compute.HealthCheckList()) req.return_value.content = return_value @@ -3895,6 +3927,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionHealthCheckReque 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.patch(request) @@ -4091,6 +4124,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.patch(request) # Establish that the response is the type that we expect. @@ -4152,6 +4186,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4198,6 +4233,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRegionHealthCheckReq 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(request) @@ -4394,6 +4430,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(request) # Establish that the response is the type that we expect. @@ -4455,6 +4492,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_group_managers.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_group_managers.py index dce6116f6c5b..3de03fd1e41e 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_group_managers.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_group_managers.py @@ -1081,6 +1081,7 @@ def test_abandon_instances_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.abandon_instances(request) @@ -1145,6 +1146,7 @@ def test_abandon_instances_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.abandon_instances(**mock_args) @@ -1298,6 +1300,7 @@ def test_abandon_instances_unary_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.abandon_instances_unary(request) @@ -1362,6 +1365,7 @@ def test_abandon_instances_unary_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.abandon_instances_unary(**mock_args) @@ -1516,6 +1520,7 @@ def test_apply_updates_to_instances_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.apply_updates_to_instances(request) @@ -1580,6 +1585,7 @@ def test_apply_updates_to_instances_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.apply_updates_to_instances(**mock_args) @@ -1734,6 +1740,7 @@ def test_apply_updates_to_instances_unary_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.apply_updates_to_instances_unary(request) @@ -1798,6 +1805,7 @@ def test_apply_updates_to_instances_unary_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.apply_updates_to_instances_unary(**mock_args) @@ -1951,6 +1959,7 @@ def test_create_instances_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.create_instances(request) @@ -2015,6 +2024,7 @@ def test_create_instances_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_instances(**mock_args) @@ -2168,6 +2178,7 @@ def test_create_instances_unary_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.create_instances_unary(request) @@ -2232,6 +2243,7 @@ def test_create_instances_unary_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_instances_unary(**mock_args) @@ -2382,6 +2394,7 @@ def test_delete_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.delete(request) @@ -2442,6 +2455,7 @@ def test_delete_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.delete(**mock_args) @@ -2589,6 +2603,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2649,6 +2664,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2799,6 +2815,7 @@ def test_delete_instances_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.delete_instances(request) @@ -2863,6 +2880,7 @@ def test_delete_instances_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.delete_instances(**mock_args) @@ -3016,6 +3034,7 @@ def test_delete_instances_unary_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.delete_instances_unary(request) @@ -3080,6 +3099,7 @@ def test_delete_instances_unary_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.delete_instances_unary(**mock_args) @@ -3234,6 +3254,7 @@ def test_delete_per_instance_configs_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.delete_per_instance_configs(request) @@ -3298,6 +3319,7 @@ def test_delete_per_instance_configs_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.delete_per_instance_configs(**mock_args) @@ -3452,6 +3474,7 @@ def test_delete_per_instance_configs_unary_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.delete_per_instance_configs_unary(request) @@ -3516,6 +3539,7 @@ def test_delete_per_instance_configs_unary_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.delete_per_instance_configs_unary(**mock_args) @@ -3662,6 +3686,7 @@ def test_get_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(request) @@ -3722,6 +3747,7 @@ def test_get_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(**mock_args) @@ -3866,6 +3892,7 @@ def test_insert_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.insert(request) @@ -3928,6 +3955,7 @@ def test_insert_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.insert(**mock_args) @@ -4078,6 +4106,7 @@ def test_insert_unary_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.insert_unary(request) @@ -4140,6 +4169,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -4293,6 +4323,7 @@ def test_list_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.list(request) @@ -4355,6 +4386,7 @@ def test_list_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(**mock_args) @@ -4570,6 +4602,7 @@ def test_list_errors_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.list_errors(request) @@ -4640,6 +4673,7 @@ def test_list_errors_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_errors(**mock_args) @@ -4866,6 +4900,7 @@ def test_list_managed_instances_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.list_managed_instances(request) @@ -4936,6 +4971,7 @@ def test_list_managed_instances_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_managed_instances(**mock_args) @@ -5164,6 +5200,7 @@ def test_list_per_instance_configs_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.list_per_instance_configs(request) @@ -5234,6 +5271,7 @@ def test_list_per_instance_configs_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_per_instance_configs(**mock_args) @@ -5450,6 +5488,7 @@ def test_patch_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.patch(request) @@ -5518,6 +5557,7 @@ def test_patch_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.patch(**mock_args) @@ -5673,6 +5713,7 @@ def test_patch_unary_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.patch_unary(request) @@ -5741,6 +5782,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -5901,6 +5943,7 @@ def test_patch_per_instance_configs_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.patch_per_instance_configs(request) @@ -5967,6 +6010,7 @@ def test_patch_per_instance_configs_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.patch_per_instance_configs(**mock_args) @@ -6125,6 +6169,7 @@ def test_patch_per_instance_configs_unary_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.patch_per_instance_configs_unary(request) @@ -6191,6 +6236,7 @@ def test_patch_per_instance_configs_unary_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.patch_per_instance_configs_unary(**mock_args) @@ -6348,6 +6394,7 @@ def test_recreate_instances_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.recreate_instances(request) @@ -6412,6 +6459,7 @@ def test_recreate_instances_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.recreate_instances(**mock_args) @@ -6567,6 +6615,7 @@ def test_recreate_instances_unary_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.recreate_instances_unary(request) @@ -6631,6 +6680,7 @@ def test_recreate_instances_unary_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.recreate_instances_unary(**mock_args) @@ -6793,6 +6843,7 @@ def test_resize_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.resize(request) @@ -6865,6 +6916,7 @@ def test_resize_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.resize(**mock_args) @@ -7025,6 +7077,7 @@ def test_resize_unary_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.resize_unary(request) @@ -7097,6 +7150,7 @@ def test_resize_unary_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.resize_unary(**mock_args) @@ -7129,7 +7183,7 @@ def test_resize_unary_rest_flattened_error(transport: str = "rest"): ) -def test_set_instance_template_rest_use_cached_wrapped_rpc(): +def test_resume_instances_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7143,10 +7197,7 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.set_instance_template - in client._transport._wrapped_methods - ) + assert client._transport.resume_instances in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7154,11 +7205,11 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_instance_template + client._transport.resume_instances ] = mock_rpc request = {} - client.set_instance_template(request) + client.resume_instances(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7167,15 +7218,15 @@ def test_set_instance_template_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_instance_template(request) + client.resume_instances(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_instance_template_rest_required_fields( - request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, +def test_resume_instances_rest_required_fields( + request_type=compute.ResumeInstancesRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -7193,7 +7244,7 @@ def test_set_instance_template_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7204,7 +7255,7 @@ def test_set_instance_template_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7251,20 +7302,21 @@ def test_set_instance_template_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_instance_template(request) + response = client.resume_instances(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_instance_template_rest_unset_required_fields(): +def test_resume_instances_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_instance_template._get_unset_required_fields({}) + unset_fields = transport.resume_instances._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -7272,13 +7324,13 @@ def test_set_instance_template_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagersSetTemplateRequestResource", + "regionInstanceGroupManagersResumeInstancesRequestResource", ) ) ) -def test_set_instance_template_rest_flattened(): +def test_resume_instances_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7301,8 +7353,8 @@ def test_set_instance_template_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( - instance_template="instance_template_value" + region_instance_group_managers_resume_instances_request_resource=compute.RegionInstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) mock_args.update(sample_request) @@ -7315,21 +7367,22 @@ def test_set_instance_template_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_instance_template(**mock_args) + client.resume_instances(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/resumeInstances" % client.transport._host, args[1], ) -def test_set_instance_template_rest_flattened_error(transport: str = "rest"): +def test_resume_instances_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7338,18 +7391,18 @@ def test_set_instance_template_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_instance_template( - compute.SetInstanceTemplateRegionInstanceGroupManagerRequest(), + client.resume_instances( + compute.ResumeInstancesRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( - instance_template="instance_template_value" + region_instance_group_managers_resume_instances_request_resource=compute.RegionInstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) -def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): +def test_resume_instances_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7363,10 +7416,7 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.set_instance_template - in client._transport._wrapped_methods - ) + assert client._transport.resume_instances in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7374,11 +7424,11 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_instance_template + client._transport.resume_instances ] = mock_rpc request = {} - client.set_instance_template_unary(request) + client.resume_instances_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7387,15 +7437,15 @@ def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_instance_template_unary(request) + client.resume_instances_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_instance_template_unary_rest_required_fields( - request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, +def test_resume_instances_unary_rest_required_fields( + request_type=compute.ResumeInstancesRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -7413,7 +7463,7 @@ def test_set_instance_template_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7424,7 +7474,7 @@ def test_set_instance_template_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_instance_template._get_unset_required_fields(jsonified_request) + ).resume_instances._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7471,20 +7521,21 @@ def test_set_instance_template_unary_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_instance_template_unary(request) + response = client.resume_instances_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_instance_template_unary_rest_unset_required_fields(): +def test_resume_instances_unary_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_instance_template._get_unset_required_fields({}) + unset_fields = transport.resume_instances._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -7492,13 +7543,13 @@ def test_set_instance_template_unary_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagersSetTemplateRequestResource", + "regionInstanceGroupManagersResumeInstancesRequestResource", ) ) ) -def test_set_instance_template_unary_rest_flattened(): +def test_resume_instances_unary_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7521,8 +7572,8 @@ def test_set_instance_template_unary_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( - instance_template="instance_template_value" + region_instance_group_managers_resume_instances_request_resource=compute.RegionInstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) mock_args.update(sample_request) @@ -7535,21 +7586,22 @@ def test_set_instance_template_unary_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_instance_template_unary(**mock_args) + client.resume_instances_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/resumeInstances" % client.transport._host, args[1], ) -def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest"): +def test_resume_instances_unary_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7558,18 +7610,18 @@ def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_instance_template_unary( - compute.SetInstanceTemplateRegionInstanceGroupManagerRequest(), + client.resume_instances_unary( + compute.ResumeInstancesRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( - instance_template="instance_template_value" + region_instance_group_managers_resume_instances_request_resource=compute.RegionInstanceGroupManagersResumeInstancesRequest( + instances=["instances_value"] ), ) -def test_set_target_pools_rest_use_cached_wrapped_rpc(): +def test_set_instance_template_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7583,7 +7635,10 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_target_pools in client._transport._wrapped_methods + assert ( + client._transport.set_instance_template + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7591,11 +7646,11 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_target_pools + client._transport.set_instance_template ] = mock_rpc request = {} - client.set_target_pools(request) + client.set_instance_template(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7604,15 +7659,15 @@ def test_set_target_pools_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_target_pools(request) + client.set_instance_template(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_target_pools_rest_required_fields( - request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, +def test_set_instance_template_rest_required_fields( + request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -7630,7 +7685,7 @@ def test_set_target_pools_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7641,7 +7696,7 @@ def test_set_target_pools_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7688,20 +7743,21 @@ def test_set_target_pools_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_target_pools(request) + response = client.set_instance_template(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_target_pools_rest_unset_required_fields(): +def test_set_instance_template_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_target_pools._get_unset_required_fields({}) + unset_fields = transport.set_instance_template._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -7709,13 +7765,13 @@ def test_set_target_pools_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagersSetTargetPoolsRequestResource", + "regionInstanceGroupManagersSetTemplateRequestResource", ) ) ) -def test_set_target_pools_rest_flattened(): +def test_set_instance_template_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7738,8 +7794,8 @@ def test_set_target_pools_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( + instance_template="instance_template_value" ), ) mock_args.update(sample_request) @@ -7752,21 +7808,22 @@ def test_set_target_pools_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_target_pools(**mock_args) + client.set_instance_template(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" % client.transport._host, args[1], ) -def test_set_target_pools_rest_flattened_error(transport: str = "rest"): +def test_set_instance_template_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7775,18 +7832,18 @@ def test_set_target_pools_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_target_pools( - compute.SetTargetPoolsRegionInstanceGroupManagerRequest(), + client.set_instance_template( + compute.SetInstanceTemplateRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( + instance_template="instance_template_value" ), ) -def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): +def test_set_instance_template_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7800,7 +7857,10 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_target_pools in client._transport._wrapped_methods + assert ( + client._transport.set_instance_template + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -7808,11 +7868,11 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.set_target_pools + client._transport.set_instance_template ] = mock_rpc request = {} - client.set_target_pools_unary(request) + client.set_instance_template_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -7821,15 +7881,15 @@ def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.set_target_pools_unary(request) + client.set_instance_template_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_target_pools_unary_rest_required_fields( - request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, +def test_set_instance_template_unary_rest_required_fields( + request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -7847,7 +7907,7 @@ def test_set_target_pools_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -7858,7 +7918,7 @@ def test_set_target_pools_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_target_pools._get_unset_required_fields(jsonified_request) + ).set_instance_template._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -7905,20 +7965,21 @@ def test_set_target_pools_unary_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_target_pools_unary(request) + response = client.set_instance_template_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_target_pools_unary_rest_unset_required_fields(): +def test_set_instance_template_unary_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_target_pools._get_unset_required_fields({}) + unset_fields = transport.set_instance_template._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -7926,13 +7987,13 @@ def test_set_target_pools_unary_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagersSetTargetPoolsRequestResource", + "regionInstanceGroupManagersSetTemplateRequestResource", ) ) ) -def test_set_target_pools_unary_rest_flattened(): +def test_set_instance_template_unary_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -7955,8 +8016,8 @@ def test_set_target_pools_unary_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( + instance_template="instance_template_value" ), ) mock_args.update(sample_request) @@ -7969,21 +8030,22 @@ def test_set_target_pools_unary_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_target_pools_unary(**mock_args) + client.set_instance_template_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setTargetPools" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setInstanceTemplate" % client.transport._host, args[1], ) -def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): +def test_set_instance_template_unary_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7992,18 +8054,18 @@ def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_target_pools_unary( - compute.SetTargetPoolsRegionInstanceGroupManagerRequest(), + client.set_instance_template_unary( + compute.SetInstanceTemplateRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( - fingerprint="fingerprint_value" + region_instance_group_managers_set_template_request_resource=compute.RegionInstanceGroupManagersSetTemplateRequest( + instance_template="instance_template_value" ), ) -def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): +def test_set_target_pools_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8017,10 +8079,7 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_per_instance_configs - in client._transport._wrapped_methods - ) + assert client._transport.set_target_pools in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -8028,11 +8087,11 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_per_instance_configs + client._transport.set_target_pools ] = mock_rpc request = {} - client.update_per_instance_configs(request) + client.set_target_pools(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -8041,15 +8100,15 @@ def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_per_instance_configs(request) + client.set_target_pools(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_per_instance_configs_rest_required_fields( - request_type=compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, +def test_set_target_pools_rest_required_fields( + request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -8067,7 +8126,7 @@ def test_update_per_instance_configs_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -8078,7 +8137,7 @@ def test_update_per_instance_configs_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -8125,20 +8184,21 @@ def test_update_per_instance_configs_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.update_per_instance_configs(request) + response = client.set_target_pools(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_per_instance_configs_rest_unset_required_fields(): +def test_set_target_pools_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + unset_fields = transport.set_target_pools._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -8146,13 +8206,13 @@ def test_update_per_instance_configs_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagerUpdateInstanceConfigReqResource", + "regionInstanceGroupManagersSetTargetPoolsRequestResource", ) ) ) -def test_update_per_instance_configs_rest_flattened(): +def test_set_target_pools_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -8175,10 +8235,8 @@ def test_update_per_instance_configs_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) mock_args.update(sample_request) @@ -8191,21 +8249,22 @@ def test_update_per_instance_configs_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_per_instance_configs(**mock_args) + client.set_target_pools(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setTargetPools" % client.transport._host, args[1], ) -def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest"): +def test_set_target_pools_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8214,20 +8273,18 @@ def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_per_instance_configs( - compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest(), + client.set_target_pools( + compute.SetTargetPoolsRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) -def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): +def test_set_target_pools_unary_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -8241,10 +8298,7 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_per_instance_configs - in client._transport._wrapped_methods - ) + assert client._transport.set_target_pools in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -8252,11 +8306,11 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_per_instance_configs + client._transport.set_target_pools ] = mock_rpc request = {} - client.update_per_instance_configs_unary(request) + client.set_target_pools_unary(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -8265,15 +8319,15 @@ def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): # subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.update_per_instance_configs_unary(request) + client.set_target_pools_unary(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_per_instance_configs_unary_rest_required_fields( - request_type=compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, +def test_set_target_pools_unary_rest_required_fields( + request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, ): transport_class = transports.RegionInstanceGroupManagersRestTransport @@ -8291,7 +8345,7 @@ def test_update_per_instance_configs_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -8302,7 +8356,7 @@ def test_update_per_instance_configs_unary_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + ).set_target_pools._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set(("request_id",)) jsonified_request.update(unset_fields) @@ -8349,20 +8403,21 @@ def test_update_per_instance_configs_unary_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.update_per_instance_configs_unary(request) + response = client.set_target_pools_unary(request) expected_params = [] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_update_per_instance_configs_unary_rest_unset_required_fields(): +def test_set_target_pools_unary_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + unset_fields = transport.set_target_pools._get_unset_required_fields({}) assert set(unset_fields) == ( set(("requestId",)) & set( @@ -8370,13 +8425,13 @@ def test_update_per_instance_configs_unary_rest_unset_required_fields(): "instanceGroupManager", "project", "region", - "regionInstanceGroupManagerUpdateInstanceConfigReqResource", + "regionInstanceGroupManagersSetTargetPoolsRequestResource", ) ) ) -def test_update_per_instance_configs_unary_rest_flattened(): +def test_set_target_pools_unary_rest_flattened(): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -8399,10 +8454,8 @@ def test_update_per_instance_configs_unary_rest_flattened(): project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) mock_args.update(sample_request) @@ -8415,23 +8468,22 @@ def test_update_per_instance_configs_unary_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_per_instance_configs_unary(**mock_args) + client.set_target_pools_unary(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/setTargetPools" % client.transport._host, args[1], ) -def test_update_per_instance_configs_unary_rest_flattened_error( - transport: str = "rest", -): +def test_set_target_pools_unary_rest_flattened_error(transport: str = "rest"): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -8440,103 +8492,2825 @@ def test_update_per_instance_configs_unary_rest_flattened_error( # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_per_instance_configs_unary( - compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest(), + client.set_target_pools_unary( + compute.SetTargetPoolsRegionInstanceGroupManagerRequest(), project="project_value", region="region_value", instance_group_manager="instance_group_manager_value", - region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( - per_instance_configs=[ - compute.PerInstanceConfig(fingerprint="fingerprint_value") - ] + region_instance_group_managers_set_target_pools_request_resource=compute.RegionInstanceGroupManagersSetTargetPoolsRequest( + fingerprint="fingerprint_value" ), ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.RegionInstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): +def test_start_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.RegionInstanceGroupManagersRestTransport( + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.start_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.start_instances] = mock_rpc + + request = {} + client.start_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.start_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_start_instances_rest_required_fields( + request_type=compute.StartInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - with pytest.raises(ValueError): - client = RegionInstanceGroupManagersClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) + request = request_type(**request_init) - # It is an error to provide an api_key and a transport instance. + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_start_instances_rest_unset_required_fields(): transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.start_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersStartInstancesRequestResource", + ) + ) + ) + + +def test_start_instances_rest_flattened(): + client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = RegionInstanceGroupManagersClient( - client_options=options, - transport=transport, + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_start_instances_request_resource=compute.RegionInstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), ) + mock_args.update(sample_request) - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = RegionInstanceGroupManagersClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/startInstances" + % client.transport._host, + args[1], ) - # It is an error to provide scopes and a transport instance. - transport = transports.RegionInstanceGroupManagersRestTransport( + +def test_start_instances_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. with pytest.raises(ValueError): + client.start_instances( + compute.StartInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_start_instances_request_resource=compute.RegionInstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + + +def test_start_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = RegionInstanceGroupManagersClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.RegionInstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = RegionInstanceGroupManagersClient(transport=transport) - assert client.transport is transport + # Ensure method has been cached + assert client._transport.start_instances in client._transport._wrapped_methods + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.start_instances] = mock_rpc -@pytest.mark.parametrize( - "transport_class", - [ - transports.RegionInstanceGroupManagersRestTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + request = {} + client.start_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.start_instances_unary(request) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_start_instances_unary_rest_required_fields( + request_type=compute.StartInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).start_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_start_instances_unary_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.start_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersStartInstancesRequestResource", + ) + ) + ) + + +def test_start_instances_unary_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_start_instances_request_resource=compute.RegionInstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.start_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/startInstances" + % client.transport._host, + args[1], + ) + + +def test_start_instances_unary_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.start_instances_unary( + compute.StartInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_start_instances_request_resource=compute.RegionInstanceGroupManagersStartInstancesRequest( + instances=["instances_value"] + ), + ) + + +def test_stop_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.stop_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.stop_instances] = mock_rpc + + request = {} + client.stop_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.stop_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_stop_instances_rest_required_fields( + request_type=compute.StopInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_stop_instances_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.stop_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersStopInstancesRequestResource", + ) + ) + ) + + +def test_stop_instances_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_stop_instances_request_resource=compute.RegionInstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/stopInstances" + % client.transport._host, + args[1], + ) + + +def test_stop_instances_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_instances( + compute.StopInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_stop_instances_request_resource=compute.RegionInstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + + +def test_stop_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.stop_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.stop_instances] = mock_rpc + + request = {} + client.stop_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.stop_instances_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_stop_instances_unary_rest_required_fields( + request_type=compute.StopInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).stop_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_stop_instances_unary_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.stop_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersStopInstancesRequestResource", + ) + ) + ) + + +def test_stop_instances_unary_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_stop_instances_request_resource=compute.RegionInstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.stop_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/stopInstances" + % client.transport._host, + args[1], + ) + + +def test_stop_instances_unary_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.stop_instances_unary( + compute.StopInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_stop_instances_request_resource=compute.RegionInstanceGroupManagersStopInstancesRequest( + force_stop=True + ), + ) + + +def test_suspend_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.suspend_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.suspend_instances + ] = mock_rpc + + request = {} + client.suspend_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.suspend_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_suspend_instances_rest_required_fields( + request_type=compute.SuspendInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_suspend_instances_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.suspend_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersSuspendInstancesRequestResource", + ) + ) + ) + + +def test_suspend_instances_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_suspend_instances_request_resource=compute.RegionInstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/suspendInstances" + % client.transport._host, + args[1], + ) + + +def test_suspend_instances_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.suspend_instances( + compute.SuspendInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_suspend_instances_request_resource=compute.RegionInstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + + +def test_suspend_instances_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.suspend_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.suspend_instances + ] = mock_rpc + + request = {} + client.suspend_instances_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.suspend_instances_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_suspend_instances_unary_rest_required_fields( + request_type=compute.SuspendInstancesRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).suspend_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_suspend_instances_unary_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.suspend_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagersSuspendInstancesRequestResource", + ) + ) + ) + + +def test_suspend_instances_unary_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_suspend_instances_request_resource=compute.RegionInstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.suspend_instances_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/suspendInstances" + % client.transport._host, + args[1], + ) + + +def test_suspend_instances_unary_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.suspend_instances_unary( + compute.SuspendInstancesRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_managers_suspend_instances_request_resource=compute.RegionInstanceGroupManagersSuspendInstancesRequest( + force_suspend=True + ), + ) + + +def test_update_per_instance_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_per_instance_configs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_per_instance_configs + ] = mock_rpc + + request = {} + client.update_per_instance_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_per_instance_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_per_instance_configs_rest_required_fields( + request_type=compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_per_instance_configs_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagerUpdateInstanceConfigReqResource", + ) + ) + ) + + +def test_update_per_instance_configs_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_update_per_instance_configs_rest_flattened_error(transport: str = "rest"): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_per_instance_configs( + compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + + +def test_update_per_instance_configs_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_per_instance_configs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_per_instance_configs + ] = mock_rpc + + request = {} + client.update_per_instance_configs_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_per_instance_configs_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_per_instance_configs_unary_rest_required_fields( + request_type=compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, +): + transport_class = transports.RegionInstanceGroupManagersRestTransport + + request_init = {} + request_init["instance_group_manager"] = "" + request_init["project"] = "" + request_init["region"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["instanceGroupManager"] = "instance_group_manager_value" + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_per_instance_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "instanceGroupManager" in jsonified_request + assert jsonified_request["instanceGroupManager"] == "instance_group_manager_value" + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_per_instance_configs_unary_rest_unset_required_fields(): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_per_instance_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "instanceGroupManager", + "project", + "region", + "regionInstanceGroupManagerUpdateInstanceConfigReqResource", + ) + ) + ) + + +def test_update_per_instance_configs_unary_rest_flattened(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_per_instance_configs_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/instanceGroupManagers/{instance_group_manager}/updatePerInstanceConfigs" + % client.transport._host, + args[1], + ) + + +def test_update_per_instance_configs_unary_rest_flattened_error( + transport: str = "rest", +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_per_instance_configs_unary( + compute.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest(), + project="project_value", + region="region_value", + instance_group_manager="instance_group_manager_value", + region_instance_group_manager_update_instance_config_req_resource=compute.RegionInstanceGroupManagerUpdateInstanceConfigReq( + per_instance_configs=[ + compute.PerInstanceConfig(fingerprint="fingerprint_value") + ] + ), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = RegionInstanceGroupManagersClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = RegionInstanceGroupManagersClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = RegionInstanceGroupManagersClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = RegionInstanceGroupManagersClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + assert client.transport is transport + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.RegionInstanceGroupManagersRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_rest(): + transport = RegionInstanceGroupManagersClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_abandon_instances_rest_bad_request( + request_type=compute.AbandonInstancesRegionInstanceGroupManagerRequest, +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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.abandon_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.AbandonInstancesRegionInstanceGroupManagerRequest, + dict, + ], +) +def test_abandon_instances_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request_init[ + "region_instance_group_managers_abandon_instances_request_resource" + ] = {"instances": ["instances_value1", "instances_value2"]} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.AbandonInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_abandon_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_managers_abandon_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_managers_abandon_instances_request_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_managers_abandon_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_managers_abandon_instances_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.abandon_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_abandon_instances_rest_interceptors(null_interceptor): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionInstanceGroupManagersRestInterceptor(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "post_abandon_instances" + ) as post, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "pre_abandon_instances" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.AbandonInstancesRegionInstanceGroupManagerRequest.pb( + compute.AbandonInstancesRegionInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.AbandonInstancesRegionInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.abandon_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_apply_updates_to_instances_rest_bad_request( + request_type=compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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.apply_updates_to_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + dict, + ], +) +def test_apply_updates_to_instances_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request_init["region_instance_group_managers_apply_updates_request_resource"] = { + "all_instances": True, + "instances": ["instances_value1", "instances_value2"], + "minimal_action": "minimal_action_value", + "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = ( + compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_apply_updates_request_resource" + ] + ) + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_managers_apply_updates_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_managers_apply_updates_request_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_managers_apply_updates_request_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_managers_apply_updates_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.apply_updates_to_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_apply_updates_to_instances_rest_interceptors(null_interceptor): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionInstanceGroupManagersRestInterceptor(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, + "post_apply_updates_to_instances", + ) as post, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, + "pre_apply_updates_to_instances", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = ( + compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest.pb( + compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + ) + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.apply_updates_to_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_instances_rest_bad_request( + request_type=compute.CreateInstancesRegionInstanceGroupManagerRequest, +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.CreateInstancesRegionInstanceGroupManagerRequest, + dict, + ], +) +def test_create_instances_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request_init["region_instance_group_managers_create_instances_request_resource"] = { + "instances": [ + { + "fingerprint": "fingerprint_value", + "name": "name_value", + "preserved_state": { + "disks": {}, + "external_i_ps": {}, + "internal_i_ps": {}, + "metadata": {}, + }, + "status": "status_value", + } + ] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.CreateInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_create_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_managers_create_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_managers_create_instances_request_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_managers_create_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_managers_create_instances_request_resource" + ][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_instances_rest_interceptors(null_interceptor): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionInstanceGroupManagersRestInterceptor(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "post_create_instances" + ) as post, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "pre_create_instances" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.CreateInstancesRegionInstanceGroupManagerRequest.pb( + compute.CreateInstancesRegionInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.CreateInstancesRegionInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.create_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_rest_bad_request( + request_type=compute.DeleteRegionInstanceGroupManagerRequest, +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.DeleteRegionInstanceGroupManagerRequest, + dict, + ], +) +def test_delete_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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.delete(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_rest_interceptors(null_interceptor): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionInstanceGroupManagersRestInterceptor(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "post_delete" + ) as post, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, "pre_delete" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.DeleteRegionInstanceGroupManagerRequest.pb( + compute.DeleteRegionInstanceGroupManagerRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.DeleteRegionInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.delete( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_rest(): - transport = RegionInstanceGroupManagersClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + pre.assert_called_once() + post.assert_called_once() -def test_abandon_instances_rest_bad_request( - request_type=compute.AbandonInstancesRegionInstanceGroupManagerRequest, +def test_delete_instances_rest_bad_request( + request_type=compute.DeleteInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8560,17 +11334,18 @@ def test_abandon_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.abandon_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.AbandonInstancesRegionInstanceGroupManagerRequest, + compute.DeleteInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_abandon_instances_rest_call_success(request_type): +def test_delete_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -8581,16 +11356,17 @@ def test_abandon_instances_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init[ - "region_instance_group_managers_abandon_instances_request_resource" - ] = {"instances": ["instances_value1", "instances_value2"]} + request_init["region_instance_group_managers_delete_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"], + "skip_instances_on_validation_error": True, + } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.AbandonInstancesRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_abandon_instances_request_resource" + test_field = compute.DeleteInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_delete_instances_request_resource" ] def get_message_fields(field): @@ -8620,7 +11396,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_abandon_instances_request_resource" + "region_instance_group_managers_delete_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -8655,16 +11431,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_managers_abandon_instances_request_resource" + "region_instance_group_managers_delete_instances_request_resource" ][field] ), ): del request_init[ - "region_instance_group_managers_abandon_instances_request_resource" + "region_instance_group_managers_delete_instances_request_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_managers_abandon_instances_request_resource" + "region_instance_group_managers_delete_instances_request_resource" ][field][subfield] request = request_type(**request_init) @@ -8705,7 +11481,8 @@ 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 - response = client.abandon_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -8734,7 +11511,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_abandon_instances_rest_interceptors(null_interceptor): +def test_delete_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -8748,14 +11525,14 @@ def test_abandon_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_abandon_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "post_delete_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_abandon_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_delete_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.AbandonInstancesRegionInstanceGroupManagerRequest.pb( - compute.AbandonInstancesRegionInstanceGroupManagerRequest() + pb_message = compute.DeleteInstancesRegionInstanceGroupManagerRequest.pb( + compute.DeleteInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -8766,10 +11543,11 @@ def test_abandon_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.AbandonInstancesRegionInstanceGroupManagerRequest() + request = compute.DeleteInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -8777,7 +11555,7 @@ def test_abandon_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.abandon_instances( + client.delete_instances( request, metadata=[ ("key", "val"), @@ -8789,8 +11567,8 @@ def test_abandon_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_apply_updates_to_instances_rest_bad_request( - request_type=compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, +def test_delete_per_instance_configs_rest_bad_request( + request_type=compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8814,17 +11592,18 @@ def test_apply_updates_to_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.apply_updates_to_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, + compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, dict, ], ) -def test_apply_updates_to_instances_rest_call_success(request_type): +def test_delete_per_instance_configs_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -8835,20 +11614,17 @@ def test_apply_updates_to_instances_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_managers_apply_updates_request_resource"] = { - "all_instances": True, - "instances": ["instances_value1", "instances_value2"], - "minimal_action": "minimal_action_value", - "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", - } + request_init[ + "region_instance_group_manager_delete_instance_config_req_resource" + ] = {"names": ["names_value1", "names_value2"]} # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf test_field = ( - compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_apply_updates_request_resource" + compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_manager_delete_instance_config_req_resource" ] ) @@ -8879,7 +11655,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_apply_updates_request_resource" + "region_instance_group_manager_delete_instance_config_req_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -8914,16 +11690,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_managers_apply_updates_request_resource" + "region_instance_group_manager_delete_instance_config_req_resource" ][field] ), ): del request_init[ - "region_instance_group_managers_apply_updates_request_resource" + "region_instance_group_manager_delete_instance_config_req_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_managers_apply_updates_request_resource" + "region_instance_group_manager_delete_instance_config_req_resource" ][field][subfield] request = request_type(**request_init) @@ -8964,7 +11740,8 @@ 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 - response = client.apply_updates_to_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_per_instance_configs(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -8993,7 +11770,180 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_apply_updates_to_instances_rest_interceptors(null_interceptor): +def test_delete_per_instance_configs_rest_interceptors(null_interceptor): + transport = transports.RegionInstanceGroupManagersRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionInstanceGroupManagersRestInterceptor(), + ) + client = RegionInstanceGroupManagersClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, + "post_delete_per_instance_configs", + ) as post, mock.patch.object( + transports.RegionInstanceGroupManagersRestInterceptor, + "pre_delete_per_instance_configs", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = ( + compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest.pb( + compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + ) + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.delete_per_instance_configs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_rest_bad_request( + request_type=compute.GetRegionInstanceGroupManagerRequest, +): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.GetRegionInstanceGroupManagerRequest, + dict, + ], +) +def test_get_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.InstanceGroupManager( + base_instance_name="base_instance_name_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + fingerprint="fingerprint_value", + id=205, + instance_group="instance_group_value", + instance_template="instance_template_value", + kind="kind_value", + list_managed_instances_results="list_managed_instances_results_value", + name="name_value", + region="region_value", + satisfies_pzi=True, + satisfies_pzs=True, + self_link="self_link_value", + target_pools=["target_pools_value"], + target_size=1185, + target_stopped_size=2047, + target_suspended_size=2251, + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.InstanceGroupManager.pb(return_value) + 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(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, compute.InstanceGroupManager) + assert response.base_instance_name == "base_instance_name_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.fingerprint == "fingerprint_value" + assert response.id == 205 + assert response.instance_group == "instance_group_value" + assert response.instance_template == "instance_template_value" + assert response.kind == "kind_value" + assert ( + response.list_managed_instances_results + == "list_managed_instances_results_value" + ) + assert response.name == "name_value" + assert response.region == "region_value" + assert response.satisfies_pzi is True + assert response.satisfies_pzs is True + assert response.self_link == "self_link_value" + assert response.target_pools == ["target_pools_value"] + assert response.target_size == 1185 + assert response.target_stopped_size == 2047 + assert response.target_suspended_size == 2251 + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9007,18 +11957,14 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "post_apply_updates_to_instances", + transports.RegionInstanceGroupManagersRestInterceptor, "post_get" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "pre_apply_updates_to_instances", + transports.RegionInstanceGroupManagersRestInterceptor, "pre_get" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest.pb( - compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() - ) + pb_message = compute.GetRegionInstanceGroupManagerRequest.pb( + compute.GetRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9029,18 +11975,21 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.InstanceGroupManager.to_json( + compute.InstanceGroupManager() + ) req.return_value.content = return_value - request = compute.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest() + request = compute.GetRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.InstanceGroupManager() - client.apply_updates_to_instances( + client.get( request, metadata=[ ("key", "val"), @@ -9052,18 +12001,14 @@ def test_apply_updates_to_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_instances_rest_bad_request( - request_type=compute.CreateInstancesRegionInstanceGroupManagerRequest, +def test_insert_rest_bad_request( + request_type=compute.InsertRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "region": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "region": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9077,49 +12022,114 @@ def test_create_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.insert(request) @pytest.mark.parametrize( "request_type", [ - compute.CreateInstancesRegionInstanceGroupManagerRequest, + compute.InsertRegionInstanceGroupManagerRequest, dict, ], ) -def test_create_instances_rest_call_success(request_type): +def test_insert_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "region": "sample2", - "instance_group_manager": "sample3", - } - request_init["region_instance_group_managers_create_instances_request_resource"] = { - "instances": [ + request_init = {"project": "sample1", "region": "sample2"} + request_init["instance_group_manager_resource"] = { + "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, + "auto_healing_policies": [ + {"health_check": "health_check_value", "initial_delay_sec": 1778} + ], + "base_instance_name": "base_instance_name_value", + "creation_timestamp": "creation_timestamp_value", + "current_actions": { + "abandoning": 1041, + "creating": 845, + "creating_without_retries": 2589, + "deleting": 844, + "none": 432, + "recreating": 1060, + "refreshing": 1069, + "restarting": 1091, + "resuming": 874, + "starting": 876, + "stopping": 884, + "suspending": 1088, + "verifying": 979, + }, + "description": "description_value", + "distribution_policy": { + "target_shape": "target_shape_value", + "zones": [{"zone": "zone_value"}], + }, + "fingerprint": "fingerprint_value", + "id": 205, + "instance_flexibility_policy": {"instance_selections": {}}, + "instance_group": "instance_group_value", + "instance_lifecycle_policy": { + "default_action_on_failure": "default_action_on_failure_value", + "force_update_on_repair": "force_update_on_repair_value", + }, + "instance_template": "instance_template_value", + "kind": "kind_value", + "list_managed_instances_results": "list_managed_instances_results_value", + "name": "name_value", + "named_ports": [{"name": "name_value", "port": 453}], + "region": "region_value", + "satisfies_pzi": True, + "satisfies_pzs": True, + "self_link": "self_link_value", + "standby_policy": {"initial_delay_sec": 1778, "mode": "mode_value"}, + "stateful_policy": { + "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} + }, + "status": { + "all_instances_config": { + "current_revision": "current_revision_value", + "effective": True, + }, + "autoscaler": "autoscaler_value", + "is_stable": True, + "stateful": { + "has_stateful_config": True, + "per_instance_configs": {"all_effective": True}, + }, + "version_target": {"is_reached": True}, + }, + "target_pools": ["target_pools_value1", "target_pools_value2"], + "target_size": 1185, + "target_stopped_size": 2047, + "target_suspended_size": 2251, + "update_policy": { + "instance_redistribution_type": "instance_redistribution_type_value", + "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, + "max_unavailable": {}, + "minimal_action": "minimal_action_value", + "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", + "replacement_method": "replacement_method_value", + "type_": "type__value", + }, + "versions": [ { - "fingerprint": "fingerprint_value", + "instance_template": "instance_template_value", "name": "name_value", - "preserved_state": { - "disks": {}, - "external_i_ps": {}, - "internal_i_ps": {}, - "metadata": {}, - }, - "status": "status_value", + "target_size": {}, } - ] + ], + "zone": "zone_value", } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.CreateInstancesRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_create_instances_request_resource" + test_field = compute.InsertRegionInstanceGroupManagerRequest.meta.fields[ + "instance_group_manager_resource" ] def get_message_fields(field): @@ -9149,7 +12159,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_create_instances_request_resource" + "instance_group_manager_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -9181,20 +12191,13 @@ def get_message_fields(field): if subfield: if field_repeated: for i in range( - 0, - len( - request_init[ - "region_instance_group_managers_create_instances_request_resource" - ][field] - ), + 0, len(request_init["instance_group_manager_resource"][field]) ): - del request_init[ - "region_instance_group_managers_create_instances_request_resource" - ][field][i][subfield] + del request_init["instance_group_manager_resource"][field][i][ + subfield + ] else: - del request_init[ - "region_instance_group_managers_create_instances_request_resource" - ][field][subfield] + del request_init["instance_group_manager_resource"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9234,7 +12237,8 @@ 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 - response = client.create_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.insert(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -9263,7 +12267,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_instances_rest_interceptors(null_interceptor): +def test_insert_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9277,14 +12281,14 @@ def test_create_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_create_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "post_insert" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_create_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_insert" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.CreateInstancesRegionInstanceGroupManagerRequest.pb( - compute.CreateInstancesRegionInstanceGroupManagerRequest() + pb_message = compute.InsertRegionInstanceGroupManagerRequest.pb( + compute.InsertRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -9295,10 +12299,11 @@ def test_create_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.CreateInstancesRegionInstanceGroupManagerRequest() + request = compute.InsertRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -9306,7 +12311,7 @@ def test_create_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.create_instances( + client.insert( request, metadata=[ ("key", "val"), @@ -9318,18 +12323,14 @@ def test_create_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_rest_bad_request( - request_type=compute.DeleteRegionInstanceGroupManagerRequest, +def test_list_rest_bad_request( + request_type=compute.ListRegionInstanceGroupManagersRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "region": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "region": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9343,55 +12344,34 @@ def test_delete_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list(request) @pytest.mark.parametrize( "request_type", [ - compute.DeleteRegionInstanceGroupManagerRequest, + compute.ListRegionInstanceGroupManagersRequest, dict, ], ) -def test_delete_rest_call_success(request_type): +def test_list_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "region": "sample2", - "instance_group_manager": "sample3", - } + request_init = {"project": "sample1", "region": "sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", + return_value = compute.RegionInstanceGroupManagerList( + id="id_value", kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", + next_page_token="next_page_token_value", self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", ) # Wrap the value into a proper Response obj @@ -9399,40 +12379,23 @@ def test_delete_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.RegionInstanceGroupManagerList.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" + assert isinstance(response, pagers.ListPager) + assert response.id == "id_value" assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" + assert response.next_page_token == "next_page_token_value" assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_rest_interceptors(null_interceptor): +def test_list_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9446,14 +12409,14 @@ def test_delete_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_delete" + transports.RegionInstanceGroupManagersRestInterceptor, "post_list" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_delete" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_list" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = compute.DeleteRegionInstanceGroupManagerRequest.pb( - compute.DeleteRegionInstanceGroupManagerRequest() + post.assert_not_called() + pb_message = compute.ListRegionInstanceGroupManagersRequest.pb( + compute.ListRegionInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -9464,18 +12427,21 @@ def test_delete_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.RegionInstanceGroupManagerList.to_json( + compute.RegionInstanceGroupManagerList() + ) req.return_value.content = return_value - request = compute.DeleteRegionInstanceGroupManagerRequest() + request = compute.ListRegionInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.RegionInstanceGroupManagerList() - client.delete( + client.list( request, metadata=[ ("key", "val"), @@ -9487,8 +12453,8 @@ def test_delete_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_instances_rest_bad_request( - request_type=compute.DeleteInstancesRegionInstanceGroupManagerRequest, +def test_list_errors_rest_bad_request( + request_type=compute.ListErrorsRegionInstanceGroupManagersRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -9512,17 +12478,18 @@ def test_delete_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_errors(request) @pytest.mark.parametrize( "request_type", [ - compute.DeleteInstancesRegionInstanceGroupManagerRequest, + compute.ListErrorsRegionInstanceGroupManagersRequest, dict, ], ) -def test_delete_instances_rest_call_success(request_type): +def test_list_errors_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -9533,120 +12500,13 @@ def test_delete_instances_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_managers_delete_instances_request_resource"] = { - "instances": ["instances_value1", "instances_value2"], - "skip_instances_on_validation_error": True, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = compute.DeleteInstancesRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_delete_instances_request_resource" - ] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "region_instance_group_managers_delete_instances_request_resource" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range( - 0, - len( - request_init[ - "region_instance_group_managers_delete_instances_request_resource" - ][field] - ), - ): - del request_init[ - "region_instance_group_managers_delete_instances_request_resource" - ][field][i][subfield] - else: - del request_init[ - "region_instance_group_managers_delete_instances_request_resource" - ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", - kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", - self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", + return_value = compute.RegionInstanceGroupManagersListErrorsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -9654,40 +12514,22 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.RegionInstanceGroupManagersListErrorsResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_errors(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" - assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" - assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListErrorsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_instances_rest_interceptors(null_interceptor): +def test_list_errors_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9701,14 +12543,14 @@ def test_delete_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_delete_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "post_list_errors" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_delete_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_list_errors" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.DeleteInstancesRegionInstanceGroupManagerRequest.pb( - compute.DeleteInstancesRegionInstanceGroupManagerRequest() + pb_message = compute.ListErrorsRegionInstanceGroupManagersRequest.pb( + compute.ListErrorsRegionInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -9719,18 +12561,21 @@ def test_delete_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.RegionInstanceGroupManagersListErrorsResponse.to_json( + compute.RegionInstanceGroupManagersListErrorsResponse() + ) req.return_value.content = return_value - request = compute.DeleteInstancesRegionInstanceGroupManagerRequest() + request = compute.ListErrorsRegionInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.RegionInstanceGroupManagersListErrorsResponse() - client.delete_instances( + client.list_errors( request, metadata=[ ("key", "val"), @@ -9742,8 +12587,8 @@ def test_delete_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_per_instance_configs_rest_bad_request( - request_type=compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, +def test_list_managed_instances_rest_bad_request( + request_type=compute.ListManagedInstancesRegionInstanceGroupManagersRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -9758,151 +12603,44 @@ def test_delete_per_instance_configs_rest_bad_request( # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_per_instance_configs(request) - - -@pytest.mark.parametrize( - "request_type", - [ - compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, - dict, - ], -) -def test_delete_per_instance_configs_rest_call_success(request_type): - client = RegionInstanceGroupManagersClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = { - "project": "sample1", - "region": "sample2", - "instance_group_manager": "sample3", - } - request_init[ - "region_instance_group_manager_delete_instance_config_req_resource" - ] = {"names": ["names_value1", "names_value2"]} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = ( - compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_manager_delete_instance_config_req_resource" - ] - ) - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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_managed_instances(request) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init[ - "region_instance_group_manager_delete_instance_config_req_resource" - ].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) +@pytest.mark.parametrize( + "request_type", + [ + compute.ListManagedInstancesRegionInstanceGroupManagersRequest, + dict, + ], +) +def test_list_managed_instances_rest_call_success(request_type): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range( - 0, - len( - request_init[ - "region_instance_group_manager_delete_instance_config_req_resource" - ][field] - ), - ): - del request_init[ - "region_instance_group_manager_delete_instance_config_req_resource" - ][field][i][subfield] - else: - del request_init[ - "region_instance_group_manager_delete_instance_config_req_resource" - ][field][subfield] + # send a request that will satisfy transcoding + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.Operation( - client_operation_id="client_operation_id_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - end_time="end_time_value", - http_error_message="http_error_message_value", - http_error_status_code=2374, - id=205, - insert_time="insert_time_value", - kind="kind_value", - name="name_value", - operation_group_id="operation_group_id_value", - operation_type="operation_type_value", - progress=885, - region="region_value", - self_link="self_link_value", - start_time="start_time_value", - status=compute.Operation.Status.DONE, - status_message="status_message_value", - target_id=947, - target_link="target_link_value", - user="user_value", - zone="zone_value", + return_value = compute.RegionInstanceGroupManagersListInstancesResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -9910,40 +12648,22 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.Operation.pb(return_value) + return_value = compute.RegionInstanceGroupManagersListInstancesResponse.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_managed_instances(request) # Establish that the response is the type that we expect. - assert isinstance(response, extended_operation.ExtendedOperation) - assert response.client_operation_id == "client_operation_id_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.end_time == "end_time_value" - assert response.http_error_message == "http_error_message_value" - assert response.http_error_status_code == 2374 - assert response.id == 205 - assert response.insert_time == "insert_time_value" - assert response.kind == "kind_value" - assert response.name == "name_value" - assert response.operation_group_id == "operation_group_id_value" - assert response.operation_type == "operation_type_value" - assert response.progress == 885 - assert response.region == "region_value" - assert response.self_link == "self_link_value" - assert response.start_time == "start_time_value" - assert response.status == compute.Operation.Status.DONE - assert response.status_message == "status_message_value" - assert response.target_id == 947 - assert response.target_link == "target_link_value" - assert response.user == "user_value" - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListManagedInstancesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_per_instance_configs_rest_interceptors(null_interceptor): +def test_list_managed_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -9958,17 +12678,15 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.RegionInstanceGroupManagersRestInterceptor, - "post_delete_per_instance_configs", + "post_list_managed_instances", ) as post, mock.patch.object( transports.RegionInstanceGroupManagersRestInterceptor, - "pre_delete_per_instance_configs", + "pre_list_managed_instances", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest.pb( - compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() - ) + pb_message = compute.ListManagedInstancesRegionInstanceGroupManagersRequest.pb( + compute.ListManagedInstancesRegionInstanceGroupManagersRequest() ) transcode.return_value = { "method": "post", @@ -9979,18 +12697,21 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.Operation.to_json(compute.Operation()) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.RegionInstanceGroupManagersListInstancesResponse.to_json( + compute.RegionInstanceGroupManagersListInstancesResponse() + ) req.return_value.content = return_value - request = compute.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest() + request = compute.ListManagedInstancesRegionInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.Operation() + post.return_value = compute.RegionInstanceGroupManagersListInstancesResponse() - client.delete_per_instance_configs( + client.list_managed_instances( request, metadata=[ ("key", "val"), @@ -10002,8 +12723,8 @@ def test_delete_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_rest_bad_request( - request_type=compute.GetRegionInstanceGroupManagerRequest, +def test_list_per_instance_configs_rest_bad_request( + request_type=compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -10027,17 +12748,18 @@ def test_get_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.GetRegionInstanceGroupManagerRequest, + compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, dict, ], ) -def test_get_rest_call_success(request_type): +def test_list_per_instance_configs_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10053,24 +12775,8 @@ def test_get_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.InstanceGroupManager( - base_instance_name="base_instance_name_value", - creation_timestamp="creation_timestamp_value", - description="description_value", - fingerprint="fingerprint_value", - id=205, - instance_group="instance_group_value", - instance_template="instance_template_value", - kind="kind_value", - list_managed_instances_results="list_managed_instances_results_value", - name="name_value", - region="region_value", - satisfies_pzi=True, - satisfies_pzs=True, - self_link="self_link_value", - target_pools=["target_pools_value"], - target_size=1185, - zone="zone_value", + return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -10078,38 +12784,22 @@ def test_get_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.InstanceGroupManager.pb(return_value) + return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp.pb( + return_value + ) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_per_instance_configs(request) # Establish that the response is the type that we expect. - assert isinstance(response, compute.InstanceGroupManager) - assert response.base_instance_name == "base_instance_name_value" - assert response.creation_timestamp == "creation_timestamp_value" - assert response.description == "description_value" - assert response.fingerprint == "fingerprint_value" - assert response.id == 205 - assert response.instance_group == "instance_group_value" - assert response.instance_template == "instance_template_value" - assert response.kind == "kind_value" - assert ( - response.list_managed_instances_results - == "list_managed_instances_results_value" - ) - assert response.name == "name_value" - assert response.region == "region_value" - assert response.satisfies_pzi is True - assert response.satisfies_pzs is True - assert response.self_link == "self_link_value" - assert response.target_pools == ["target_pools_value"] - assert response.target_size == 1185 - assert response.zone == "zone_value" + assert isinstance(response, pagers.ListPerInstanceConfigsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_rest_interceptors(null_interceptor): +def test_list_per_instance_configs_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10123,14 +12813,18 @@ def test_get_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_get" + transports.RegionInstanceGroupManagersRestInterceptor, + "post_list_per_instance_configs", ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_get" + transports.RegionInstanceGroupManagersRestInterceptor, + "pre_list_per_instance_configs", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.GetRegionInstanceGroupManagerRequest.pb( - compute.GetRegionInstanceGroupManagerRequest() + pb_message = ( + compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest.pb( + compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + ) ) transcode.return_value = { "method": "post", @@ -10141,20 +12835,23 @@ def test_get_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.InstanceGroupManager.to_json( - compute.InstanceGroupManager() + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ( + compute.RegionInstanceGroupManagersListInstanceConfigsResp.to_json( + compute.RegionInstanceGroupManagersListInstanceConfigsResp() + ) ) req.return_value.content = return_value - request = compute.GetRegionInstanceGroupManagerRequest() + request = compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.InstanceGroupManager() + post.return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp() - client.get( + client.list_per_instance_configs( request, metadata=[ ("key", "val"), @@ -10166,14 +12863,18 @@ def test_get_rest_interceptors(null_interceptor): post.assert_called_once() -def test_insert_rest_bad_request( - request_type=compute.InsertRegionInstanceGroupManagerRequest, +def test_patch_rest_bad_request( + request_type=compute.PatchRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1", "region": "sample2"} + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -10187,23 +12888,28 @@ def test_insert_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.insert(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.patch(request) @pytest.mark.parametrize( "request_type", [ - compute.InsertRegionInstanceGroupManagerRequest, + compute.PatchRegionInstanceGroupManagerRequest, dict, ], ) -def test_insert_rest_call_success(request_type): +def test_patch_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project": "sample1", "region": "sample2"} + request_init = { + "project": "sample1", + "region": "sample2", + "instance_group_manager": "sample3", + } request_init["instance_group_manager_resource"] = { "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, "auto_healing_policies": [ @@ -10248,6 +12954,7 @@ def test_insert_rest_call_success(request_type): "satisfies_pzi": True, "satisfies_pzs": True, "self_link": "self_link_value", + "standby_policy": {"initial_delay_sec": 1778, "mode": "mode_value"}, "stateful_policy": { "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} }, @@ -10266,6 +12973,8 @@ def test_insert_rest_call_success(request_type): }, "target_pools": ["target_pools_value1", "target_pools_value2"], "target_size": 1185, + "target_stopped_size": 2047, + "target_suspended_size": 2251, "update_policy": { "instance_redistribution_type": "instance_redistribution_type_value", "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, @@ -10289,7 +12998,7 @@ def test_insert_rest_call_success(request_type): # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.InsertRegionInstanceGroupManagerRequest.meta.fields[ + test_field = compute.PatchRegionInstanceGroupManagerRequest.meta.fields[ "instance_group_manager_resource" ] @@ -10398,7 +13107,8 @@ 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 - response = client.insert(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.patch(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -10427,7 +13137,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_insert_rest_interceptors(null_interceptor): +def test_patch_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10441,14 +13151,14 @@ def test_insert_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_insert" + transports.RegionInstanceGroupManagersRestInterceptor, "post_patch" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_insert" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_patch" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.InsertRegionInstanceGroupManagerRequest.pb( - compute.InsertRegionInstanceGroupManagerRequest() + pb_message = compute.PatchRegionInstanceGroupManagerRequest.pb( + compute.PatchRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -10459,10 +13169,11 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.InsertRegionInstanceGroupManagerRequest() + request = compute.PatchRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -10470,134 +13181,7 @@ def test_insert_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.insert( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_rest_bad_request( - request_type=compute.ListRegionInstanceGroupManagersRequest, -): - client = RegionInstanceGroupManagersClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"project": "sample1", "region": "sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list(request) - - -@pytest.mark.parametrize( - "request_type", - [ - compute.ListRegionInstanceGroupManagersRequest, - dict, - ], -) -def test_list_rest_call_success(request_type): - client = RegionInstanceGroupManagersClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"project": "sample1", "region": "sample2"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = compute.RegionInstanceGroupManagerList( - id="id_value", - kind="kind_value", - next_page_token="next_page_token_value", - self_link="self_link_value", - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = compute.RegionInstanceGroupManagerList.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.list(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPager) - assert response.id == "id_value" - assert response.kind == "kind_value" - assert response.next_page_token == "next_page_token_value" - assert response.self_link == "self_link_value" - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_rest_interceptors(null_interceptor): - transport = transports.RegionInstanceGroupManagersRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.RegionInstanceGroupManagersRestInterceptor(), - ) - client = RegionInstanceGroupManagersClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_list" - ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_list" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = compute.ListRegionInstanceGroupManagersRequest.pb( - compute.ListRegionInstanceGroupManagersRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = compute.RegionInstanceGroupManagerList.to_json( - compute.RegionInstanceGroupManagerList() - ) - req.return_value.content = return_value - - request = compute.ListRegionInstanceGroupManagersRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = compute.RegionInstanceGroupManagerList() - - client.list( + client.patch( request, metadata=[ ("key", "val"), @@ -10609,8 +13193,8 @@ def test_list_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_errors_rest_bad_request( - request_type=compute.ListErrorsRegionInstanceGroupManagersRequest, +def test_patch_per_instance_configs_rest_bad_request( + request_type=compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -10634,17 +13218,18 @@ def test_list_errors_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_errors(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.patch_per_instance_configs(request) @pytest.mark.parametrize( "request_type", [ - compute.ListErrorsRegionInstanceGroupManagersRequest, + compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, dict, ], ) -def test_list_errors_rest_call_success(request_type): +def test_patch_per_instance_configs_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10655,13 +13240,133 @@ def test_list_errors_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } + request_init["region_instance_group_manager_patch_instance_config_req_resource"] = { + "per_instance_configs": [ + { + "fingerprint": "fingerprint_value", + "name": "name_value", + "preserved_state": { + "disks": {}, + "external_i_ps": {}, + "internal_i_ps": {}, + "metadata": {}, + }, + "status": "status_value", + } + ] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = ( + compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_manager_patch_instance_config_req_resource" + ] + ) + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_manager_patch_instance_config_req_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_manager_patch_instance_config_req_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_manager_patch_instance_config_req_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_manager_patch_instance_config_req_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.RegionInstanceGroupManagersListErrorsResponse( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -10669,21 +13374,41 @@ def test_list_errors_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.RegionInstanceGroupManagersListErrorsResponse.pb( - return_value - ) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_errors(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.patch_per_instance_configs(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListErrorsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_errors_rest_interceptors(null_interceptor): +def test_patch_per_instance_configs_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10697,14 +13422,18 @@ def test_list_errors_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_list_errors" + transports.RegionInstanceGroupManagersRestInterceptor, + "post_patch_per_instance_configs", ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_list_errors" + transports.RegionInstanceGroupManagersRestInterceptor, + "pre_patch_per_instance_configs", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ListErrorsRegionInstanceGroupManagersRequest.pb( - compute.ListErrorsRegionInstanceGroupManagersRequest() + pb_message = ( + compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest.pb( + compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + ) ) transcode.return_value = { "method": "post", @@ -10715,20 +13444,19 @@ def test_list_errors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.RegionInstanceGroupManagersListErrorsResponse.to_json( - compute.RegionInstanceGroupManagersListErrorsResponse() - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListErrorsRegionInstanceGroupManagersRequest() + request = compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.RegionInstanceGroupManagersListErrorsResponse() + post.return_value = compute.Operation() - client.list_errors( + client.patch_per_instance_configs( request, metadata=[ ("key", "val"), @@ -10740,8 +13468,8 @@ def test_list_errors_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_managed_instances_rest_bad_request( - request_type=compute.ListManagedInstancesRegionInstanceGroupManagersRequest, +def test_recreate_instances_rest_bad_request( + request_type=compute.RecreateInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -10765,17 +13493,18 @@ def test_list_managed_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_managed_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.recreate_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.ListManagedInstancesRegionInstanceGroupManagersRequest, + compute.RecreateInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_list_managed_instances_rest_call_success(request_type): +def test_recreate_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10786,13 +13515,119 @@ def test_list_managed_instances_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } + request_init["region_instance_group_managers_recreate_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.RecreateInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_recreate_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_managers_recreate_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_managers_recreate_request_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_managers_recreate_request_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_managers_recreate_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.RegionInstanceGroupManagersListInstancesResponse( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -10800,21 +13635,41 @@ def test_list_managed_instances_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.RegionInstanceGroupManagersListInstancesResponse.pb( - return_value - ) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_managed_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.recreate_instances(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListManagedInstancesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_managed_instances_rest_interceptors(null_interceptor): +def test_recreate_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10828,16 +13683,14 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "post_list_managed_instances", + transports.RegionInstanceGroupManagersRestInterceptor, "post_recreate_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "pre_list_managed_instances", + transports.RegionInstanceGroupManagersRestInterceptor, "pre_recreate_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ListManagedInstancesRegionInstanceGroupManagersRequest.pb( - compute.ListManagedInstancesRegionInstanceGroupManagersRequest() + pb_message = compute.RecreateInstancesRegionInstanceGroupManagerRequest.pb( + compute.RecreateInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -10848,20 +13701,19 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = compute.RegionInstanceGroupManagersListInstancesResponse.to_json( - compute.RegionInstanceGroupManagersListInstancesResponse() - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListManagedInstancesRegionInstanceGroupManagersRequest() + request = compute.RecreateInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.RegionInstanceGroupManagersListInstancesResponse() + post.return_value = compute.Operation() - client.list_managed_instances( + client.recreate_instances( request, metadata=[ ("key", "val"), @@ -10873,8 +13725,8 @@ def test_list_managed_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_per_instance_configs_rest_bad_request( - request_type=compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, +def test_resize_rest_bad_request( + request_type=compute.ResizeRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -10898,17 +13750,18 @@ def test_list_per_instance_configs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.resize(request) @pytest.mark.parametrize( "request_type", [ - compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, + compute.ResizeRegionInstanceGroupManagerRequest, dict, ], ) -def test_list_per_instance_configs_rest_call_success(request_type): +def test_resize_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -10924,8 +13777,29 @@ def test_list_per_instance_configs_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp( - next_page_token="next_page_token_value", + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", ) # Wrap the value into a proper Response obj @@ -10933,21 +13807,41 @@ def test_list_per_instance_configs_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp.pb( - return_value - ) + return_value = compute.Operation.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.resize(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPerInstanceConfigsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_per_instance_configs_rest_interceptors(null_interceptor): +def test_resize_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -10961,18 +13855,14 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "post_list_per_instance_configs", + transports.RegionInstanceGroupManagersRestInterceptor, "post_resize" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "pre_list_per_instance_configs", + transports.RegionInstanceGroupManagersRestInterceptor, "pre_resize" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest.pb( - compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() - ) + pb_message = compute.ResizeRegionInstanceGroupManagerRequest.pb( + compute.ResizeRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -10983,22 +13873,19 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = ( - compute.RegionInstanceGroupManagersListInstanceConfigsResp.to_json( - compute.RegionInstanceGroupManagersListInstanceConfigsResp() - ) - ) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ListPerInstanceConfigsRegionInstanceGroupManagersRequest() + request = compute.ResizeRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = compute.RegionInstanceGroupManagersListInstanceConfigsResp() + post.return_value = compute.Operation() - client.list_per_instance_configs( + client.resize( request, metadata=[ ("key", "val"), @@ -11010,8 +13897,8 @@ def test_list_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_patch_rest_bad_request( - request_type=compute.PatchRegionInstanceGroupManagerRequest, +def test_resume_instances_rest_bad_request( + request_type=compute.ResumeInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11035,17 +13922,18 @@ def test_patch_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.patch(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.resume_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.PatchRegionInstanceGroupManagerRequest, + compute.ResumeInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_patch_rest_call_success(request_type): +def test_resume_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11056,93 +13944,16 @@ def test_patch_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["instance_group_manager_resource"] = { - "all_instances_config": {"properties": {"labels": {}, "metadata": {}}}, - "auto_healing_policies": [ - {"health_check": "health_check_value", "initial_delay_sec": 1778} - ], - "base_instance_name": "base_instance_name_value", - "creation_timestamp": "creation_timestamp_value", - "current_actions": { - "abandoning": 1041, - "creating": 845, - "creating_without_retries": 2589, - "deleting": 844, - "none": 432, - "recreating": 1060, - "refreshing": 1069, - "restarting": 1091, - "resuming": 874, - "starting": 876, - "stopping": 884, - "suspending": 1088, - "verifying": 979, - }, - "description": "description_value", - "distribution_policy": { - "target_shape": "target_shape_value", - "zones": [{"zone": "zone_value"}], - }, - "fingerprint": "fingerprint_value", - "id": 205, - "instance_flexibility_policy": {"instance_selections": {}}, - "instance_group": "instance_group_value", - "instance_lifecycle_policy": { - "default_action_on_failure": "default_action_on_failure_value", - "force_update_on_repair": "force_update_on_repair_value", - }, - "instance_template": "instance_template_value", - "kind": "kind_value", - "list_managed_instances_results": "list_managed_instances_results_value", - "name": "name_value", - "named_ports": [{"name": "name_value", "port": 453}], - "region": "region_value", - "satisfies_pzi": True, - "satisfies_pzs": True, - "self_link": "self_link_value", - "stateful_policy": { - "preserved_state": {"disks": {}, "external_i_ps": {}, "internal_i_ps": {}} - }, - "status": { - "all_instances_config": { - "current_revision": "current_revision_value", - "effective": True, - }, - "autoscaler": "autoscaler_value", - "is_stable": True, - "stateful": { - "has_stateful_config": True, - "per_instance_configs": {"all_effective": True}, - }, - "version_target": {"is_reached": True}, - }, - "target_pools": ["target_pools_value1", "target_pools_value2"], - "target_size": 1185, - "update_policy": { - "instance_redistribution_type": "instance_redistribution_type_value", - "max_surge": {"calculated": 1042, "fixed": 528, "percent": 753}, - "max_unavailable": {}, - "minimal_action": "minimal_action_value", - "most_disruptive_allowed_action": "most_disruptive_allowed_action_value", - "replacement_method": "replacement_method_value", - "type_": "type__value", - }, - "versions": [ - { - "instance_template": "instance_template_value", - "name": "name_value", - "target_size": {}, - } - ], - "zone": "zone_value", + request_init["region_instance_group_managers_resume_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.PatchRegionInstanceGroupManagerRequest.meta.fields[ - "instance_group_manager_resource" + test_field = compute.ResumeInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_resume_instances_request_resource" ] def get_message_fields(field): @@ -11172,7 +13983,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "instance_group_manager_resource" + "region_instance_group_managers_resume_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -11204,13 +14015,20 @@ def get_message_fields(field): if subfield: if field_repeated: for i in range( - 0, len(request_init["instance_group_manager_resource"][field]) + 0, + len( + request_init[ + "region_instance_group_managers_resume_instances_request_resource" + ][field] + ), ): - del request_init["instance_group_manager_resource"][field][i][ - subfield - ] + del request_init[ + "region_instance_group_managers_resume_instances_request_resource" + ][field][i][subfield] else: - del request_init["instance_group_manager_resource"][field][subfield] + del request_init[ + "region_instance_group_managers_resume_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -11250,7 +14068,8 @@ 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 - response = client.patch(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.resume_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11279,7 +14098,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_patch_rest_interceptors(null_interceptor): +def test_resume_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11293,14 +14112,14 @@ def test_patch_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_patch" + transports.RegionInstanceGroupManagersRestInterceptor, "post_resume_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_patch" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_resume_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.PatchRegionInstanceGroupManagerRequest.pb( - compute.PatchRegionInstanceGroupManagerRequest() + pb_message = compute.ResumeInstancesRegionInstanceGroupManagerRequest.pb( + compute.ResumeInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11311,10 +14130,11 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.PatchRegionInstanceGroupManagerRequest() + request = compute.ResumeInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -11322,7 +14142,7 @@ def test_patch_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.patch( + client.resume_instances( request, metadata=[ ("key", "val"), @@ -11334,8 +14154,8 @@ def test_patch_rest_interceptors(null_interceptor): post.assert_called_once() -def test_patch_per_instance_configs_rest_bad_request( - request_type=compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, +def test_set_instance_template_rest_bad_request( + request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11359,17 +14179,18 @@ def test_patch_per_instance_configs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.patch_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.set_instance_template(request) @pytest.mark.parametrize( "request_type", [ - compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, + compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, dict, ], ) -def test_patch_per_instance_configs_rest_call_success(request_type): +def test_set_instance_template_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11380,20 +14201,8 @@ def test_patch_per_instance_configs_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_manager_patch_instance_config_req_resource"] = { - "per_instance_configs": [ - { - "fingerprint": "fingerprint_value", - "name": "name_value", - "preserved_state": { - "disks": {}, - "external_i_ps": {}, - "internal_i_ps": {}, - "metadata": {}, - }, - "status": "status_value", - } - ] + request_init["region_instance_group_managers_set_template_request_resource"] = { + "instance_template": "instance_template_value" } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -11401,8 +14210,8 @@ def test_patch_per_instance_configs_rest_call_success(request_type): # Determine if the message type is proto-plus or protobuf test_field = ( - compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_manager_patch_instance_config_req_resource" + compute.SetInstanceTemplateRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_set_template_request_resource" ] ) @@ -11433,7 +14242,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_manager_patch_instance_config_req_resource" + "region_instance_group_managers_set_template_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -11468,16 +14277,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_manager_patch_instance_config_req_resource" + "region_instance_group_managers_set_template_request_resource" ][field] ), ): del request_init[ - "region_instance_group_manager_patch_instance_config_req_resource" + "region_instance_group_managers_set_template_request_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_manager_patch_instance_config_req_resource" + "region_instance_group_managers_set_template_request_resource" ][field][subfield] request = request_type(**request_init) @@ -11518,7 +14327,8 @@ 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 - response = client.patch_per_instance_configs(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.set_instance_template(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11547,7 +14357,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_patch_per_instance_configs_rest_interceptors(null_interceptor): +def test_set_instance_template_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11562,17 +14372,15 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): path_template, "transcode" ) as transcode, mock.patch.object( transports.RegionInstanceGroupManagersRestInterceptor, - "post_patch_per_instance_configs", + "post_set_instance_template", ) as post, mock.patch.object( transports.RegionInstanceGroupManagersRestInterceptor, - "pre_patch_per_instance_configs", + "pre_set_instance_template", ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = ( - compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest.pb( - compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() - ) + pb_message = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest.pb( + compute.SetInstanceTemplateRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11583,10 +14391,11 @@ def test_patch_per_instance_configs_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest() + request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -11594,7 +14403,7 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.patch_per_instance_configs( + client.set_instance_template( request, metadata=[ ("key", "val"), @@ -11606,8 +14415,8 @@ def test_patch_per_instance_configs_rest_interceptors(null_interceptor): post.assert_called_once() -def test_recreate_instances_rest_bad_request( - request_type=compute.RecreateInstancesRegionInstanceGroupManagerRequest, +def test_set_target_pools_rest_bad_request( + request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11631,17 +14440,18 @@ def test_recreate_instances_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.recreate_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.set_target_pools(request) @pytest.mark.parametrize( "request_type", [ - compute.RecreateInstancesRegionInstanceGroupManagerRequest, + compute.SetTargetPoolsRegionInstanceGroupManagerRequest, dict, ], ) -def test_recreate_instances_rest_call_success(request_type): +def test_set_target_pools_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11652,16 +14462,17 @@ def test_recreate_instances_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_managers_recreate_request_resource"] = { - "instances": ["instances_value1", "instances_value2"] + request_init["region_instance_group_managers_set_target_pools_request_resource"] = { + "fingerprint": "fingerprint_value", + "target_pools": ["target_pools_value1", "target_pools_value2"], } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.RecreateInstancesRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_recreate_request_resource" + test_field = compute.SetTargetPoolsRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_set_target_pools_request_resource" ] def get_message_fields(field): @@ -11691,7 +14502,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_recreate_request_resource" + "region_instance_group_managers_set_target_pools_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -11726,16 +14537,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_managers_recreate_request_resource" + "region_instance_group_managers_set_target_pools_request_resource" ][field] ), ): del request_init[ - "region_instance_group_managers_recreate_request_resource" + "region_instance_group_managers_set_target_pools_request_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_managers_recreate_request_resource" + "region_instance_group_managers_set_target_pools_request_resource" ][field][subfield] request = request_type(**request_init) @@ -11776,7 +14587,8 @@ 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 - response = client.recreate_instances(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.set_target_pools(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11805,7 +14617,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_recreate_instances_rest_interceptors(null_interceptor): +def test_set_target_pools_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11819,14 +14631,14 @@ def test_recreate_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_recreate_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "post_set_target_pools" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_recreate_instances" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_set_target_pools" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.RecreateInstancesRegionInstanceGroupManagerRequest.pb( - compute.RecreateInstancesRegionInstanceGroupManagerRequest() + pb_message = compute.SetTargetPoolsRegionInstanceGroupManagerRequest.pb( + compute.SetTargetPoolsRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -11837,10 +14649,11 @@ def test_recreate_instances_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.RecreateInstancesRegionInstanceGroupManagerRequest() + request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -11848,7 +14661,7 @@ def test_recreate_instances_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.recreate_instances( + client.set_target_pools( request, metadata=[ ("key", "val"), @@ -11860,8 +14673,8 @@ def test_recreate_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_resize_rest_bad_request( - request_type=compute.ResizeRegionInstanceGroupManagerRequest, +def test_start_instances_rest_bad_request( + request_type=compute.StartInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -11885,17 +14698,18 @@ def test_resize_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.resize(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.start_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.ResizeRegionInstanceGroupManagerRequest, + compute.StartInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_resize_rest_call_success(request_type): +def test_start_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -11906,6 +14720,91 @@ def test_resize_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } + request_init["region_instance_group_managers_start_instances_request_resource"] = { + "instances": ["instances_value1", "instances_value2"] + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.StartInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_start_instances_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_instance_group_managers_start_instances_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, + len( + request_init[ + "region_instance_group_managers_start_instances_request_resource" + ][field] + ), + ): + del request_init[ + "region_instance_group_managers_start_instances_request_resource" + ][field][i][subfield] + else: + del request_init[ + "region_instance_group_managers_start_instances_request_resource" + ][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -11945,7 +14844,8 @@ def test_resize_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 - response = client.resize(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.start_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -11974,7 +14874,7 @@ def test_resize_rest_call_success(request_type): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_resize_rest_interceptors(null_interceptor): +def test_start_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11988,14 +14888,14 @@ def test_resize_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_resize" + transports.RegionInstanceGroupManagersRestInterceptor, "post_start_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_resize" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_start_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.ResizeRegionInstanceGroupManagerRequest.pb( - compute.ResizeRegionInstanceGroupManagerRequest() + pb_message = compute.StartInstancesRegionInstanceGroupManagerRequest.pb( + compute.StartInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12006,10 +14906,11 @@ def test_resize_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.ResizeRegionInstanceGroupManagerRequest() + request = compute.StartInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12017,7 +14918,7 @@ def test_resize_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.resize( + client.start_instances( request, metadata=[ ("key", "val"), @@ -12029,8 +14930,8 @@ def test_resize_rest_interceptors(null_interceptor): post.assert_called_once() -def test_set_instance_template_rest_bad_request( - request_type=compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, +def test_stop_instances_rest_bad_request( + request_type=compute.StopInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -12054,17 +14955,18 @@ def test_set_instance_template_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.set_instance_template(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.stop_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.SetInstanceTemplateRegionInstanceGroupManagerRequest, + compute.StopInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_set_instance_template_rest_call_success(request_type): +def test_stop_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12075,19 +14977,18 @@ def test_set_instance_template_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_managers_set_template_request_resource"] = { - "instance_template": "instance_template_value" + request_init["region_instance_group_managers_stop_instances_request_resource"] = { + "force_stop": True, + "instances": ["instances_value1", "instances_value2"], } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = ( - compute.SetInstanceTemplateRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_set_template_request_resource" - ] - ) + test_field = compute.StopInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_stop_instances_request_resource" + ] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -12116,7 +15017,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_set_template_request_resource" + "region_instance_group_managers_stop_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -12151,16 +15052,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_managers_set_template_request_resource" + "region_instance_group_managers_stop_instances_request_resource" ][field] ), ): del request_init[ - "region_instance_group_managers_set_template_request_resource" + "region_instance_group_managers_stop_instances_request_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_managers_set_template_request_resource" + "region_instance_group_managers_stop_instances_request_resource" ][field][subfield] request = request_type(**request_init) @@ -12201,7 +15102,8 @@ 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 - response = client.set_instance_template(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.stop_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12230,7 +15132,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_instance_template_rest_interceptors(null_interceptor): +def test_stop_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12244,16 +15146,14 @@ def test_set_instance_template_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "post_set_instance_template", + transports.RegionInstanceGroupManagersRestInterceptor, "post_stop_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, - "pre_set_instance_template", + transports.RegionInstanceGroupManagersRestInterceptor, "pre_stop_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest.pb( - compute.SetInstanceTemplateRegionInstanceGroupManagerRequest() + pb_message = compute.StopInstancesRegionInstanceGroupManagerRequest.pb( + compute.StopInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12264,10 +15164,11 @@ def test_set_instance_template_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.SetInstanceTemplateRegionInstanceGroupManagerRequest() + request = compute.StopInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12275,7 +15176,7 @@ def test_set_instance_template_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.set_instance_template( + client.stop_instances( request, metadata=[ ("key", "val"), @@ -12287,8 +15188,8 @@ def test_set_instance_template_rest_interceptors(null_interceptor): post.assert_called_once() -def test_set_target_pools_rest_bad_request( - request_type=compute.SetTargetPoolsRegionInstanceGroupManagerRequest, +def test_suspend_instances_rest_bad_request( + request_type=compute.SuspendInstancesRegionInstanceGroupManagerRequest, ): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -12312,17 +15213,18 @@ def test_set_target_pools_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.set_target_pools(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.suspend_instances(request) @pytest.mark.parametrize( "request_type", [ - compute.SetTargetPoolsRegionInstanceGroupManagerRequest, + compute.SuspendInstancesRegionInstanceGroupManagerRequest, dict, ], ) -def test_set_target_pools_rest_call_success(request_type): +def test_suspend_instances_rest_call_success(request_type): client = RegionInstanceGroupManagersClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -12333,17 +15235,16 @@ def test_set_target_pools_rest_call_success(request_type): "region": "sample2", "instance_group_manager": "sample3", } - request_init["region_instance_group_managers_set_target_pools_request_resource"] = { - "fingerprint": "fingerprint_value", - "target_pools": ["target_pools_value1", "target_pools_value2"], - } + request_init[ + "region_instance_group_managers_suspend_instances_request_resource" + ] = {"force_suspend": True, "instances": ["instances_value1", "instances_value2"]} # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = compute.SetTargetPoolsRegionInstanceGroupManagerRequest.meta.fields[ - "region_instance_group_managers_set_target_pools_request_resource" + test_field = compute.SuspendInstancesRegionInstanceGroupManagerRequest.meta.fields[ + "region_instance_group_managers_suspend_instances_request_resource" ] def get_message_fields(field): @@ -12373,7 +15274,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime for field, value in request_init[ - "region_instance_group_managers_set_target_pools_request_resource" + "region_instance_group_managers_suspend_instances_request_resource" ].items(): # pragma: NO COVER result = None is_repeated = False @@ -12408,16 +15309,16 @@ def get_message_fields(field): 0, len( request_init[ - "region_instance_group_managers_set_target_pools_request_resource" + "region_instance_group_managers_suspend_instances_request_resource" ][field] ), ): del request_init[ - "region_instance_group_managers_set_target_pools_request_resource" + "region_instance_group_managers_suspend_instances_request_resource" ][field][i][subfield] else: del request_init[ - "region_instance_group_managers_set_target_pools_request_resource" + "region_instance_group_managers_suspend_instances_request_resource" ][field][subfield] request = request_type(**request_init) @@ -12458,7 +15359,8 @@ 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 - response = client.set_target_pools(request) + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.suspend_instances(request) # Establish that the response is the type that we expect. assert isinstance(response, extended_operation.ExtendedOperation) @@ -12487,7 +15389,7 @@ def get_message_fields(field): @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_target_pools_rest_interceptors(null_interceptor): +def test_suspend_instances_rest_interceptors(null_interceptor): transport = transports.RegionInstanceGroupManagersRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12501,14 +15403,14 @@ def test_set_target_pools_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "post_set_target_pools" + transports.RegionInstanceGroupManagersRestInterceptor, "post_suspend_instances" ) as post, mock.patch.object( - transports.RegionInstanceGroupManagersRestInterceptor, "pre_set_target_pools" + transports.RegionInstanceGroupManagersRestInterceptor, "pre_suspend_instances" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = compute.SetTargetPoolsRegionInstanceGroupManagerRequest.pb( - compute.SetTargetPoolsRegionInstanceGroupManagerRequest() + pb_message = compute.SuspendInstancesRegionInstanceGroupManagerRequest.pb( + compute.SuspendInstancesRegionInstanceGroupManagerRequest() ) transcode.return_value = { "method": "post", @@ -12519,10 +15421,11 @@ def test_set_target_pools_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value - request = compute.SetTargetPoolsRegionInstanceGroupManagerRequest() + request = compute.SuspendInstancesRegionInstanceGroupManagerRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12530,7 +15433,7 @@ def test_set_target_pools_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = compute.Operation() - client.set_target_pools( + client.suspend_instances( request, metadata=[ ("key", "val"), @@ -12567,6 +15470,7 @@ def test_update_per_instance_configs_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.update_per_instance_configs(request) @@ -12728,6 +15632,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_per_instance_configs(request) # Establish that the response is the type that we expect. @@ -12793,6 +15698,7 @@ def test_update_per_instance_configs_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -13159,6 +16065,26 @@ def test_resize_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_resume_instances_unary_empty_call_rest(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.resume_instances), "__call__") as call: + client.resume_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.ResumeInstancesRegionInstanceGroupManagerRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_set_instance_template_unary_empty_call_rest(): @@ -13201,6 +16127,68 @@ def test_set_target_pools_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_start_instances_unary_empty_call_rest(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.start_instances), "__call__") as call: + client.start_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.StartInstancesRegionInstanceGroupManagerRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_stop_instances_unary_empty_call_rest(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.stop_instances), "__call__") as call: + client.stop_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.StopInstancesRegionInstanceGroupManagerRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_suspend_instances_unary_empty_call_rest(): + client = RegionInstanceGroupManagersClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.suspend_instances), "__call__" + ) as call: + client.suspend_instances_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.SuspendInstancesRegionInstanceGroupManagerRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_update_per_instance_configs_unary_empty_call_rest(): @@ -13263,8 +16251,12 @@ def test_region_instance_group_managers_base_transport(): "patch_per_instance_configs", "recreate_instances", "resize", + "resume_instances", "set_instance_template", "set_target_pools", + "start_instances", + "stop_instances", + "suspend_instances", "update_per_instance_configs", ) for method in methods: @@ -13453,12 +16445,24 @@ def test_region_instance_group_managers_client_transport_session_collision( session1 = client1.transport.resize._session session2 = client2.transport.resize._session assert session1 != session2 + session1 = client1.transport.resume_instances._session + session2 = client2.transport.resume_instances._session + assert session1 != session2 session1 = client1.transport.set_instance_template._session session2 = client2.transport.set_instance_template._session assert session1 != session2 session1 = client1.transport.set_target_pools._session session2 = client2.transport.set_target_pools._session assert session1 != session2 + session1 = client1.transport.start_instances._session + session2 = client2.transport.start_instances._session + assert session1 != session2 + session1 = client1.transport.stop_instances._session + session2 = client2.transport.stop_instances._session + assert session1 != session2 + session1 = client1.transport.suspend_instances._session + session2 = client2.transport.suspend_instances._session + assert session1 != session2 session1 = client1.transport.update_per_instance_configs._session session2 = client2.transport.update_per_instance_configs._session assert session1 != session2 diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_groups.py index 61bd7eba7093..535dfaeaef4d 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_groups.py @@ -1052,6 +1052,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionInstanceGroupReq 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(request) @@ -1112,6 +1113,7 @@ def test_get_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(**mock_args) @@ -1259,6 +1261,7 @@ def test_list_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.list(request) @@ -1321,6 +1324,7 @@ def test_list_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(**mock_args) @@ -1533,6 +1537,7 @@ def test_list_instances_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.list_instances(request) @@ -1605,6 +1610,7 @@ def test_list_instances_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_instances(**mock_args) @@ -1828,6 +1834,7 @@ def test_set_named_ports_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_named_ports(request) @@ -1892,6 +1899,7 @@ def test_set_named_ports_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_named_ports(**mock_args) @@ -2043,6 +2051,7 @@ def test_set_named_ports_unary_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_named_ports_unary(request) @@ -2107,6 +2116,7 @@ def test_set_named_ports_unary_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_named_ports_unary(**mock_args) @@ -2246,6 +2256,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionInstanceGroupRequest 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(request) @@ -2296,6 +2307,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2347,6 +2359,7 @@ def test_get_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 = compute.InstanceGroup.to_json(compute.InstanceGroup()) req.return_value.content = return_value @@ -2389,6 +2402,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionInstanceGroupsRequ 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(request) @@ -2427,6 +2441,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2470,6 +2485,7 @@ def test_list_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 = compute.RegionInstanceGroupList.to_json( compute.RegionInstanceGroupList() ) @@ -2520,6 +2536,7 @@ def test_list_instances_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.list_instances(request) @@ -2648,6 +2665,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.list_instances(request) # Establish that the response is the type that we expect. @@ -2691,6 +2709,7 @@ def test_list_instances_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 = compute.RegionInstanceGroupsListInstances.to_json( compute.RegionInstanceGroupsListInstances() ) @@ -2741,6 +2760,7 @@ def test_set_named_ports_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_named_ports(request) @@ -2887,6 +2907,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.set_named_ports(request) # Establish that the response is the type that we expect. @@ -2948,6 +2969,7 @@ def test_set_named_ports_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_templates.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_templates.py index 81a2b90c8bcb..cafda09c012f 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_templates.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instance_templates.py @@ -1064,6 +1064,7 @@ def test_delete_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.delete(request) @@ -1124,6 +1125,7 @@ def test_delete_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.delete(**mock_args) @@ -1271,6 +1273,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1331,6 +1334,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1472,6 +1476,7 @@ def test_get_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(request) @@ -1532,6 +1537,7 @@ def test_get_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(**mock_args) @@ -1676,6 +1682,7 @@ def test_insert_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.insert(request) @@ -1734,6 +1741,7 @@ def test_insert_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.insert(**mock_args) @@ -1880,6 +1888,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1938,6 +1947,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2087,6 +2097,7 @@ def test_list_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.list(request) @@ -2149,6 +2160,7 @@ def test_list_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(**mock_args) @@ -2347,6 +2359,7 @@ def test_delete_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.delete(request) @@ -2407,6 +2420,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2468,6 +2482,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2514,6 +2529,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionInstanceTemplateRequ 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(request) @@ -2560,6 +2576,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2607,6 +2624,7 @@ def test_get_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 = compute.InstanceTemplate.to_json(compute.InstanceTemplate()) req.return_value.content = return_value @@ -2651,6 +2669,7 @@ def test_insert_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.insert(request) @@ -2977,6 +2996,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.insert(request) # Establish that the response is the type that we expect. @@ -3038,6 +3058,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3080,6 +3101,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionInstanceTemplatesR 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(request) @@ -3118,6 +3140,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3161,6 +3184,7 @@ def test_list_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 = compute.InstanceTemplateList.to_json( compute.InstanceTemplateList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instances.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instances.py index c0f88c5edf38..5347ad371589 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instances.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instances.py @@ -1028,6 +1028,7 @@ def test_bulk_insert_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.bulk_insert(request) @@ -1086,6 +1087,7 @@ def test_bulk_insert_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.bulk_insert(**mock_args) @@ -1232,6 +1234,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(request) @@ -1290,6 +1293,7 @@ def test_bulk_insert_unary_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.bulk_insert_unary(**mock_args) @@ -1426,6 +1430,7 @@ def test_bulk_insert_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.bulk_insert(request) @@ -1745,6 +1750,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.bulk_insert(request) # Establish that the response is the type that we expect. @@ -1806,6 +1812,7 @@ def test_bulk_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instant_snapshots.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instant_snapshots.py index 6e2fd3003cce..04b32415b203 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instant_snapshots.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_instant_snapshots.py @@ -1064,6 +1064,7 @@ def test_delete_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.delete(request) @@ -1124,6 +1125,7 @@ def test_delete_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.delete(**mock_args) @@ -1271,6 +1273,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1331,6 +1334,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1470,6 +1474,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionInstantSnapshotR 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(request) @@ -1530,6 +1535,7 @@ def test_get_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(**mock_args) @@ -1673,6 +1679,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) @@ -1733,6 +1740,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) @@ -1877,6 +1885,7 @@ def test_insert_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.insert(request) @@ -1935,6 +1944,7 @@ def test_insert_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.insert(**mock_args) @@ -2081,6 +2091,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2139,6 +2150,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2288,6 +2300,7 @@ def test_list_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.list(request) @@ -2350,6 +2363,7 @@ def test_list_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(**mock_args) @@ -2552,6 +2566,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) @@ -2616,6 +2631,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) @@ -2767,6 +2783,7 @@ def test_set_labels_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_labels(request) @@ -2831,6 +2848,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2982,6 +3000,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3046,6 +3065,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3195,6 +3215,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) @@ -3259,6 +3280,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) @@ -3400,6 +3422,7 @@ def test_delete_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.delete(request) @@ -3460,6 +3483,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3521,6 +3545,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3567,6 +3592,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionInstantSnapshotReque 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(request) @@ -3622,6 +3648,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3678,6 +3705,7 @@ def test_get_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 = compute.InstantSnapshot.to_json(compute.InstantSnapshot()) req.return_value.content = return_value @@ -3722,6 +3750,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) @@ -3759,6 +3788,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. @@ -3801,6 +3831,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3845,6 +3876,7 @@ def test_insert_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.insert(request) @@ -3995,6 +4027,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.insert(request) # Establish that the response is the type that we expect. @@ -4056,6 +4089,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4098,6 +4132,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionInstantSnapshotsRe 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(request) @@ -4136,6 +4171,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4179,6 +4215,7 @@ def test_list_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 = compute.InstantSnapshotList.to_json( compute.InstantSnapshotList() ) @@ -4225,6 +4262,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) @@ -4378,6 +4416,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4420,6 +4459,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4464,6 +4504,7 @@ def test_set_labels_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_labels(request) @@ -4599,6 +4640,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4660,6 +4702,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4704,6 +4747,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) @@ -4817,6 +4861,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4857,6 +4902,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_endpoint_groups.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_endpoint_groups.py index 2a8e6b937c35..2818411dae10 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_endpoint_groups.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_endpoint_groups.py @@ -1084,6 +1084,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -1150,6 +1151,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(**mock_args) @@ -1308,6 +1310,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(request) @@ -1374,6 +1377,7 @@ def test_attach_network_endpoints_unary_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.attach_network_endpoints_unary(**mock_args) @@ -1526,6 +1530,7 @@ def test_delete_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.delete(request) @@ -1586,6 +1591,7 @@ def test_delete_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.delete(**mock_args) @@ -1733,6 +1739,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1793,6 +1800,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1946,6 +1954,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -2012,6 +2021,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(**mock_args) @@ -2170,6 +2180,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(request) @@ -2236,6 +2247,7 @@ def test_detach_network_endpoints_unary_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.detach_network_endpoints_unary(**mock_args) @@ -2382,6 +2394,7 @@ def test_get_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(request) @@ -2442,6 +2455,7 @@ def test_get_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(**mock_args) @@ -2586,6 +2600,7 @@ def test_insert_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.insert(request) @@ -2644,6 +2659,7 @@ def test_insert_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.insert(**mock_args) @@ -2790,6 +2806,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2848,6 +2865,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2997,6 +3015,7 @@ def test_list_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.list(request) @@ -3059,6 +3078,7 @@ def test_list_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(**mock_args) @@ -3277,6 +3297,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -3347,6 +3368,7 @@ def test_list_network_endpoints_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_network_endpoints(**mock_args) @@ -3555,6 +3577,7 @@ def test_attach_network_endpoints_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.attach_network_endpoints(request) @@ -3712,6 +3735,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.attach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -3775,6 +3799,7 @@ def test_attach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3823,6 +3848,7 @@ def test_delete_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.delete(request) @@ -3883,6 +3909,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3944,6 +3971,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3992,6 +4020,7 @@ def test_detach_network_endpoints_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.detach_network_endpoints(request) @@ -4149,6 +4178,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.detach_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4212,6 +4242,7 @@ def test_detach_network_endpoints_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4260,6 +4291,7 @@ def test_get_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(request) @@ -4312,6 +4344,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4365,6 +4398,7 @@ def test_get_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 = compute.NetworkEndpointGroup.to_json( compute.NetworkEndpointGroup() ) @@ -4411,6 +4445,7 @@ def test_insert_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.insert(request) @@ -4576,6 +4611,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.insert(request) # Establish that the response is the type that we expect. @@ -4637,6 +4673,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4681,6 +4718,7 @@ def test_list_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.list(request) @@ -4719,6 +4757,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4762,6 +4801,7 @@ def test_list_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 = compute.NetworkEndpointGroupList.to_json( compute.NetworkEndpointGroupList() ) @@ -4812,6 +4852,7 @@ def test_list_network_endpoints_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.list_network_endpoints(request) @@ -4855,6 +4896,7 @@ def test_list_network_endpoints_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_network_endpoints(request) # Establish that the response is the type that we expect. @@ -4899,6 +4941,7 @@ def test_list_network_endpoints_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 = compute.NetworkEndpointGroupsListNetworkEndpoints.to_json( compute.NetworkEndpointGroupsListNetworkEndpoints() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_firewall_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_firewall_policies.py index 248200c7c997..0a37e80df5ba 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_firewall_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_network_firewall_policies.py @@ -1090,6 +1090,7 @@ def test_add_association_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.add_association(request) @@ -1159,6 +1160,7 @@ def test_add_association_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.add_association(**mock_args) @@ -1315,6 +1317,7 @@ def test_add_association_unary_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.add_association_unary(request) @@ -1384,6 +1387,7 @@ def test_add_association_unary_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.add_association_unary(**mock_args) @@ -1541,6 +1545,7 @@ def test_add_rule_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.add_rule(request) @@ -1611,6 +1616,7 @@ def test_add_rule_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.add_rule(**mock_args) @@ -1768,6 +1774,7 @@ def test_add_rule_unary_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.add_rule_unary(request) @@ -1838,6 +1845,7 @@ def test_add_rule_unary_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.add_rule_unary(**mock_args) @@ -1993,6 +2001,7 @@ def test_clone_rules_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.clone_rules(request) @@ -2058,6 +2067,7 @@ def test_clone_rules_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.clone_rules(**mock_args) @@ -2210,6 +2220,7 @@ def test_clone_rules_unary_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.clone_rules_unary(request) @@ -2275,6 +2286,7 @@ def test_clone_rules_unary_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.clone_rules_unary(**mock_args) @@ -2422,6 +2434,7 @@ def test_delete_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.delete(request) @@ -2482,6 +2495,7 @@ def test_delete_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.delete(**mock_args) @@ -2629,6 +2643,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2689,6 +2704,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2830,6 +2846,7 @@ def test_get_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(request) @@ -2890,6 +2907,7 @@ def test_get_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(**mock_args) @@ -3033,6 +3051,7 @@ def test_get_association_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_association(request) @@ -3093,6 +3112,7 @@ def test_get_association_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_association(**mock_args) @@ -3248,6 +3268,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -3315,6 +3336,7 @@ def test_get_effective_firewalls_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_effective_firewalls(**mock_args) @@ -3458,6 +3480,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) @@ -3518,6 +3541,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) @@ -3661,6 +3685,7 @@ def test_get_rule_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_rule(request) @@ -3721,6 +3746,7 @@ def test_get_rule_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_rule(**mock_args) @@ -3865,6 +3891,7 @@ def test_insert_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.insert(request) @@ -3927,6 +3954,7 @@ def test_insert_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.insert(**mock_args) @@ -4077,6 +4105,7 @@ def test_insert_unary_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.insert_unary(request) @@ -4139,6 +4168,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -4292,6 +4322,7 @@ def test_list_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.list(request) @@ -4354,6 +4385,7 @@ def test_list_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(**mock_args) @@ -4562,6 +4594,7 @@ def test_patch_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.patch(request) @@ -4630,6 +4663,7 @@ def test_patch_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.patch(**mock_args) @@ -4785,6 +4819,7 @@ def test_patch_unary_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.patch_unary(request) @@ -4853,6 +4888,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -5013,6 +5049,7 @@ def test_patch_rule_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.patch_rule(request) @@ -5082,6 +5119,7 @@ def test_patch_rule_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.patch_rule(**mock_args) @@ -5238,6 +5276,7 @@ def test_patch_rule_unary_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.patch_rule_unary(request) @@ -5307,6 +5346,7 @@ def test_patch_rule_unary_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.patch_rule_unary(**mock_args) @@ -5466,6 +5506,7 @@ def test_remove_association_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.remove_association(request) @@ -5531,6 +5572,7 @@ def test_remove_association_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.remove_association(**mock_args) @@ -5687,6 +5729,7 @@ def test_remove_association_unary_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.remove_association_unary(request) @@ -5752,6 +5795,7 @@ def test_remove_association_unary_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.remove_association_unary(**mock_args) @@ -5904,6 +5948,7 @@ def test_remove_rule_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.remove_rule(request) @@ -5969,6 +6014,7 @@ def test_remove_rule_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.remove_rule(**mock_args) @@ -6121,6 +6167,7 @@ def test_remove_rule_unary_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.remove_rule_unary(request) @@ -6186,6 +6233,7 @@ def test_remove_rule_unary_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.remove_rule_unary(**mock_args) @@ -6328,6 +6376,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) @@ -6392,6 +6441,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) @@ -6541,6 +6591,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) @@ -6605,6 +6656,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) @@ -6746,6 +6798,7 @@ def test_add_association_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.add_association(request) @@ -6890,6 +6943,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.add_association(request) # Establish that the response is the type that we expect. @@ -6951,6 +7005,7 @@ def test_add_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6999,6 +7054,7 @@ def test_add_rule_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.add_rule(request) @@ -7187,6 +7243,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.add_rule(request) # Establish that the response is the type that we expect. @@ -7248,6 +7305,7 @@ def test_add_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7296,6 +7354,7 @@ def test_clone_rules_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.clone_rules(request) @@ -7356,6 +7415,7 @@ def test_clone_rules_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.clone_rules(request) # Establish that the response is the type that we expect. @@ -7417,6 +7477,7 @@ def test_clone_rules_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7465,6 +7526,7 @@ def test_delete_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.delete(request) @@ -7525,6 +7587,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -7586,6 +7649,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7634,6 +7698,7 @@ def test_get_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(request) @@ -7685,6 +7750,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -7737,6 +7803,7 @@ def test_get_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 = compute.FirewallPolicy.to_json(compute.FirewallPolicy()) req.return_value.content = return_value @@ -7785,6 +7852,7 @@ def test_get_association_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_association(request) @@ -7828,6 +7896,7 @@ def test_get_association_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_association(request) # Establish that the response is the type that we expect. @@ -7872,6 +7941,7 @@ def test_get_association_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 = compute.FirewallPolicyAssociation.to_json( compute.FirewallPolicyAssociation() ) @@ -7918,6 +7988,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) @@ -7957,6 +8028,7 @@ def test_get_effective_firewalls_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_effective_firewalls(request) # Establish that the response is the type that we expect. @@ -8000,6 +8072,7 @@ def test_get_effective_firewalls_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 = ( compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse.to_json( compute.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse() @@ -8050,6 +8123,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) @@ -8087,6 +8161,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. @@ -8129,6 +8204,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -8177,6 +8253,7 @@ def test_get_rule_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_rule(request) @@ -8228,6 +8305,7 @@ def test_get_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -8280,6 +8358,7 @@ def test_get_rule_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 = compute.FirewallPolicyRule.to_json(compute.FirewallPolicyRule()) req.return_value.content = return_value @@ -8324,6 +8403,7 @@ def test_insert_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.insert(request) @@ -8539,6 +8619,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.insert(request) # Establish that the response is the type that we expect. @@ -8600,6 +8681,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -8644,6 +8726,7 @@ def test_list_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.list(request) @@ -8681,6 +8764,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -8723,6 +8807,7 @@ def test_list_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 = compute.FirewallPolicyList.to_json(compute.FirewallPolicyList()) req.return_value.content = return_value @@ -8771,6 +8856,7 @@ def test_patch_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.patch(request) @@ -8990,6 +9076,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.patch(request) # Establish that the response is the type that we expect. @@ -9051,6 +9138,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9099,6 +9187,7 @@ def test_patch_rule_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.patch_rule(request) @@ -9287,6 +9376,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.patch_rule(request) # Establish that the response is the type that we expect. @@ -9348,6 +9438,7 @@ def test_patch_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9396,6 +9487,7 @@ def test_remove_association_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.remove_association(request) @@ -9456,6 +9548,7 @@ def test_remove_association_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.remove_association(request) # Establish that the response is the type that we expect. @@ -9519,6 +9612,7 @@ def test_remove_association_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9567,6 +9661,7 @@ def test_remove_rule_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.remove_rule(request) @@ -9627,6 +9722,7 @@ def test_remove_rule_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.remove_rule(request) # Establish that the response is the type that we expect. @@ -9688,6 +9784,7 @@ def test_remove_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -9732,6 +9829,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) @@ -9885,6 +9983,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -9927,6 +10026,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -9971,6 +10071,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) @@ -10086,6 +10187,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -10128,6 +10230,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_notification_endpoints.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_notification_endpoints.py index 66a03f6caa5a..dffefa1e54fb 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_notification_endpoints.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_notification_endpoints.py @@ -1078,6 +1078,7 @@ def test_delete_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.delete(request) @@ -1138,6 +1139,7 @@ def test_delete_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.delete(**mock_args) @@ -1285,6 +1287,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1345,6 +1348,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1486,6 +1490,7 @@ def test_get_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(request) @@ -1546,6 +1551,7 @@ def test_get_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(**mock_args) @@ -1690,6 +1696,7 @@ def test_insert_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.insert(request) @@ -1748,6 +1755,7 @@ def test_insert_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.insert(**mock_args) @@ -1894,6 +1902,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1952,6 +1961,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2101,6 +2111,7 @@ def test_list_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.list(request) @@ -2163,6 +2174,7 @@ def test_list_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(**mock_args) @@ -2361,6 +2373,7 @@ def test_delete_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.delete(request) @@ -2421,6 +2434,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2482,6 +2496,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2530,6 +2545,7 @@ def test_get_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(request) @@ -2575,6 +2591,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2621,6 +2638,7 @@ def test_get_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 = compute.NotificationEndpoint.to_json( compute.NotificationEndpoint() ) @@ -2667,6 +2685,7 @@ def test_insert_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.insert(request) @@ -2814,6 +2833,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.insert(request) # Establish that the response is the type that we expect. @@ -2875,6 +2895,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2919,6 +2940,7 @@ def test_list_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.list(request) @@ -2957,6 +2979,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3000,6 +3023,7 @@ def test_list_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 = compute.NotificationEndpointList.to_json( compute.NotificationEndpointList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_operations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_operations.py index 887773b60a40..4860f6b57518 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_operations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_operations.py @@ -1023,6 +1023,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRegionOperationR 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(request) @@ -1083,6 +1084,7 @@ def test_delete_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.delete(**mock_args) @@ -1222,6 +1224,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionOperationRequest 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(request) @@ -1282,6 +1285,7 @@ def test_get_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(**mock_args) @@ -1427,6 +1431,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionOperationsRequ 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(request) @@ -1489,6 +1494,7 @@ def test_list_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(**mock_args) @@ -1688,6 +1694,7 @@ def test_wait_rest_required_fields(request_type=compute.WaitRegionOperationReque 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.wait(request) @@ -1748,6 +1755,7 @@ def test_wait_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.wait(**mock_args) @@ -1880,6 +1888,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionOperationReque 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(request) @@ -1913,6 +1922,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -1952,6 +1962,7 @@ def test_delete_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 = compute.DeleteRegionOperationResponse.to_json( compute.DeleteRegionOperationResponse() ) @@ -1996,6 +2007,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionOperationRequest): 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(request) @@ -2052,6 +2064,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2113,6 +2126,7 @@ def test_get_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2155,6 +2169,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionOperationsRequest) 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(request) @@ -2193,6 +2208,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2236,6 +2252,7 @@ def test_list_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 = compute.OperationList.to_json(compute.OperationList()) req.return_value.content = return_value @@ -2278,6 +2295,7 @@ def test_wait_rest_bad_request(request_type=compute.WaitRegionOperationRequest): 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.wait(request) @@ -2334,6 +2352,7 @@ def test_wait_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.wait(request) # Establish that the response is the type that we expect. @@ -2395,6 +2414,7 @@ def test_wait_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_security_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_security_policies.py index 4a383ccc74c0..5ea251fdb37f 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_security_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_security_policies.py @@ -1065,6 +1065,7 @@ def test_add_rule_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.add_rule(request) @@ -1129,6 +1130,7 @@ def test_add_rule_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.add_rule(**mock_args) @@ -1280,6 +1282,7 @@ def test_add_rule_unary_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.add_rule_unary(request) @@ -1344,6 +1347,7 @@ def test_add_rule_unary_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.add_rule_unary(**mock_args) @@ -1494,6 +1498,7 @@ def test_delete_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.delete(request) @@ -1554,6 +1559,7 @@ def test_delete_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.delete(**mock_args) @@ -1701,6 +1707,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1761,6 +1768,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1900,6 +1908,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionSecurityPolicyRe 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(request) @@ -1960,6 +1969,7 @@ def test_get_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(**mock_args) @@ -2103,6 +2113,7 @@ def test_get_rule_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_rule(request) @@ -2163,6 +2174,7 @@ def test_get_rule_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_rule(**mock_args) @@ -2312,6 +2324,7 @@ def test_insert_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.insert(request) @@ -2379,6 +2392,7 @@ def test_insert_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.insert(**mock_args) @@ -2534,6 +2548,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2601,6 +2616,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2754,6 +2770,7 @@ def test_list_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.list(request) @@ -2816,6 +2833,7 @@ def test_list_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(**mock_args) @@ -3029,6 +3047,7 @@ def test_patch_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.patch(request) @@ -3102,6 +3121,7 @@ def test_patch_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.patch(**mock_args) @@ -3262,6 +3282,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3335,6 +3356,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3496,6 +3518,7 @@ def test_patch_rule_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.patch_rule(request) @@ -3566,6 +3589,7 @@ def test_patch_rule_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.patch_rule(**mock_args) @@ -3723,6 +3747,7 @@ def test_patch_rule_unary_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.patch_rule_unary(request) @@ -3793,6 +3818,7 @@ def test_patch_rule_unary_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.patch_rule_unary(**mock_args) @@ -3943,6 +3969,7 @@ def test_remove_rule_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.remove_rule(request) @@ -4003,6 +4030,7 @@ def test_remove_rule_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.remove_rule(**mock_args) @@ -4150,6 +4178,7 @@ def test_remove_rule_unary_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.remove_rule_unary(request) @@ -4210,6 +4239,7 @@ def test_remove_rule_unary_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.remove_rule_unary(**mock_args) @@ -4241,6 +4271,440 @@ def test_remove_rule_unary_rest_flattened_error(transport: str = "rest"): ) +def test_set_labels_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.set_labels in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.set_labels] = mock_rpc + + request = {} + client.set_labels(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.set_labels(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_set_labels_rest_required_fields( + request_type=compute.SetLabelsRegionSecurityPolicyRequest, +): + transport_class = transports.RegionSecurityPoliciesRestTransport + + request_init = {} + request_init["project"] = "" + request_init["region"] = "" + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_labels._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_labels(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_set_labels_rest_unset_required_fields(): + transport = transports.RegionSecurityPoliciesRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.set_labels._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "project", + "region", + "regionSetLabelsRequestResource", + "resource", + ) + ) + ) + + +def test_set_labels_rest_flattened(): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "resource": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + resource="resource_value", + region_set_labels_request_resource=compute.RegionSetLabelsRequest( + label_fingerprint="label_fingerprint_value" + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_labels(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/securityPolicies/{resource}/setLabels" + % client.transport._host, + args[1], + ) + + +def test_set_labels_rest_flattened_error(transport: str = "rest"): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.set_labels( + compute.SetLabelsRegionSecurityPolicyRequest(), + project="project_value", + region="region_value", + resource="resource_value", + region_set_labels_request_resource=compute.RegionSetLabelsRequest( + label_fingerprint="label_fingerprint_value" + ), + ) + + +def test_set_labels_unary_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.set_labels in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.set_labels] = mock_rpc + + request = {} + client.set_labels_unary(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.set_labels_unary(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_set_labels_unary_rest_required_fields( + request_type=compute.SetLabelsRegionSecurityPolicyRequest, +): + transport_class = transports.RegionSecurityPoliciesRestTransport + + request_init = {} + request_init["project"] = "" + request_init["region"] = "" + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_labels._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["project"] = "project_value" + jsonified_request["region"] = "region_value" + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_labels._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + assert "region" in jsonified_request + assert jsonified_request["region"] == "region_value" + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_labels_unary(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_set_labels_unary_rest_unset_required_fields(): + transport = transports.RegionSecurityPoliciesRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.set_labels._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("requestId",)) + & set( + ( + "project", + "region", + "regionSetLabelsRequestResource", + "resource", + ) + ) + ) + + +def test_set_labels_unary_rest_flattened(): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project": "sample1", + "region": "sample2", + "resource": "sample3", + } + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + region="region_value", + resource="resource_value", + region_set_labels_request_resource=compute.RegionSetLabelsRequest( + label_fingerprint="label_fingerprint_value" + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_labels_unary(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/regions/{region}/securityPolicies/{resource}/setLabels" + % client.transport._host, + args[1], + ) + + +def test_set_labels_unary_rest_flattened_error(transport: str = "rest"): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.set_labels_unary( + compute.SetLabelsRegionSecurityPolicyRequest(), + project="project_value", + region="region_value", + resource="resource_value", + region_set_labels_request_resource=compute.RegionSetLabelsRequest( + label_fingerprint="label_fingerprint_value" + ), + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.RegionSecurityPoliciesRestTransport( @@ -4348,6 +4812,7 @@ def test_add_rule_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.add_rule(request) @@ -4571,6 +5036,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.add_rule(request) # Establish that the response is the type that we expect. @@ -4632,6 +5098,7 @@ def test_add_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4680,6 +5147,7 @@ def test_delete_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.delete(request) @@ -4740,6 +5208,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4801,6 +5270,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4847,6 +5317,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionSecurityPolicyReques 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(request) @@ -4895,6 +5366,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4944,6 +5416,7 @@ def test_get_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 = compute.SecurityPolicy.to_json(compute.SecurityPolicy()) req.return_value.content = return_value @@ -4992,6 +5465,7 @@ def test_get_rule_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_rule(request) @@ -5035,6 +5509,7 @@ def test_get_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -5079,6 +5554,7 @@ def test_get_rule_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 = compute.SecurityPolicyRule.to_json(compute.SecurityPolicyRule()) req.return_value.content = return_value @@ -5123,6 +5599,7 @@ def test_insert_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.insert(request) @@ -5412,6 +5889,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.insert(request) # Establish that the response is the type that we expect. @@ -5473,6 +5951,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5515,6 +5994,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionSecurityPoliciesRe 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(request) @@ -5552,6 +6032,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5594,6 +6075,7 @@ def test_list_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 = compute.SecurityPolicyList.to_json(compute.SecurityPolicyList()) req.return_value.content = return_value @@ -5640,6 +6122,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionSecurityPolicyRe 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.patch(request) @@ -5933,6 +6416,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.patch(request) # Establish that the response is the type that we expect. @@ -5994,6 +6478,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6042,6 +6527,7 @@ def test_patch_rule_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.patch_rule(request) @@ -6265,6 +6751,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.patch_rule(request) # Establish that the response is the type that we expect. @@ -6326,6 +6813,7 @@ def test_patch_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6374,6 +6862,7 @@ def test_remove_rule_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.remove_rule(request) @@ -6434,6 +6923,7 @@ def test_remove_rule_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.remove_rule(request) # Establish that the response is the type that we expect. @@ -6495,6 +6985,7 @@ def test_remove_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6518,6 +7009,249 @@ def test_remove_rule_rest_interceptors(null_interceptor): post.assert_called_once() +def test_set_labels_rest_bad_request( + request_type=compute.SetLabelsRegionSecurityPolicyRequest, +): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"project": "sample1", "region": "sample2", "resource": "sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + 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_labels(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.SetLabelsRegionSecurityPolicyRequest, + dict, + ], +) +def test_set_labels_rest_call_success(request_type): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"project": "sample1", "region": "sample2", "resource": "sample3"} + request_init["region_set_labels_request_resource"] = { + "label_fingerprint": "label_fingerprint_value", + "labels": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = compute.SetLabelsRegionSecurityPolicyRequest.meta.fields[ + "region_set_labels_request_resource" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "region_set_labels_request_resource" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range( + 0, len(request_init["region_set_labels_request_resource"][field]) + ): + del request_init["region_set_labels_request_resource"][field][i][ + subfield + ] + else: + del request_init["region_set_labels_request_resource"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.Operation( + client_operation_id="client_operation_id_value", + creation_timestamp="creation_timestamp_value", + description="description_value", + end_time="end_time_value", + http_error_message="http_error_message_value", + http_error_status_code=2374, + id=205, + insert_time="insert_time_value", + kind="kind_value", + name="name_value", + operation_group_id="operation_group_id_value", + operation_type="operation_type_value", + progress=885, + region="region_value", + self_link="self_link_value", + start_time="start_time_value", + status=compute.Operation.Status.DONE, + status_message="status_message_value", + target_id=947, + target_link="target_link_value", + user="user_value", + zone="zone_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.Operation.pb(return_value) + 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_labels(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, extended_operation.ExtendedOperation) + assert response.client_operation_id == "client_operation_id_value" + assert response.creation_timestamp == "creation_timestamp_value" + assert response.description == "description_value" + assert response.end_time == "end_time_value" + assert response.http_error_message == "http_error_message_value" + assert response.http_error_status_code == 2374 + assert response.id == 205 + assert response.insert_time == "insert_time_value" + assert response.kind == "kind_value" + assert response.name == "name_value" + assert response.operation_group_id == "operation_group_id_value" + assert response.operation_type == "operation_type_value" + assert response.progress == 885 + assert response.region == "region_value" + assert response.self_link == "self_link_value" + assert response.start_time == "start_time_value" + assert response.status == compute.Operation.Status.DONE + assert response.status_message == "status_message_value" + assert response.target_id == 947 + assert response.target_link == "target_link_value" + assert response.user == "user_value" + assert response.zone == "zone_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_set_labels_rest_interceptors(null_interceptor): + transport = transports.RegionSecurityPoliciesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.RegionSecurityPoliciesRestInterceptor(), + ) + client = RegionSecurityPoliciesClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.RegionSecurityPoliciesRestInterceptor, "post_set_labels" + ) as post, mock.patch.object( + transports.RegionSecurityPoliciesRestInterceptor, "pre_set_labels" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.SetLabelsRegionSecurityPolicyRequest.pb( + compute.SetLabelsRegionSecurityPolicyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + 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 = compute.Operation.to_json(compute.Operation()) + req.return_value.content = return_value + + request = compute.SetLabelsRegionSecurityPolicyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.Operation() + + client.set_labels( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + def test_initialize_client_w_rest(): client = RegionSecurityPoliciesClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -6705,6 +7439,26 @@ def test_remove_rule_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_set_labels_unary_empty_call_rest(): + client = RegionSecurityPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.set_labels), "__call__") as call: + client.set_labels_unary(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.SetLabelsRegionSecurityPolicyRequest() + + assert args[0] == request_msg + + def test_region_security_policies_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): @@ -6736,6 +7490,7 @@ def test_region_security_policies_base_transport(): "patch", "patch_rule", "remove_rule", + "set_labels", ) for method in methods: with pytest.raises(NotImplementedError): @@ -6900,6 +7655,9 @@ def test_region_security_policies_client_transport_session_collision(transport_n session1 = client1.transport.remove_rule._session session2 = client2.transport.remove_rule._session assert session1 != session2 + session1 = client1.transport.set_labels._session + session2 = client2.transport.set_labels._session + assert session1 != session2 def test_common_billing_account_path(): diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_certificates.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_certificates.py index 15c39dff4cae..75098aa5ddc2 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_certificates.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_certificates.py @@ -1062,6 +1062,7 @@ def test_delete_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.delete(request) @@ -1122,6 +1123,7 @@ def test_delete_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.delete(**mock_args) @@ -1269,6 +1271,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1329,6 +1332,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1468,6 +1472,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionSslCertificateRe 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(request) @@ -1528,6 +1533,7 @@ def test_get_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(**mock_args) @@ -1672,6 +1678,7 @@ def test_insert_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.insert(request) @@ -1730,6 +1737,7 @@ def test_insert_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.insert(**mock_args) @@ -1876,6 +1884,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1934,6 +1943,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2083,6 +2093,7 @@ def test_list_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.list(request) @@ -2145,6 +2156,7 @@ def test_list_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(**mock_args) @@ -2343,6 +2355,7 @@ def test_delete_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.delete(request) @@ -2403,6 +2416,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2464,6 +2478,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2510,6 +2525,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionSslCertificateReques 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(request) @@ -2560,6 +2576,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2611,6 +2628,7 @@ def test_get_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 = compute.SslCertificate.to_json(compute.SslCertificate()) req.return_value.content = return_value @@ -2655,6 +2673,7 @@ def test_insert_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.insert(request) @@ -2808,6 +2827,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.insert(request) # Establish that the response is the type that we expect. @@ -2869,6 +2889,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2911,6 +2932,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionSslCertificatesReq 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(request) @@ -2949,6 +2971,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2992,6 +3015,7 @@ def test_list_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 = compute.SslCertificateList.to_json(compute.SslCertificateList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_policies.py index 6c3b759a4e5c..11b1a2056765 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_ssl_policies.py @@ -1044,6 +1044,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRegionSslPolicyR 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(request) @@ -1104,6 +1105,7 @@ def test_delete_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.delete(**mock_args) @@ -1251,6 +1253,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1311,6 +1314,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1450,6 +1454,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionSslPolicyRequest 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(request) @@ -1510,6 +1515,7 @@ def test_get_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(**mock_args) @@ -1652,6 +1658,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertRegionSslPolicyR 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.insert(request) @@ -1710,6 +1717,7 @@ def test_insert_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.insert(**mock_args) @@ -1856,6 +1864,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1914,6 +1923,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2061,6 +2071,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionSslPoliciesReq 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(request) @@ -2123,6 +2134,7 @@ def test_list_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(**mock_args) @@ -2337,6 +2349,7 @@ def test_list_available_features_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.list_available_features(request) @@ -2399,6 +2412,7 @@ def test_list_available_features_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_available_features(**mock_args) @@ -2544,6 +2558,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchRegionSslPolicyReq 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.patch(request) @@ -2608,6 +2623,7 @@ def test_patch_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.patch(**mock_args) @@ -2759,6 +2775,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2823,6 +2840,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2958,6 +2976,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionSslPolicyReque 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(request) @@ -3014,6 +3033,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3075,6 +3095,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3117,6 +3138,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionSslPolicyRequest): 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(request) @@ -3163,6 +3185,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3214,6 +3237,7 @@ def test_get_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 = compute.SslPolicy.to_json(compute.SslPolicy()) req.return_value.content = return_value @@ -3256,6 +3280,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionSslPolicyReque 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.insert(request) @@ -3400,6 +3425,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.insert(request) # Establish that the response is the type that we expect. @@ -3461,6 +3487,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3503,6 +3530,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionSslPoliciesRequest 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(request) @@ -3541,6 +3569,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3584,6 +3613,7 @@ def test_list_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 = compute.SslPoliciesList.to_json(compute.SslPoliciesList()) req.return_value.content = return_value @@ -3628,6 +3658,7 @@ def test_list_available_features_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.list_available_features(request) @@ -3663,6 +3694,7 @@ def test_list_available_features_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_available_features(request) # Establish that the response is the type that we expect. @@ -3703,6 +3735,7 @@ def test_list_available_features_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 = compute.SslPoliciesListAvailableFeaturesResponse.to_json( compute.SslPoliciesListAvailableFeaturesResponse() ) @@ -3747,6 +3780,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionSslPolicyRequest 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.patch(request) @@ -3891,6 +3925,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.patch(request) # Establish that the response is the type that we expect. @@ -3952,6 +3987,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_http_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_http_proxies.py index 2bafa4c8a6c9..e81cc1f8f8ae 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_http_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_http_proxies.py @@ -1064,6 +1064,7 @@ def test_delete_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.delete(request) @@ -1124,6 +1125,7 @@ def test_delete_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.delete(**mock_args) @@ -1271,6 +1273,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1331,6 +1334,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1470,6 +1474,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionTargetHttpProxyR 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(request) @@ -1530,6 +1535,7 @@ def test_get_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(**mock_args) @@ -1674,6 +1680,7 @@ def test_insert_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.insert(request) @@ -1732,6 +1739,7 @@ def test_insert_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.insert(**mock_args) @@ -1878,6 +1886,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1936,6 +1945,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2085,6 +2095,7 @@ def test_list_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.list(request) @@ -2147,6 +2158,7 @@ def test_list_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(**mock_args) @@ -2355,6 +2367,7 @@ def test_set_url_map_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_url_map(request) @@ -2417,6 +2430,7 @@ def test_set_url_map_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_url_map(**mock_args) @@ -2566,6 +2580,7 @@ def test_set_url_map_unary_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_url_map_unary(request) @@ -2628,6 +2643,7 @@ def test_set_url_map_unary_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_url_map_unary(**mock_args) @@ -2767,6 +2783,7 @@ def test_delete_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.delete(request) @@ -2827,6 +2844,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2888,6 +2906,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2934,6 +2953,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionTargetHttpProxyReque 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(request) @@ -2983,6 +3003,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3033,6 +3054,7 @@ def test_get_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 = compute.TargetHttpProxy.to_json(compute.TargetHttpProxy()) req.return_value.content = return_value @@ -3077,6 +3099,7 @@ def test_insert_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.insert(request) @@ -3219,6 +3242,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.insert(request) # Establish that the response is the type that we expect. @@ -3280,6 +3304,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3322,6 +3347,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionTargetHttpProxiesR 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(request) @@ -3360,6 +3386,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3403,6 +3430,7 @@ def test_list_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 = compute.TargetHttpProxyList.to_json( compute.TargetHttpProxyList() ) @@ -3453,6 +3481,7 @@ def test_set_url_map_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_url_map(request) @@ -3587,6 +3616,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.set_url_map(request) # Establish that the response is the type that we expect. @@ -3648,6 +3678,7 @@ def test_set_url_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_https_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_https_proxies.py index d6a017a104a8..22815fda5a23 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_https_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_https_proxies.py @@ -1068,6 +1068,7 @@ def test_delete_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.delete(request) @@ -1128,6 +1129,7 @@ def test_delete_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.delete(**mock_args) @@ -1275,6 +1277,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1335,6 +1338,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1476,6 +1480,7 @@ def test_get_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(request) @@ -1536,6 +1541,7 @@ def test_get_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(**mock_args) @@ -1680,6 +1686,7 @@ def test_insert_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.insert(request) @@ -1738,6 +1745,7 @@ def test_insert_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.insert(**mock_args) @@ -1884,6 +1892,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1942,6 +1951,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2091,6 +2101,7 @@ def test_list_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.list(request) @@ -2153,6 +2164,7 @@ def test_list_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(**mock_args) @@ -2361,6 +2373,7 @@ def test_patch_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.patch(request) @@ -2425,6 +2438,7 @@ def test_patch_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.patch(**mock_args) @@ -2576,6 +2590,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2640,6 +2655,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2795,6 +2811,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -2859,6 +2876,7 @@ def test_set_ssl_certificates_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_ssl_certificates(**mock_args) @@ -3014,6 +3032,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(request) @@ -3078,6 +3097,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(**mock_args) @@ -3229,6 +3249,7 @@ def test_set_url_map_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_url_map(request) @@ -3291,6 +3312,7 @@ def test_set_url_map_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_url_map(**mock_args) @@ -3440,6 +3462,7 @@ def test_set_url_map_unary_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_url_map_unary(request) @@ -3502,6 +3525,7 @@ def test_set_url_map_unary_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_url_map_unary(**mock_args) @@ -3641,6 +3665,7 @@ def test_delete_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.delete(request) @@ -3701,6 +3726,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3762,6 +3788,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3808,6 +3835,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionTargetHttpsProxyRequ 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(request) @@ -3864,6 +3892,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3921,6 +3950,7 @@ def test_get_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 = compute.TargetHttpsProxy.to_json(compute.TargetHttpsProxy()) req.return_value.content = return_value @@ -3965,6 +3995,7 @@ def test_insert_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.insert(request) @@ -4114,6 +4145,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.insert(request) # Establish that the response is the type that we expect. @@ -4175,6 +4207,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4219,6 +4252,7 @@ def test_list_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.list(request) @@ -4257,6 +4291,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4300,6 +4335,7 @@ def test_list_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 = compute.TargetHttpsProxyList.to_json( compute.TargetHttpsProxyList() ) @@ -4350,6 +4386,7 @@ def test_patch_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.patch(request) @@ -4503,6 +4540,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.patch(request) # Establish that the response is the type that we expect. @@ -4564,6 +4602,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4612,6 +4651,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -4757,6 +4797,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.set_ssl_certificates(request) # Establish that the response is the type that we expect. @@ -4818,6 +4859,7 @@ def test_set_ssl_certificates_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4866,6 +4908,7 @@ def test_set_url_map_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_url_map(request) @@ -5000,6 +5043,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.set_url_map(request) # Establish that the response is the type that we expect. @@ -5061,6 +5105,7 @@ def test_set_url_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_tcp_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_tcp_proxies.py index 9452891c094e..56de523ac378 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_tcp_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_target_tcp_proxies.py @@ -1064,6 +1064,7 @@ def test_delete_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.delete(request) @@ -1124,6 +1125,7 @@ def test_delete_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.delete(**mock_args) @@ -1271,6 +1273,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1331,6 +1334,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1470,6 +1474,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionTargetTcpProxyRe 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(request) @@ -1530,6 +1535,7 @@ def test_get_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(**mock_args) @@ -1674,6 +1680,7 @@ def test_insert_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.insert(request) @@ -1732,6 +1739,7 @@ def test_insert_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.insert(**mock_args) @@ -1878,6 +1886,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1936,6 +1945,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2085,6 +2095,7 @@ def test_list_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.list(request) @@ -2147,6 +2158,7 @@ def test_list_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(**mock_args) @@ -2345,6 +2357,7 @@ def test_delete_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.delete(request) @@ -2405,6 +2418,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2466,6 +2480,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2512,6 +2527,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionTargetTcpProxyReques 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(request) @@ -2560,6 +2576,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2609,6 +2626,7 @@ def test_get_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 = compute.TargetTcpProxy.to_json(compute.TargetTcpProxy()) req.return_value.content = return_value @@ -2653,6 +2671,7 @@ def test_insert_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.insert(request) @@ -2794,6 +2813,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.insert(request) # Establish that the response is the type that we expect. @@ -2855,6 +2875,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2897,6 +2918,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionTargetTcpProxiesRe 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(request) @@ -2935,6 +2957,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2978,6 +3001,7 @@ def test_list_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 = compute.TargetTcpProxyList.to_json(compute.TargetTcpProxyList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_url_maps.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_url_maps.py index ee5c2b559929..9f478dfa904d 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_url_maps.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_url_maps.py @@ -1012,6 +1012,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRegionUrlMapRequ 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(request) @@ -1072,6 +1073,7 @@ def test_delete_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.delete(**mock_args) @@ -1219,6 +1221,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1279,6 +1282,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1418,6 +1422,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionUrlMapRequest): 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(request) @@ -1478,6 +1483,7 @@ def test_get_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(**mock_args) @@ -1620,6 +1626,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertRegionUrlMapRequ 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.insert(request) @@ -1678,6 +1685,7 @@ def test_insert_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.insert(**mock_args) @@ -1824,6 +1832,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1882,6 +1891,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2029,6 +2039,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionUrlMapsRequest 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(request) @@ -2091,6 +2102,7 @@ def test_list_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(**mock_args) @@ -2297,6 +2309,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchRegionUrlMapReques 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.patch(request) @@ -2361,6 +2374,7 @@ def test_patch_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.patch(**mock_args) @@ -2512,6 +2526,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2576,6 +2591,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2725,6 +2741,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateRegionUrlMapRequ 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(request) @@ -2789,6 +2806,7 @@ def test_update_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(**mock_args) @@ -2940,6 +2958,7 @@ def test_update_unary_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.update_unary(request) @@ -3004,6 +3023,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3149,6 +3169,7 @@ def test_validate_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.validate(request) @@ -3213,6 +3234,7 @@ def test_validate_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.validate(**mock_args) @@ -3348,6 +3370,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRegionUrlMapRequest) 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(request) @@ -3404,6 +3427,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3465,6 +3489,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3507,6 +3532,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionUrlMapRequest): 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(request) @@ -3550,6 +3576,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3596,6 +3623,7 @@ def test_get_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 = compute.UrlMap.to_json(compute.UrlMap()) req.return_value.content = return_value @@ -3638,6 +3666,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRegionUrlMapRequest) 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.insert(request) @@ -3948,6 +3977,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.insert(request) # Establish that the response is the type that we expect. @@ -4009,6 +4039,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4051,6 +4082,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionUrlMapsRequest): 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(request) @@ -4089,6 +4121,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4132,6 +4165,7 @@ def test_list_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 = compute.UrlMapList.to_json(compute.UrlMapList()) req.return_value.content = return_value @@ -4174,6 +4208,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRegionUrlMapRequest): 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.patch(request) @@ -4484,6 +4519,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.patch(request) # Establish that the response is the type that we expect. @@ -4545,6 +4581,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4587,6 +4624,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRegionUrlMapRequest) 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(request) @@ -4897,6 +4935,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(request) # Establish that the response is the type that we expect. @@ -4958,6 +4997,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5000,6 +5040,7 @@ def test_validate_rest_bad_request(request_type=compute.ValidateRegionUrlMapRequ 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.validate(request) @@ -5305,6 +5346,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.validate(request) # Establish that the response is the type that we expect. @@ -5344,6 +5386,7 @@ def test_validate_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 = compute.UrlMapsValidateResponse.to_json( compute.UrlMapsValidateResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_zones.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_zones.py index 52330f10a499..bd45824b687a 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_zones.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_region_zones.py @@ -988,6 +988,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionZonesRequest): 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(request) @@ -1050,6 +1051,7 @@ def test_list_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(**mock_args) @@ -1242,6 +1244,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionZonesRequest): 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(request) @@ -1280,6 +1283,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1321,6 +1325,7 @@ def test_list_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 = compute.ZoneList.to_json(compute.ZoneList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_regions.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_regions.py index c90bf14c6e22..8ca019192b86 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_regions.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_regions.py @@ -954,6 +954,7 @@ def test_get_rest_required_fields(request_type=compute.GetRegionRequest): 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(request) @@ -1008,6 +1009,7 @@ def test_get_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(**mock_args) @@ -1148,6 +1150,7 @@ def test_list_rest_required_fields(request_type=compute.ListRegionsRequest): 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(request) @@ -1204,6 +1207,7 @@ def test_list_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(**mock_args) @@ -1393,6 +1397,7 @@ def test_get_rest_bad_request(request_type=compute.GetRegionRequest): 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(request) @@ -1436,6 +1441,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1480,6 +1486,7 @@ def test_get_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 = compute.Region.to_json(compute.Region()) req.return_value.content = return_value @@ -1522,6 +1529,7 @@ def test_list_rest_bad_request(request_type=compute.ListRegionsRequest): 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(request) @@ -1560,6 +1568,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1599,6 +1608,7 @@ def test_list_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 = compute.RegionList.to_json(compute.RegionList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_reservations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_reservations.py index 9ba74b308889..a46d872f9272 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_reservations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_reservations.py @@ -999,6 +999,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1057,6 +1058,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1273,6 +1275,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteReservationReque 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(request) @@ -1333,6 +1336,7 @@ def test_delete_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.delete(**mock_args) @@ -1480,6 +1484,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1540,6 +1545,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1679,6 +1685,7 @@ def test_get_rest_required_fields(request_type=compute.GetReservationRequest): 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(request) @@ -1739,6 +1746,7 @@ def test_get_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(**mock_args) @@ -1882,6 +1890,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) @@ -1942,6 +1951,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) @@ -2084,6 +2094,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertReservationReque 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.insert(request) @@ -2150,6 +2161,7 @@ def test_insert_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.insert(**mock_args) @@ -2304,6 +2316,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2370,6 +2383,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2525,6 +2539,7 @@ def test_list_rest_required_fields(request_type=compute.ListReservationsRequest) 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(request) @@ -2587,6 +2602,7 @@ def test_list_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(**mock_args) @@ -2793,6 +2809,7 @@ def test_resize_rest_required_fields(request_type=compute.ResizeReservationReque 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.resize(request) @@ -2857,6 +2874,7 @@ def test_resize_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.resize(**mock_args) @@ -3008,6 +3026,7 @@ def test_resize_unary_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.resize_unary(request) @@ -3072,6 +3091,7 @@ def test_resize_unary_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.resize_unary(**mock_args) @@ -3217,6 +3237,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) @@ -3281,6 +3302,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) @@ -3430,6 +3452,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) @@ -3494,6 +3517,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) @@ -3649,6 +3673,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateReservationReque 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(request) @@ -3727,6 +3752,7 @@ def test_update_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(**mock_args) @@ -3892,6 +3918,7 @@ def test_update_unary_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.update_unary(request) @@ -3970,6 +3997,7 @@ def test_update_unary_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_unary(**mock_args) @@ -4115,6 +4143,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -4154,6 +4183,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -4198,6 +4228,7 @@ def test_aggregated_list_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 = compute.ReservationAggregatedList.to_json( compute.ReservationAggregatedList() ) @@ -4242,6 +4273,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteReservationRequest): 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(request) @@ -4298,6 +4330,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4359,6 +4392,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4401,6 +4435,7 @@ def test_get_rest_bad_request(request_type=compute.GetReservationRequest): 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(request) @@ -4446,6 +4481,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4494,6 +4530,7 @@ def test_get_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 = compute.Reservation.to_json(compute.Reservation()) req.return_value.content = return_value @@ -4538,6 +4575,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) @@ -4575,6 +4613,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. @@ -4617,6 +4656,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4659,6 +4699,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertReservationRequest): 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.insert(request) @@ -4835,6 +4876,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.insert(request) # Establish that the response is the type that we expect. @@ -4896,6 +4938,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4938,6 +4981,7 @@ def test_list_rest_bad_request(request_type=compute.ListReservationsRequest): 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(request) @@ -4976,6 +5020,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5019,6 +5064,7 @@ def test_list_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 = compute.ReservationList.to_json(compute.ReservationList()) req.return_value.content = return_value @@ -5061,6 +5107,7 @@ def test_resize_rest_bad_request(request_type=compute.ResizeReservationRequest): 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.resize(request) @@ -5195,6 +5242,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.resize(request) # Establish that the response is the type that we expect. @@ -5256,6 +5304,7 @@ def test_resize_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5300,6 +5349,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) @@ -5453,6 +5503,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5495,6 +5546,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5539,6 +5591,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) @@ -5652,6 +5705,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5692,6 +5746,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -5736,6 +5791,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateReservationRequest): 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(request) @@ -5912,6 +5968,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(request) # Establish that the response is the type that we expect. @@ -5973,6 +6030,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_resource_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_resource_policies.py index c0bf8b296a45..c4136e611dbc 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_resource_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_resource_policies.py @@ -1036,6 +1036,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1094,6 +1095,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1312,6 +1314,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteResourcePolicyRe 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(request) @@ -1372,6 +1375,7 @@ def test_delete_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.delete(**mock_args) @@ -1519,6 +1523,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1579,6 +1584,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1718,6 +1724,7 @@ def test_get_rest_required_fields(request_type=compute.GetResourcePolicyRequest) 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(request) @@ -1778,6 +1785,7 @@ def test_get_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(**mock_args) @@ -1921,6 +1929,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) @@ -1981,6 +1990,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) @@ -2123,6 +2133,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertResourcePolicyRe 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.insert(request) @@ -2181,6 +2192,7 @@ def test_insert_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.insert(**mock_args) @@ -2327,6 +2339,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2385,6 +2398,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2532,6 +2546,7 @@ def test_list_rest_required_fields(request_type=compute.ListResourcePoliciesRequ 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(request) @@ -2594,6 +2609,7 @@ def test_list_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(**mock_args) @@ -2805,6 +2821,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchResourcePolicyRequ 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.patch(request) @@ -2874,6 +2891,7 @@ def test_patch_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.patch(**mock_args) @@ -3030,6 +3048,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3099,6 +3118,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3244,6 +3264,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) @@ -3308,6 +3329,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) @@ -3457,6 +3479,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) @@ -3521,6 +3544,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) @@ -3658,6 +3682,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3698,6 +3723,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3743,6 +3769,7 @@ def test_aggregated_list_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 = compute.ResourcePolicyAggregatedList.to_json( compute.ResourcePolicyAggregatedList() ) @@ -3791,6 +3818,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteResourcePolicyReques 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(request) @@ -3851,6 +3879,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3912,6 +3941,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3958,6 +3988,7 @@ def test_get_rest_bad_request(request_type=compute.GetResourcePolicyRequest): 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(request) @@ -4004,6 +4035,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4051,6 +4083,7 @@ def test_get_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 = compute.ResourcePolicy.to_json(compute.ResourcePolicy()) req.return_value.content = return_value @@ -4095,6 +4128,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) @@ -4132,6 +4166,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. @@ -4174,6 +4209,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4216,6 +4252,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertResourcePolicyReques 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.insert(request) @@ -4408,6 +4445,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.insert(request) # Establish that the response is the type that we expect. @@ -4469,6 +4507,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4511,6 +4550,7 @@ def test_list_rest_bad_request(request_type=compute.ListResourcePoliciesRequest) 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(request) @@ -4550,6 +4590,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4594,6 +4635,7 @@ def test_list_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 = compute.ResourcePolicyList.to_json(compute.ResourcePolicyList()) req.return_value.content = return_value @@ -4640,6 +4682,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchResourcePolicyRequest) 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.patch(request) @@ -4836,6 +4879,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.patch(request) # Establish that the response is the type that we expect. @@ -4897,6 +4941,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4941,6 +4986,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) @@ -5094,6 +5140,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5136,6 +5183,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5180,6 +5228,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) @@ -5293,6 +5342,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5333,6 +5383,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routers.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routers.py index 21c00c53ee6c..9655b229f31f 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routers.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routers.py @@ -971,6 +971,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1029,6 +1030,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1242,6 +1244,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRouterRequest): 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(request) @@ -1302,6 +1305,7 @@ def test_delete_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.delete(**mock_args) @@ -1447,6 +1451,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteRouterRequ 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_unary(request) @@ -1507,6 +1512,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1646,6 +1652,7 @@ def test_get_rest_required_fields(request_type=compute.GetRouterRequest): 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(request) @@ -1706,6 +1713,7 @@ def test_get_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(**mock_args) @@ -1849,6 +1857,7 @@ def test_get_nat_ip_info_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_nat_ip_info(request) @@ -1909,6 +1918,7 @@ def test_get_nat_ip_info_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_nat_ip_info(**mock_args) @@ -2065,6 +2075,7 @@ def test_get_nat_mapping_info_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_nat_mapping_info(request) @@ -2134,6 +2145,7 @@ def test_get_nat_mapping_info_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_nat_mapping_info(**mock_args) @@ -2342,6 +2354,7 @@ def test_get_router_status_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_router_status(request) @@ -2402,6 +2415,7 @@ def test_get_router_status_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_router_status(**mock_args) @@ -2544,6 +2558,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertRouterRequest): 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.insert(request) @@ -2602,6 +2617,7 @@ def test_insert_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.insert(**mock_args) @@ -2746,6 +2762,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertRouterRequ 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.insert_unary(request) @@ -2804,6 +2821,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2951,6 +2969,7 @@ def test_list_rest_required_fields(request_type=compute.ListRoutersRequest): 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(request) @@ -3013,6 +3032,7 @@ def test_list_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(**mock_args) @@ -3219,6 +3239,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchRouterRequest): 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.patch(request) @@ -3283,6 +3304,7 @@ def test_patch_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.patch(**mock_args) @@ -3432,6 +3454,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchRouterReques 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.patch_unary(request) @@ -3496,6 +3519,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3639,6 +3663,7 @@ def test_preview_rest_required_fields(request_type=compute.PreviewRouterRequest) 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.preview(request) @@ -3703,6 +3728,7 @@ def test_preview_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.preview(**mock_args) @@ -3852,6 +3878,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateRouterRequest): 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(request) @@ -3916,6 +3943,7 @@ def test_update_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(**mock_args) @@ -4065,6 +4093,7 @@ def test_update_unary_rest_required_fields(request_type=compute.UpdateRouterRequ 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_unary(request) @@ -4129,6 +4158,7 @@ def test_update_unary_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_unary(**mock_args) @@ -4266,6 +4296,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -4305,6 +4336,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -4347,6 +4379,7 @@ def test_aggregated_list_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 = compute.RouterAggregatedList.to_json( compute.RouterAggregatedList() ) @@ -4391,6 +4424,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRouterRequest): 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(request) @@ -4447,6 +4481,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4504,6 +4539,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4546,6 +4582,7 @@ def test_get_rest_bad_request(request_type=compute.GetRouterRequest): 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(request) @@ -4589,6 +4626,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4633,6 +4671,7 @@ def test_get_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 = compute.Router.to_json(compute.Router()) req.return_value.content = return_value @@ -4677,6 +4716,7 @@ def test_get_nat_ip_info_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_nat_ip_info(request) @@ -4710,6 +4750,7 @@ def test_get_nat_ip_info_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_nat_ip_info(request) # Establish that the response is the type that we expect. @@ -4747,6 +4788,7 @@ def test_get_nat_ip_info_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 = compute.NatIpInfoResponse.to_json(compute.NatIpInfoResponse()) req.return_value.content = return_value @@ -4791,6 +4833,7 @@ def test_get_nat_mapping_info_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_nat_mapping_info(request) @@ -4829,6 +4872,7 @@ def test_get_nat_mapping_info_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_nat_mapping_info(request) # Establish that the response is the type that we expect. @@ -4870,6 +4914,7 @@ def test_get_nat_mapping_info_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 = compute.VmEndpointNatMappingsList.to_json( compute.VmEndpointNatMappingsList() ) @@ -4916,6 +4961,7 @@ def test_get_router_status_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_router_status(request) @@ -4951,6 +4997,7 @@ def test_get_router_status_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_router_status(request) # Establish that the response is the type that we expect. @@ -4989,6 +5036,7 @@ def test_get_router_status_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 = compute.RouterStatusResponse.to_json( compute.RouterStatusResponse() ) @@ -5033,6 +5081,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRouterRequest): 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.insert(request) @@ -5290,6 +5339,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.insert(request) # Establish that the response is the type that we expect. @@ -5347,6 +5397,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5389,6 +5440,7 @@ def test_list_rest_bad_request(request_type=compute.ListRoutersRequest): 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(request) @@ -5427,6 +5479,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5466,6 +5519,7 @@ def test_list_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 = compute.RouterList.to_json(compute.RouterList()) req.return_value.content = return_value @@ -5508,6 +5562,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchRouterRequest): 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.patch(request) @@ -5765,6 +5820,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.patch(request) # Establish that the response is the type that we expect. @@ -5822,6 +5878,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5864,6 +5921,7 @@ def test_preview_rest_bad_request(request_type=compute.PreviewRouterRequest): 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.preview(request) @@ -6098,6 +6156,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.preview(request) # Establish that the response is the type that we expect. @@ -6133,6 +6192,7 @@ def test_preview_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 = compute.RoutersPreviewResponse.to_json( compute.RoutersPreviewResponse() ) @@ -6177,6 +6237,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateRouterRequest): 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(request) @@ -6434,6 +6495,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(request) # Establish that the response is the type that we expect. @@ -6491,6 +6553,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routes.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routes.py index 889a91f49b9c..c484a3fe491d 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routes.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_routes.py @@ -966,6 +966,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteRouteRequest): 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(request) @@ -1020,6 +1021,7 @@ def test_delete_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.delete(**mock_args) @@ -1160,6 +1162,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteRouteReque 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_unary(request) @@ -1214,6 +1217,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1348,6 +1352,7 @@ def test_get_rest_required_fields(request_type=compute.GetRouteRequest): 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(request) @@ -1402,6 +1407,7 @@ def test_get_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(**mock_args) @@ -1539,6 +1545,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertRouteRequest): 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.insert(request) @@ -1595,6 +1602,7 @@ def test_insert_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.insert(**mock_args) @@ -1733,6 +1741,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertRouteReque 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.insert_unary(request) @@ -1789,6 +1798,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -1930,6 +1940,7 @@ def test_list_rest_required_fields(request_type=compute.ListRoutesRequest): 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(request) @@ -1986,6 +1997,7 @@ def test_list_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(**mock_args) @@ -2176,6 +2188,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteRouteRequest): 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(request) @@ -2232,6 +2245,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2289,6 +2303,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2331,6 +2346,7 @@ def test_get_rest_bad_request(request_type=compute.GetRouteRequest): 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(request) @@ -2365,8 +2381,11 @@ def test_get_rest_call_success(request_type): next_hop_hub="next_hop_hub_value", next_hop_ilb="next_hop_ilb_value", next_hop_instance="next_hop_instance_value", + next_hop_inter_region_cost=2785, next_hop_ip="next_hop_ip_value", + next_hop_med=1274, next_hop_network="next_hop_network_value", + next_hop_origin="next_hop_origin_value", next_hop_peering="next_hop_peering_value", next_hop_vpn_tunnel="next_hop_vpn_tunnel_value", priority=898, @@ -2385,6 +2404,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2400,8 +2420,11 @@ def test_get_rest_call_success(request_type): assert response.next_hop_hub == "next_hop_hub_value" assert response.next_hop_ilb == "next_hop_ilb_value" assert response.next_hop_instance == "next_hop_instance_value" + assert response.next_hop_inter_region_cost == 2785 assert response.next_hop_ip == "next_hop_ip_value" + assert response.next_hop_med == 1274 assert response.next_hop_network == "next_hop_network_value" + assert response.next_hop_origin == "next_hop_origin_value" assert response.next_hop_peering == "next_hop_peering_value" assert response.next_hop_vpn_tunnel == "next_hop_vpn_tunnel_value" assert response.priority == 898 @@ -2440,6 +2463,7 @@ def test_get_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 = compute.Route.to_json(compute.Route()) req.return_value.content = return_value @@ -2482,6 +2506,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertRouteRequest): 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.insert(request) @@ -2514,8 +2539,11 @@ def test_insert_rest_call_success(request_type): "next_hop_hub": "next_hop_hub_value", "next_hop_ilb": "next_hop_ilb_value", "next_hop_instance": "next_hop_instance_value", + "next_hop_inter_region_cost": 2785, "next_hop_ip": "next_hop_ip_value", + "next_hop_med": 1274, "next_hop_network": "next_hop_network_value", + "next_hop_origin": "next_hop_origin_value", "next_hop_peering": "next_hop_peering_value", "next_hop_vpn_tunnel": "next_hop_vpn_tunnel_value", "priority": 898, @@ -2637,6 +2665,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.insert(request) # Establish that the response is the type that we expect. @@ -2694,6 +2723,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2736,6 +2766,7 @@ def test_list_rest_bad_request(request_type=compute.ListRoutesRequest): 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(request) @@ -2774,6 +2805,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2813,6 +2845,7 @@ def test_list_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 = compute.RouteList.to_json(compute.RouteList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_security_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_security_policies.py index d4bfa53e0905..1ae2fb7845a8 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_security_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_security_policies.py @@ -1035,6 +1035,7 @@ def test_add_rule_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.add_rule(request) @@ -1093,6 +1094,7 @@ def test_add_rule_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.add_rule(**mock_args) @@ -1239,6 +1241,7 @@ def test_add_rule_unary_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.add_rule_unary(request) @@ -1297,6 +1300,7 @@ def test_add_rule_unary_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.add_rule_unary(**mock_args) @@ -1444,6 +1448,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1502,6 +1507,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1716,6 +1722,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteSecurityPolicyRe 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(request) @@ -1770,6 +1777,7 @@ def test_delete_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.delete(**mock_args) @@ -1912,6 +1920,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1966,6 +1975,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2100,6 +2110,7 @@ def test_get_rest_required_fields(request_type=compute.GetSecurityPolicyRequest) 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(request) @@ -2154,6 +2165,7 @@ def test_get_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(**mock_args) @@ -2292,6 +2304,7 @@ def test_get_rule_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_rule(request) @@ -2346,6 +2359,7 @@ def test_get_rule_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_rule(**mock_args) @@ -2488,6 +2502,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertSecurityPolicyRe 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.insert(request) @@ -2553,6 +2568,7 @@ def test_insert_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.insert(**mock_args) @@ -2703,6 +2719,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2768,6 +2785,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2914,6 +2932,7 @@ def test_list_rest_required_fields(request_type=compute.ListSecurityPoliciesRequ 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(request) @@ -2970,6 +2989,7 @@ def test_list_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(**mock_args) @@ -3181,6 +3201,7 @@ def test_list_preconfigured_expression_sets_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.list_preconfigured_expression_sets(request) @@ -3243,6 +3264,7 @@ def test_list_preconfigured_expression_sets_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_preconfigured_expression_sets(**mock_args) @@ -3390,6 +3412,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchSecurityPolicyRequ 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.patch(request) @@ -3457,6 +3480,7 @@ def test_patch_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.patch(**mock_args) @@ -3612,6 +3636,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3679,6 +3704,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3835,6 +3861,7 @@ def test_patch_rule_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.patch_rule(request) @@ -3899,6 +3926,7 @@ def test_patch_rule_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.patch_rule(**mock_args) @@ -4051,6 +4079,7 @@ def test_patch_rule_unary_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.patch_rule_unary(request) @@ -4115,6 +4144,7 @@ def test_patch_rule_unary_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.patch_rule_unary(**mock_args) @@ -4260,6 +4290,7 @@ def test_remove_rule_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.remove_rule(request) @@ -4314,6 +4345,7 @@ def test_remove_rule_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.remove_rule(**mock_args) @@ -4456,6 +4488,7 @@ def test_remove_rule_unary_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.remove_rule_unary(request) @@ -4510,6 +4543,7 @@ def test_remove_rule_unary_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.remove_rule_unary(**mock_args) @@ -4651,6 +4685,7 @@ def test_set_labels_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_labels(request) @@ -4709,6 +4744,7 @@ def test_set_labels_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_labels(**mock_args) @@ -4853,6 +4889,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -4911,6 +4948,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -5045,6 +5083,7 @@ def test_add_rule_rest_bad_request(request_type=compute.AddRuleSecurityPolicyReq 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.add_rule(request) @@ -5264,6 +5303,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.add_rule(request) # Establish that the response is the type that we expect. @@ -5325,6 +5365,7 @@ def test_add_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5369,6 +5410,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -5409,6 +5451,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -5454,6 +5497,7 @@ def test_aggregated_list_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 = compute.SecurityPoliciesAggregatedList.to_json( compute.SecurityPoliciesAggregatedList() ) @@ -5498,6 +5542,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteSecurityPolicyReques 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(request) @@ -5554,6 +5599,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -5615,6 +5661,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5657,6 +5704,7 @@ def test_get_rest_bad_request(request_type=compute.GetSecurityPolicyRequest): 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(request) @@ -5701,6 +5749,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5750,6 +5799,7 @@ def test_get_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 = compute.SecurityPolicy.to_json(compute.SecurityPolicy()) req.return_value.content = return_value @@ -5792,6 +5842,7 @@ def test_get_rule_rest_bad_request(request_type=compute.GetRuleSecurityPolicyReq 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_rule(request) @@ -5831,6 +5882,7 @@ def test_get_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -5875,6 +5927,7 @@ def test_get_rule_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 = compute.SecurityPolicyRule.to_json(compute.SecurityPolicyRule()) req.return_value.content = return_value @@ -5917,6 +5970,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertSecurityPolicyReques 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.insert(request) @@ -6206,6 +6260,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.insert(request) # Establish that the response is the type that we expect. @@ -6267,6 +6322,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6309,6 +6365,7 @@ def test_list_rest_bad_request(request_type=compute.ListSecurityPoliciesRequest) 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(request) @@ -6346,6 +6403,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -6388,6 +6446,7 @@ def test_list_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 = compute.SecurityPolicyList.to_json(compute.SecurityPolicyList()) req.return_value.content = return_value @@ -6432,6 +6491,7 @@ def test_list_preconfigured_expression_sets_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.list_preconfigured_expression_sets(request) @@ -6469,6 +6529,7 @@ def test_list_preconfigured_expression_sets_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_preconfigured_expression_sets(request) # Establish that the response is the type that we expect. @@ -6512,6 +6573,7 @@ def test_list_preconfigured_expression_sets_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 = ( compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse.to_json( compute.SecurityPoliciesListPreconfiguredExpressionSetsResponse() @@ -6560,6 +6622,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchSecurityPolicyRequest) 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.patch(request) @@ -6849,6 +6912,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.patch(request) # Establish that the response is the type that we expect. @@ -6910,6 +6974,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6954,6 +7019,7 @@ def test_patch_rule_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.patch_rule(request) @@ -7173,6 +7239,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.patch_rule(request) # Establish that the response is the type that we expect. @@ -7234,6 +7301,7 @@ def test_patch_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7278,6 +7346,7 @@ def test_remove_rule_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.remove_rule(request) @@ -7334,6 +7403,7 @@ def test_remove_rule_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.remove_rule(request) # Establish that the response is the type that we expect. @@ -7395,6 +7465,7 @@ def test_remove_rule_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7439,6 +7510,7 @@ def test_set_labels_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_labels(request) @@ -7574,6 +7646,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.set_labels(request) # Establish that the response is the type that we expect. @@ -7635,6 +7708,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_service_attachments.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_service_attachments.py index 54da68c0eaf3..66580f6a94bf 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_service_attachments.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_service_attachments.py @@ -1048,6 +1048,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1106,6 +1107,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1326,6 +1328,7 @@ def test_delete_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.delete(request) @@ -1386,6 +1389,7 @@ def test_delete_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.delete(**mock_args) @@ -1533,6 +1537,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1593,6 +1598,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1732,6 +1738,7 @@ def test_get_rest_required_fields(request_type=compute.GetServiceAttachmentReque 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(request) @@ -1792,6 +1799,7 @@ def test_get_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(**mock_args) @@ -1935,6 +1943,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) @@ -1995,6 +2004,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) @@ -2139,6 +2149,7 @@ def test_insert_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.insert(request) @@ -2201,6 +2212,7 @@ def test_insert_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.insert(**mock_args) @@ -2351,6 +2363,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2413,6 +2426,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2564,6 +2578,7 @@ def test_list_rest_required_fields(request_type=compute.ListServiceAttachmentsRe 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(request) @@ -2626,6 +2641,7 @@ def test_list_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(**mock_args) @@ -2832,6 +2848,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchServiceAttachmentR 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.patch(request) @@ -2900,6 +2917,7 @@ def test_patch_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.patch(**mock_args) @@ -3055,6 +3073,7 @@ def test_patch_unary_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.patch_unary(request) @@ -3123,6 +3142,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3272,6 +3292,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) @@ -3336,6 +3357,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) @@ -3485,6 +3507,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) @@ -3549,6 +3572,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) @@ -3686,6 +3710,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3725,6 +3750,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3769,6 +3795,7 @@ def test_aggregated_list_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 = compute.ServiceAttachmentAggregatedList.to_json( compute.ServiceAttachmentAggregatedList() ) @@ -3817,6 +3844,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteServiceAttachmentReq 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(request) @@ -3877,6 +3905,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3938,6 +3967,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3984,6 +4014,7 @@ def test_get_rest_bad_request(request_type=compute.GetServiceAttachmentRequest): 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(request) @@ -4039,6 +4070,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4095,6 +4127,7 @@ def test_get_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 = compute.ServiceAttachment.to_json(compute.ServiceAttachment()) req.return_value.content = return_value @@ -4139,6 +4172,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) @@ -4176,6 +4210,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. @@ -4218,6 +4253,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4260,6 +4296,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertServiceAttachmentReq 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.insert(request) @@ -4428,6 +4465,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.insert(request) # Establish that the response is the type that we expect. @@ -4489,6 +4527,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4531,6 +4570,7 @@ def test_list_rest_bad_request(request_type=compute.ListServiceAttachmentsReques 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(request) @@ -4569,6 +4609,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4612,6 +4653,7 @@ def test_list_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 = compute.ServiceAttachmentList.to_json( compute.ServiceAttachmentList() ) @@ -4660,6 +4702,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchServiceAttachmentReque 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.patch(request) @@ -4832,6 +4875,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.patch(request) # Establish that the response is the type that we expect. @@ -4893,6 +4937,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4937,6 +4982,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) @@ -5090,6 +5136,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5132,6 +5179,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5176,6 +5224,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) @@ -5289,6 +5338,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5329,6 +5379,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshot_settings_service.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshot_settings_service.py index faf681c86755..482dfcb21e99 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshot_settings_service.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshot_settings_service.py @@ -1047,6 +1047,7 @@ def test_get_rest_required_fields(request_type=compute.GetSnapshotSettingRequest 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(request) @@ -1092,6 +1093,7 @@ def test_get_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(**mock_args) @@ -1233,6 +1235,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchSnapshotSettingReq 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.patch(request) @@ -1300,6 +1303,7 @@ def test_patch_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.patch(**mock_args) @@ -1452,6 +1456,7 @@ def test_patch_unary_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.patch_unary(request) @@ -1519,6 +1524,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -1658,6 +1664,7 @@ def test_get_rest_bad_request(request_type=compute.GetSnapshotSettingRequest): 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(request) @@ -1691,6 +1698,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1730,6 +1738,7 @@ def test_get_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 = compute.SnapshotSettings.to_json(compute.SnapshotSettings()) req.return_value.content = return_value @@ -1772,6 +1781,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchSnapshotSettingRequest 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.patch(request) @@ -1904,6 +1914,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.patch(request) # Establish that the response is the type that we expect. @@ -1965,6 +1976,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshots.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshots.py index 6d6eec94a0f4..048d45a54940 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshots.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_snapshots.py @@ -983,6 +983,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteSnapshotRequest) 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(request) @@ -1037,6 +1038,7 @@ def test_delete_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.delete(**mock_args) @@ -1177,6 +1179,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteSnapshotRe 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_unary(request) @@ -1231,6 +1234,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1365,6 +1369,7 @@ def test_get_rest_required_fields(request_type=compute.GetSnapshotRequest): 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(request) @@ -1419,6 +1424,7 @@ def test_get_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(**mock_args) @@ -1557,6 +1563,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) @@ -1611,6 +1618,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) @@ -1748,6 +1756,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertSnapshotRequest) 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.insert(request) @@ -1802,6 +1811,7 @@ def test_insert_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.insert(**mock_args) @@ -1939,6 +1949,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertSnapshotRe 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.insert_unary(request) @@ -1993,6 +2004,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2133,6 +2145,7 @@ def test_list_rest_required_fields(request_type=compute.ListSnapshotsRequest): 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(request) @@ -2189,6 +2202,7 @@ def test_list_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(**mock_args) @@ -2386,6 +2400,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) @@ -2444,6 +2459,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) @@ -2586,6 +2602,7 @@ def test_set_labels_rest_required_fields(request_type=compute.SetLabelsSnapshotR 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_labels(request) @@ -2644,6 +2661,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2788,6 +2806,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2846,6 +2865,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -2990,6 +3010,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) @@ -3048,6 +3069,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) @@ -3182,6 +3204,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteSnapshotRequest): 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(request) @@ -3238,6 +3261,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3295,6 +3319,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3337,6 +3362,7 @@ def test_get_rest_bad_request(request_type=compute.GetSnapshotRequest): 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(request) @@ -3402,6 +3428,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3477,6 +3504,7 @@ def test_get_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 = compute.Snapshot.to_json(compute.Snapshot()) req.return_value.content = return_value @@ -3521,6 +3549,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) @@ -3558,6 +3587,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. @@ -3598,6 +3628,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -3640,6 +3671,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertSnapshotRequest): 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.insert(request) @@ -3807,6 +3839,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.insert(request) # Establish that the response is the type that we expect. @@ -3864,6 +3897,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3906,6 +3940,7 @@ def test_list_rest_bad_request(request_type=compute.ListSnapshotsRequest): 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(request) @@ -3944,6 +3979,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3983,6 +4019,7 @@ def test_list_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 = compute.SnapshotList.to_json(compute.SnapshotList()) req.return_value.content = return_value @@ -4027,6 +4064,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) @@ -4180,6 +4218,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -4220,6 +4259,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4262,6 +4302,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsSnapshotReque 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_labels(request) @@ -4397,6 +4438,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4456,6 +4498,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4500,6 +4543,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) @@ -4613,6 +4657,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4651,6 +4696,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_certificates.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_certificates.py index 7e1b6b8982b8..2f034ad59580 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_certificates.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_certificates.py @@ -1030,6 +1030,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1088,6 +1089,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1302,6 +1304,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteSslCertificateRe 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(request) @@ -1356,6 +1359,7 @@ def test_delete_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.delete(**mock_args) @@ -1498,6 +1502,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1552,6 +1557,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1686,6 +1692,7 @@ def test_get_rest_required_fields(request_type=compute.GetSslCertificateRequest) 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(request) @@ -1740,6 +1747,7 @@ def test_get_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(**mock_args) @@ -1877,6 +1885,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertSslCertificateRe 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.insert(request) @@ -1933,6 +1942,7 @@ def test_insert_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.insert(**mock_args) @@ -2074,6 +2084,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2130,6 +2141,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2272,6 +2284,7 @@ def test_list_rest_required_fields(request_type=compute.ListSslCertificatesReque 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(request) @@ -2328,6 +2341,7 @@ def test_list_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(**mock_args) @@ -2521,6 +2535,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -2560,6 +2575,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -2604,6 +2620,7 @@ def test_aggregated_list_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 = compute.SslCertificateAggregatedList.to_json( compute.SslCertificateAggregatedList() ) @@ -2648,6 +2665,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteSslCertificateReques 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(request) @@ -2704,6 +2722,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2765,6 +2784,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2807,6 +2827,7 @@ def test_get_rest_bad_request(request_type=compute.GetSslCertificateRequest): 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(request) @@ -2853,6 +2874,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2904,6 +2926,7 @@ def test_get_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 = compute.SslCertificate.to_json(compute.SslCertificate()) req.return_value.content = return_value @@ -2946,6 +2969,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertSslCertificateReques 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.insert(request) @@ -3099,6 +3123,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.insert(request) # Establish that the response is the type that we expect. @@ -3160,6 +3185,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3202,6 +3228,7 @@ def test_list_rest_bad_request(request_type=compute.ListSslCertificatesRequest): 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(request) @@ -3240,6 +3267,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3283,6 +3311,7 @@ def test_list_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 = compute.SslCertificateList.to_json(compute.SslCertificateList()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_policies.py index 5d359a75d47c..ce5a3c5f3cb3 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_ssl_policies.py @@ -995,6 +995,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1053,6 +1054,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1265,6 +1267,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteSslPolicyRequest 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(request) @@ -1319,6 +1322,7 @@ def test_delete_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.delete(**mock_args) @@ -1459,6 +1463,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteSslPolicyR 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_unary(request) @@ -1513,6 +1518,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1647,6 +1653,7 @@ def test_get_rest_required_fields(request_type=compute.GetSslPolicyRequest): 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(request) @@ -1701,6 +1708,7 @@ def test_get_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(**mock_args) @@ -1838,6 +1846,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertSslPolicyRequest 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.insert(request) @@ -1894,6 +1903,7 @@ def test_insert_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.insert(**mock_args) @@ -2033,6 +2043,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertSslPolicyR 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.insert_unary(request) @@ -2089,6 +2100,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2231,6 +2243,7 @@ def test_list_rest_required_fields(request_type=compute.ListSslPoliciesRequest): 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(request) @@ -2287,6 +2300,7 @@ def test_list_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(**mock_args) @@ -2496,6 +2510,7 @@ def test_list_available_features_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.list_available_features(request) @@ -2552,6 +2567,7 @@ def test_list_available_features_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_available_features(**mock_args) @@ -2692,6 +2708,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchSslPolicyRequest): 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.patch(request) @@ -2750,6 +2767,7 @@ def test_patch_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.patch(**mock_args) @@ -2894,6 +2912,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchSslPolicyReq 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.patch_unary(request) @@ -2952,6 +2971,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3088,6 +3108,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3128,6 +3149,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3173,6 +3195,7 @@ def test_aggregated_list_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 = compute.SslPoliciesAggregatedList.to_json( compute.SslPoliciesAggregatedList() ) @@ -3217,6 +3240,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteSslPolicyRequest): 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(request) @@ -3273,6 +3297,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3332,6 +3357,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3374,6 +3400,7 @@ def test_get_rest_bad_request(request_type=compute.GetSslPolicyRequest): 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(request) @@ -3420,6 +3447,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3469,6 +3497,7 @@ def test_get_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 = compute.SslPolicy.to_json(compute.SslPolicy()) req.return_value.content = return_value @@ -3511,6 +3540,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertSslPolicyRequest): 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.insert(request) @@ -3655,6 +3685,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.insert(request) # Establish that the response is the type that we expect. @@ -3714,6 +3745,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3756,6 +3788,7 @@ def test_list_rest_bad_request(request_type=compute.ListSslPoliciesRequest): 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(request) @@ -3794,6 +3827,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3835,6 +3869,7 @@ def test_list_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 = compute.SslPoliciesList.to_json(compute.SslPoliciesList()) req.return_value.content = return_value @@ -3879,6 +3914,7 @@ def test_list_available_features_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.list_available_features(request) @@ -3914,6 +3950,7 @@ def test_list_available_features_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_available_features(request) # Establish that the response is the type that we expect. @@ -3954,6 +3991,7 @@ def test_list_available_features_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 = compute.SslPoliciesListAvailableFeaturesResponse.to_json( compute.SslPoliciesListAvailableFeaturesResponse() ) @@ -3998,6 +4036,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchSslPolicyRequest): 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.patch(request) @@ -4142,6 +4181,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.patch(request) # Establish that the response is the type that we expect. @@ -4201,6 +4241,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pool_types.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pool_types.py index 93d856c66009..3a3f952d398f 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pool_types.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pool_types.py @@ -1029,6 +1029,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1087,6 +1088,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1299,6 +1301,7 @@ def test_get_rest_required_fields(request_type=compute.GetStoragePoolTypeRequest 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(request) @@ -1359,6 +1362,7 @@ def test_get_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(**mock_args) @@ -1504,6 +1508,7 @@ def test_list_rest_required_fields(request_type=compute.ListStoragePoolTypesRequ 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(request) @@ -1566,6 +1571,7 @@ def test_list_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(**mock_args) @@ -1760,6 +1766,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1798,6 +1805,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -1841,6 +1849,7 @@ def test_aggregated_list_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 = compute.StoragePoolTypeAggregatedList.to_json( compute.StoragePoolTypeAggregatedList() ) @@ -1889,6 +1898,7 @@ def test_get_rest_bad_request(request_type=compute.GetStoragePoolTypeRequest): 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(request) @@ -1943,6 +1953,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1998,6 +2009,7 @@ def test_get_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 = compute.StoragePoolType.to_json(compute.StoragePoolType()) req.return_value.content = return_value @@ -2040,6 +2052,7 @@ def test_list_rest_bad_request(request_type=compute.ListStoragePoolTypesRequest) 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(request) @@ -2078,6 +2091,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2121,6 +2135,7 @@ def test_list_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 = compute.StoragePoolTypeList.to_json( compute.StoragePoolTypeList() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pools.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pools.py index 3f5d68382965..90c5d62f6400 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pools.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_storage_pools.py @@ -999,6 +999,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1057,6 +1058,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1273,6 +1275,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteStoragePoolReque 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(request) @@ -1333,6 +1336,7 @@ def test_delete_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.delete(**mock_args) @@ -1480,6 +1484,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1540,6 +1545,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1679,6 +1685,7 @@ def test_get_rest_required_fields(request_type=compute.GetStoragePoolRequest): 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(request) @@ -1739,6 +1746,7 @@ def test_get_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(**mock_args) @@ -1882,6 +1890,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) @@ -1942,6 +1951,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) @@ -2084,6 +2094,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertStoragePoolReque 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.insert(request) @@ -2142,6 +2153,7 @@ def test_insert_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.insert(**mock_args) @@ -2288,6 +2300,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2346,6 +2359,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2493,6 +2507,7 @@ def test_list_rest_required_fields(request_type=compute.ListStoragePoolsRequest) 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(request) @@ -2555,6 +2570,7 @@ def test_list_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(**mock_args) @@ -2766,6 +2782,7 @@ def test_list_disks_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.list_disks(request) @@ -2834,6 +2851,7 @@ def test_list_disks_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_disks(**mock_args) @@ -3041,6 +3059,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) @@ -3105,6 +3124,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) @@ -3254,6 +3274,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) @@ -3318,6 +3339,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) @@ -3472,6 +3494,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateStoragePoolReque 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(request) @@ -3541,6 +3564,7 @@ def test_update_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(**mock_args) @@ -3697,6 +3721,7 @@ def test_update_unary_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.update_unary(request) @@ -3766,6 +3791,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3903,6 +3929,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3943,6 +3970,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3988,6 +4016,7 @@ def test_aggregated_list_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 = compute.StoragePoolAggregatedList.to_json( compute.StoragePoolAggregatedList() ) @@ -4032,6 +4061,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteStoragePoolRequest): 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(request) @@ -4088,6 +4118,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4149,6 +4180,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4191,6 +4223,7 @@ def test_get_rest_bad_request(request_type=compute.GetStoragePoolRequest): 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(request) @@ -4241,6 +4274,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4296,6 +4330,7 @@ def test_get_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 = compute.StoragePool.to_json(compute.StoragePool()) req.return_value.content = return_value @@ -4340,6 +4375,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) @@ -4377,6 +4413,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. @@ -4419,6 +4456,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -4461,6 +4499,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertStoragePoolRequest): 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.insert(request) @@ -4618,6 +4657,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.insert(request) # Establish that the response is the type that we expect. @@ -4679,6 +4719,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4721,6 +4762,7 @@ def test_list_rest_bad_request(request_type=compute.ListStoragePoolsRequest): 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(request) @@ -4761,6 +4803,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4806,6 +4849,7 @@ def test_list_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 = compute.StoragePoolList.to_json(compute.StoragePoolList()) req.return_value.content = return_value @@ -4848,6 +4892,7 @@ def test_list_disks_rest_bad_request(request_type=compute.ListDisksStoragePoolsR 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_disks(request) @@ -4888,6 +4933,7 @@ def test_list_disks_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_disks(request) # Establish that the response is the type that we expect. @@ -4933,6 +4979,7 @@ def test_list_disks_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 = compute.StoragePoolListDisks.to_json( compute.StoragePoolListDisks() ) @@ -4979,6 +5026,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) @@ -5132,6 +5180,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -5174,6 +5223,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5218,6 +5268,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) @@ -5331,6 +5382,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -5371,6 +5423,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) @@ -5415,6 +5468,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateStoragePoolRequest): 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(request) @@ -5572,6 +5626,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(request) # Establish that the response is the type that we expect. @@ -5633,6 +5688,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_subnetworks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_subnetworks.py index f95e007f6dff..ea238c7f0ab8 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_subnetworks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_subnetworks.py @@ -995,6 +995,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1053,6 +1054,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1269,6 +1271,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteSubnetworkReques 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(request) @@ -1329,6 +1332,7 @@ def test_delete_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.delete(**mock_args) @@ -1476,6 +1480,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1536,6 +1541,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1688,6 +1694,7 @@ def test_expand_ip_cidr_range_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.expand_ip_cidr_range(request) @@ -1752,6 +1759,7 @@ def test_expand_ip_cidr_range_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.expand_ip_cidr_range(**mock_args) @@ -1907,6 +1915,7 @@ def test_expand_ip_cidr_range_unary_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.expand_ip_cidr_range_unary(request) @@ -1971,6 +1980,7 @@ def test_expand_ip_cidr_range_unary_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.expand_ip_cidr_range_unary(**mock_args) @@ -2113,6 +2123,7 @@ def test_get_rest_required_fields(request_type=compute.GetSubnetworkRequest): 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(request) @@ -2173,6 +2184,7 @@ def test_get_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(**mock_args) @@ -2316,6 +2328,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) @@ -2376,6 +2389,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) @@ -2518,6 +2532,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertSubnetworkReques 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.insert(request) @@ -2576,6 +2591,7 @@ def test_insert_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.insert(**mock_args) @@ -2722,6 +2738,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2780,6 +2797,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2927,6 +2945,7 @@ def test_list_rest_required_fields(request_type=compute.ListSubnetworksRequest): 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(request) @@ -2989,6 +3008,7 @@ def test_list_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(**mock_args) @@ -3192,6 +3212,7 @@ def test_list_usable_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.list_usable(request) @@ -3248,6 +3269,7 @@ def test_list_usable_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_usable(**mock_args) @@ -3460,6 +3482,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchSubnetworkRequest) 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.patch(request) @@ -3529,6 +3552,7 @@ def test_patch_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.patch(**mock_args) @@ -3683,6 +3707,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchSubnetworkRe 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.patch_unary(request) @@ -3752,6 +3777,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3897,6 +3923,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) @@ -3961,6 +3988,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) @@ -4117,6 +4145,7 @@ def test_set_private_ip_google_access_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_private_ip_google_access(request) @@ -4181,6 +4210,7 @@ def test_set_private_ip_google_access_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_private_ip_google_access(**mock_args) @@ -4337,6 +4367,7 @@ def test_set_private_ip_google_access_unary_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_private_ip_google_access_unary(request) @@ -4401,6 +4432,7 @@ def test_set_private_ip_google_access_unary_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_private_ip_google_access_unary(**mock_args) @@ -4552,6 +4584,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) @@ -4616,6 +4649,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) @@ -4753,6 +4787,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -4792,6 +4827,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -4836,6 +4872,7 @@ def test_aggregated_list_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 = compute.SubnetworkAggregatedList.to_json( compute.SubnetworkAggregatedList() ) @@ -4880,6 +4917,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteSubnetworkRequest): 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(request) @@ -4936,6 +4974,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4997,6 +5036,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5041,6 +5081,7 @@ def test_expand_ip_cidr_range_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.expand_ip_cidr_range(request) @@ -5182,6 +5223,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.expand_ip_cidr_range(request) # Establish that the response is the type that we expect. @@ -5243,6 +5285,7 @@ def test_expand_ip_cidr_range_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5285,6 +5328,7 @@ def test_get_rest_bad_request(request_type=compute.GetSubnetworkRequest): 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(request) @@ -5342,6 +5386,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5402,6 +5447,7 @@ def test_get_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 = compute.Subnetwork.to_json(compute.Subnetwork()) req.return_value.content = return_value @@ -5446,6 +5492,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) @@ -5483,6 +5530,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. @@ -5525,6 +5573,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -5567,6 +5616,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertSubnetworkRequest): 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.insert(request) @@ -5730,6 +5780,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.insert(request) # Establish that the response is the type that we expect. @@ -5791,6 +5842,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5833,6 +5885,7 @@ def test_list_rest_bad_request(request_type=compute.ListSubnetworksRequest): 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(request) @@ -5871,6 +5924,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5912,6 +5966,7 @@ def test_list_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 = compute.SubnetworkList.to_json(compute.SubnetworkList()) req.return_value.content = return_value @@ -5956,6 +6011,7 @@ def test_list_usable_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.list_usable(request) @@ -5994,6 +6050,7 @@ def test_list_usable_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_usable(request) # Establish that the response is the type that we expect. @@ -6037,6 +6094,7 @@ def test_list_usable_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 = compute.UsableSubnetworksAggregatedList.to_json( compute.UsableSubnetworksAggregatedList() ) @@ -6081,6 +6139,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchSubnetworkRequest): 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.patch(request) @@ -6244,6 +6303,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.patch(request) # Establish that the response is the type that we expect. @@ -6303,6 +6363,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6347,6 +6408,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) @@ -6500,6 +6562,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.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -6542,6 +6605,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 = compute.Policy.to_json(compute.Policy()) req.return_value.content = return_value @@ -6586,6 +6650,7 @@ def test_set_private_ip_google_access_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_private_ip_google_access(request) @@ -6727,6 +6792,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.set_private_ip_google_access(request) # Establish that the response is the type that we expect. @@ -6788,6 +6854,7 @@ def test_set_private_ip_google_access_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6832,6 +6899,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) @@ -6945,6 +7013,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -6985,6 +7054,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_grpc_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_grpc_proxies.py index f06801e20255..a4055203d20c 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_grpc_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_grpc_proxies.py @@ -1040,6 +1040,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetGrpcProxyR 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(request) @@ -1094,6 +1095,7 @@ def test_delete_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.delete(**mock_args) @@ -1236,6 +1238,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1290,6 +1293,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1424,6 +1428,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetGrpcProxyRequest 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(request) @@ -1478,6 +1483,7 @@ def test_get_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(**mock_args) @@ -1615,6 +1621,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetGrpcProxyR 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.insert(request) @@ -1671,6 +1678,7 @@ def test_insert_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.insert(**mock_args) @@ -1812,6 +1820,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1868,6 +1877,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2010,6 +2020,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetGrpcProxiesReq 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(request) @@ -2066,6 +2077,7 @@ def test_list_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(**mock_args) @@ -2267,6 +2279,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchTargetGrpcProxyReq 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.patch(request) @@ -2325,6 +2338,7 @@ def test_patch_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.patch(**mock_args) @@ -2471,6 +2485,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2529,6 +2544,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2663,6 +2679,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetGrpcProxyReque 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(request) @@ -2719,6 +2736,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -2780,6 +2798,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2822,6 +2841,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetGrpcProxyRequest): 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(request) @@ -2866,6 +2886,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2915,6 +2936,7 @@ def test_get_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 = compute.TargetGrpcProxy.to_json(compute.TargetGrpcProxy()) req.return_value.content = return_value @@ -2957,6 +2979,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetGrpcProxyReque 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.insert(request) @@ -3098,6 +3121,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.insert(request) # Establish that the response is the type that we expect. @@ -3159,6 +3183,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3201,6 +3226,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetGrpcProxiesRequest 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(request) @@ -3239,6 +3265,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3282,6 +3309,7 @@ def test_list_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 = compute.TargetGrpcProxyList.to_json( compute.TargetGrpcProxyList() ) @@ -3326,6 +3354,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchTargetGrpcProxyRequest 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.patch(request) @@ -3467,6 +3496,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.patch(request) # Establish that the response is the type that we expect. @@ -3528,6 +3558,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_http_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_http_proxies.py index ff2ad804d063..d00ba47d47dc 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_http_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_http_proxies.py @@ -1044,6 +1044,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1102,6 +1103,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1316,6 +1318,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetHttpProxyR 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(request) @@ -1370,6 +1373,7 @@ def test_delete_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.delete(**mock_args) @@ -1512,6 +1516,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1566,6 +1571,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1700,6 +1706,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetHttpProxyRequest 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(request) @@ -1754,6 +1761,7 @@ def test_get_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(**mock_args) @@ -1891,6 +1899,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetHttpProxyR 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.insert(request) @@ -1947,6 +1956,7 @@ def test_insert_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.insert(**mock_args) @@ -2088,6 +2098,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2144,6 +2155,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2286,6 +2298,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetHttpProxiesReq 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(request) @@ -2342,6 +2355,7 @@ def test_list_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(**mock_args) @@ -2543,6 +2557,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchTargetHttpProxyReq 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.patch(request) @@ -2601,6 +2616,7 @@ def test_patch_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.patch(**mock_args) @@ -2747,6 +2763,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2805,6 +2822,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2951,6 +2969,7 @@ def test_set_url_map_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_url_map(request) @@ -3007,6 +3026,7 @@ def test_set_url_map_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_url_map(**mock_args) @@ -3151,6 +3171,7 @@ def test_set_url_map_unary_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_url_map_unary(request) @@ -3207,6 +3228,7 @@ def test_set_url_map_unary_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_url_map_unary(**mock_args) @@ -3341,6 +3363,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3380,6 +3403,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3424,6 +3448,7 @@ def test_aggregated_list_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 = compute.TargetHttpProxyAggregatedList.to_json( compute.TargetHttpProxyAggregatedList() ) @@ -3468,6 +3493,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetHttpProxyReque 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(request) @@ -3524,6 +3550,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3585,6 +3612,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3627,6 +3655,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetHttpProxyRequest): 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(request) @@ -3672,6 +3701,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3722,6 +3752,7 @@ def test_get_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 = compute.TargetHttpProxy.to_json(compute.TargetHttpProxy()) req.return_value.content = return_value @@ -3764,6 +3795,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetHttpProxyReque 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.insert(request) @@ -3906,6 +3938,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.insert(request) # Establish that the response is the type that we expect. @@ -3967,6 +4000,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4009,6 +4043,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetHttpProxiesRequest 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(request) @@ -4047,6 +4082,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4090,6 +4126,7 @@ def test_list_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 = compute.TargetHttpProxyList.to_json( compute.TargetHttpProxyList() ) @@ -4134,6 +4171,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchTargetHttpProxyRequest 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.patch(request) @@ -4276,6 +4314,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.patch(request) # Establish that the response is the type that we expect. @@ -4337,6 +4376,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4381,6 +4421,7 @@ def test_set_url_map_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_url_map(request) @@ -4511,6 +4552,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.set_url_map(request) # Establish that the response is the type that we expect. @@ -4572,6 +4614,7 @@ def test_set_url_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_https_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_https_proxies.py index 1f94a24ff001..3337c4d9e2ec 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_https_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_https_proxies.py @@ -1048,6 +1048,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1106,6 +1107,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1322,6 +1324,7 @@ def test_delete_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.delete(request) @@ -1376,6 +1379,7 @@ def test_delete_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.delete(**mock_args) @@ -1518,6 +1522,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1572,6 +1577,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1706,6 +1712,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetHttpsProxyReques 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(request) @@ -1760,6 +1767,7 @@ def test_get_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(**mock_args) @@ -1899,6 +1907,7 @@ def test_insert_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.insert(request) @@ -1955,6 +1964,7 @@ def test_insert_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.insert(**mock_args) @@ -2096,6 +2106,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2152,6 +2163,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2294,6 +2306,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetHttpsProxiesRe 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(request) @@ -2350,6 +2363,7 @@ def test_list_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(**mock_args) @@ -2551,6 +2565,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchTargetHttpsProxyRe 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.patch(request) @@ -2609,6 +2624,7 @@ def test_patch_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.patch(**mock_args) @@ -2755,6 +2771,7 @@ def test_patch_unary_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.patch_unary(request) @@ -2813,6 +2830,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -2963,6 +2981,7 @@ def test_set_certificate_map_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_certificate_map(request) @@ -3021,6 +3040,7 @@ def test_set_certificate_map_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_certificate_map(**mock_args) @@ -3171,6 +3191,7 @@ def test_set_certificate_map_unary_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_certificate_map_unary(request) @@ -3229,6 +3250,7 @@ def test_set_certificate_map_unary_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_certificate_map_unary(**mock_args) @@ -3377,6 +3399,7 @@ def test_set_quic_override_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_quic_override(request) @@ -3435,6 +3458,7 @@ def test_set_quic_override_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_quic_override(**mock_args) @@ -3583,6 +3607,7 @@ def test_set_quic_override_unary_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_quic_override_unary(request) @@ -3641,6 +3666,7 @@ def test_set_quic_override_unary_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_quic_override_unary(**mock_args) @@ -3791,6 +3817,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -3849,6 +3876,7 @@ def test_set_ssl_certificates_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_ssl_certificates(**mock_args) @@ -3999,6 +4027,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(request) @@ -4057,6 +4086,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(**mock_args) @@ -4203,6 +4233,7 @@ def test_set_ssl_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_ssl_policy(request) @@ -4261,6 +4292,7 @@ def test_set_ssl_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_ssl_policy(**mock_args) @@ -4407,6 +4439,7 @@ def test_set_ssl_policy_unary_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_ssl_policy_unary(request) @@ -4465,6 +4498,7 @@ def test_set_ssl_policy_unary_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_ssl_policy_unary(**mock_args) @@ -4611,6 +4645,7 @@ def test_set_url_map_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_url_map(request) @@ -4667,6 +4702,7 @@ def test_set_url_map_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_url_map(**mock_args) @@ -4811,6 +4847,7 @@ def test_set_url_map_unary_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_url_map_unary(request) @@ -4867,6 +4904,7 @@ def test_set_url_map_unary_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_url_map_unary(**mock_args) @@ -5001,6 +5039,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -5040,6 +5079,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -5084,6 +5124,7 @@ def test_aggregated_list_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 = compute.TargetHttpsProxyAggregatedList.to_json( compute.TargetHttpsProxyAggregatedList() ) @@ -5128,6 +5169,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetHttpsProxyRequ 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(request) @@ -5184,6 +5226,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -5245,6 +5288,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5287,6 +5331,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetHttpsProxyRequest): 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(request) @@ -5339,6 +5384,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -5396,6 +5442,7 @@ def test_get_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 = compute.TargetHttpsProxy.to_json(compute.TargetHttpsProxy()) req.return_value.content = return_value @@ -5438,6 +5485,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetHttpsProxyRequ 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.insert(request) @@ -5587,6 +5635,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.insert(request) # Establish that the response is the type that we expect. @@ -5648,6 +5697,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5690,6 +5740,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetHttpsProxiesReques 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(request) @@ -5728,6 +5779,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5771,6 +5823,7 @@ def test_list_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 = compute.TargetHttpsProxyList.to_json( compute.TargetHttpsProxyList() ) @@ -5815,6 +5868,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchTargetHttpsProxyReques 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.patch(request) @@ -5964,6 +6018,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.patch(request) # Establish that the response is the type that we expect. @@ -6025,6 +6080,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6069,6 +6125,7 @@ def test_set_certificate_map_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_certificate_map(request) @@ -6210,6 +6267,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.set_certificate_map(request) # Establish that the response is the type that we expect. @@ -6271,6 +6329,7 @@ def test_set_certificate_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6315,6 +6374,7 @@ def test_set_quic_override_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_quic_override(request) @@ -6456,6 +6516,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.set_quic_override(request) # Establish that the response is the type that we expect. @@ -6517,6 +6578,7 @@ def test_set_quic_override_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6561,6 +6623,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -6702,6 +6765,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.set_ssl_certificates(request) # Establish that the response is the type that we expect. @@ -6763,6 +6827,7 @@ def test_set_ssl_certificates_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6807,6 +6872,7 @@ def test_set_ssl_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_ssl_policy(request) @@ -6939,6 +7005,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.set_ssl_policy(request) # Establish that the response is the type that we expect. @@ -7000,6 +7067,7 @@ def test_set_ssl_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7044,6 +7112,7 @@ def test_set_url_map_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_url_map(request) @@ -7174,6 +7243,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.set_url_map(request) # Establish that the response is the type that we expect. @@ -7235,6 +7305,7 @@ def test_set_url_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_instances.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_instances.py index b39a05dd8014..d956e7f89b44 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_instances.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_instances.py @@ -1030,6 +1030,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1088,6 +1089,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1306,6 +1308,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetInstanceRe 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(request) @@ -1366,6 +1369,7 @@ def test_delete_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.delete(**mock_args) @@ -1513,6 +1517,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1573,6 +1578,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1712,6 +1718,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetInstanceRequest) 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(request) @@ -1772,6 +1779,7 @@ def test_get_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(**mock_args) @@ -1914,6 +1922,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetInstanceRe 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.insert(request) @@ -1972,6 +1981,7 @@ def test_insert_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.insert(**mock_args) @@ -2118,6 +2128,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2176,6 +2187,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2323,6 +2335,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetInstancesReque 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(request) @@ -2385,6 +2398,7 @@ def test_list_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(**mock_args) @@ -2597,6 +2611,7 @@ def test_set_security_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_security_policy(request) @@ -2661,6 +2676,7 @@ def test_set_security_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_security_policy(**mock_args) @@ -2816,6 +2832,7 @@ def test_set_security_policy_unary_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_security_policy_unary(request) @@ -2880,6 +2897,7 @@ def test_set_security_policy_unary_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_security_policy_unary(**mock_args) @@ -3017,6 +3035,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3056,6 +3075,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3100,6 +3120,7 @@ def test_aggregated_list_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 = compute.TargetInstanceAggregatedList.to_json( compute.TargetInstanceAggregatedList() ) @@ -3148,6 +3169,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetInstanceReques 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(request) @@ -3208,6 +3230,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3269,6 +3292,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3315,6 +3339,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetInstanceRequest): 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(request) @@ -3364,6 +3389,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3414,6 +3440,7 @@ def test_get_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 = compute.TargetInstance.to_json(compute.TargetInstance()) req.return_value.content = return_value @@ -3456,6 +3483,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetInstanceReques 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.insert(request) @@ -3596,6 +3624,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.insert(request) # Establish that the response is the type that we expect. @@ -3657,6 +3686,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3699,6 +3729,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetInstancesRequest): 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(request) @@ -3737,6 +3768,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3780,6 +3812,7 @@ def test_list_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 = compute.TargetInstanceList.to_json(compute.TargetInstanceList()) req.return_value.content = return_value @@ -3828,6 +3861,7 @@ def test_set_security_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_security_policy(request) @@ -3966,6 +4000,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.set_security_policy(request) # Establish that the response is the type that we expect. @@ -4027,6 +4062,7 @@ def test_set_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_pools.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_pools.py index 00e218974820..e23ed1874e46 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_pools.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_pools.py @@ -1000,6 +1000,7 @@ def test_add_health_check_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.add_health_check(request) @@ -1066,6 +1067,7 @@ def test_add_health_check_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.add_health_check(**mock_args) @@ -1221,6 +1223,7 @@ def test_add_health_check_unary_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.add_health_check_unary(request) @@ -1287,6 +1290,7 @@ def test_add_health_check_unary_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.add_health_check_unary(**mock_args) @@ -1440,6 +1444,7 @@ def test_add_instance_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.add_instance(request) @@ -1504,6 +1509,7 @@ def test_add_instance_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.add_instance(**mock_args) @@ -1655,6 +1661,7 @@ def test_add_instance_unary_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.add_instance_unary(request) @@ -1719,6 +1726,7 @@ def test_add_instance_unary_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.add_instance_unary(**mock_args) @@ -1867,6 +1875,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1925,6 +1934,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -2141,6 +2151,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetPoolReques 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(request) @@ -2201,6 +2212,7 @@ def test_delete_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.delete(**mock_args) @@ -2348,6 +2360,7 @@ def test_delete_unary_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.delete_unary(request) @@ -2408,6 +2421,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -2547,6 +2561,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetPoolRequest): 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(request) @@ -2607,6 +2622,7 @@ def test_get_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(**mock_args) @@ -2749,6 +2765,7 @@ def test_get_health_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_health(request) @@ -2813,6 +2830,7 @@ def test_get_health_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_health(**mock_args) @@ -2958,6 +2976,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetPoolReques 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.insert(request) @@ -3014,6 +3033,7 @@ def test_insert_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.insert(**mock_args) @@ -3158,6 +3178,7 @@ def test_insert_unary_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.insert_unary(request) @@ -3214,6 +3235,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -3359,6 +3381,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetPoolsRequest): 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(request) @@ -3421,6 +3444,7 @@ def test_list_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(**mock_args) @@ -3633,6 +3657,7 @@ def test_remove_health_check_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.remove_health_check(request) @@ -3699,6 +3724,7 @@ def test_remove_health_check_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.remove_health_check(**mock_args) @@ -3856,6 +3882,7 @@ def test_remove_health_check_unary_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.remove_health_check_unary(request) @@ -3922,6 +3949,7 @@ def test_remove_health_check_unary_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.remove_health_check_unary(**mock_args) @@ -4075,6 +4103,7 @@ def test_remove_instance_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.remove_instance(request) @@ -4139,6 +4168,7 @@ def test_remove_instance_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.remove_instance(**mock_args) @@ -4290,6 +4320,7 @@ def test_remove_instance_unary_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.remove_instance_unary(request) @@ -4354,6 +4385,7 @@ def test_remove_instance_unary_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.remove_instance_unary(**mock_args) @@ -4510,6 +4542,7 @@ def test_set_backup_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_backup(request) @@ -4577,6 +4610,7 @@ def test_set_backup_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_backup(**mock_args) @@ -4731,6 +4765,7 @@ def test_set_backup_unary_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_backup_unary(request) @@ -4798,6 +4833,7 @@ def test_set_backup_unary_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_backup_unary(**mock_args) @@ -4951,6 +4987,7 @@ def test_set_security_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_security_policy(request) @@ -5015,6 +5052,7 @@ def test_set_security_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_security_policy(**mock_args) @@ -5170,6 +5208,7 @@ def test_set_security_policy_unary_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_security_policy_unary(request) @@ -5234,6 +5273,7 @@ def test_set_security_policy_unary_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_security_policy_unary(**mock_args) @@ -5371,6 +5411,7 @@ def test_add_health_check_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.add_health_check(request) @@ -5512,6 +5553,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.add_health_check(request) # Establish that the response is the type that we expect. @@ -5573,6 +5615,7 @@ def test_add_health_check_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5617,6 +5660,7 @@ def test_add_instance_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.add_instance(request) @@ -5758,6 +5802,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.add_instance(request) # Establish that the response is the type that we expect. @@ -5819,6 +5864,7 @@ def test_add_instance_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5863,6 +5909,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -5902,6 +5949,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -5946,6 +5994,7 @@ def test_aggregated_list_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 = compute.TargetPoolAggregatedList.to_json( compute.TargetPoolAggregatedList() ) @@ -5990,6 +6039,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetPoolRequest): 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(request) @@ -6046,6 +6096,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -6107,6 +6158,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6149,6 +6201,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetPoolRequest): 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(request) @@ -6196,6 +6249,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -6246,6 +6300,7 @@ def test_get_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 = compute.TargetPool.to_json(compute.TargetPool()) req.return_value.content = return_value @@ -6288,6 +6343,7 @@ def test_get_health_rest_bad_request(request_type=compute.GetHealthTargetPoolReq 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_health(request) @@ -6397,6 +6453,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.get_health(request) # Establish that the response is the type that we expect. @@ -6437,6 +6494,7 @@ def test_get_health_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 = compute.TargetPoolInstanceHealth.to_json( compute.TargetPoolInstanceHealth() ) @@ -6481,6 +6539,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetPoolRequest): 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.insert(request) @@ -6621,6 +6680,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.insert(request) # Establish that the response is the type that we expect. @@ -6682,6 +6742,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -6724,6 +6785,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetPoolsRequest): 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(request) @@ -6762,6 +6824,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -6803,6 +6866,7 @@ def test_list_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 = compute.TargetPoolList.to_json(compute.TargetPoolList()) req.return_value.content = return_value @@ -6847,6 +6911,7 @@ def test_remove_health_check_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.remove_health_check(request) @@ -6988,6 +7053,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.remove_health_check(request) # Establish that the response is the type that we expect. @@ -7049,6 +7115,7 @@ def test_remove_health_check_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7093,6 +7160,7 @@ def test_remove_instance_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.remove_instance(request) @@ -7234,6 +7302,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.remove_instance(request) # Establish that the response is the type that we expect. @@ -7295,6 +7364,7 @@ def test_remove_instance_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7337,6 +7407,7 @@ def test_set_backup_rest_bad_request(request_type=compute.SetBackupTargetPoolReq 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_backup(request) @@ -7467,6 +7538,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.set_backup(request) # Establish that the response is the type that we expect. @@ -7528,6 +7600,7 @@ def test_set_backup_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -7572,6 +7645,7 @@ def test_set_security_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_security_policy(request) @@ -7706,6 +7780,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.set_security_policy(request) # Establish that the response is the type that we expect. @@ -7767,6 +7842,7 @@ def test_set_security_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_ssl_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_ssl_proxies.py index d924309b2a3e..8c5e342be302 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_ssl_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_ssl_proxies.py @@ -1032,6 +1032,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetSslProxyRe 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(request) @@ -1086,6 +1087,7 @@ def test_delete_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.delete(**mock_args) @@ -1228,6 +1230,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1282,6 +1285,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1416,6 +1420,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetSslProxyRequest) 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(request) @@ -1470,6 +1475,7 @@ def test_get_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(**mock_args) @@ -1607,6 +1613,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetSslProxyRe 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.insert(request) @@ -1663,6 +1670,7 @@ def test_insert_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.insert(**mock_args) @@ -1804,6 +1812,7 @@ def test_insert_unary_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.insert_unary(request) @@ -1860,6 +1869,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2002,6 +2012,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetSslProxiesRequ 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(request) @@ -2058,6 +2069,7 @@ def test_list_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(**mock_args) @@ -2265,6 +2277,7 @@ def test_set_backend_service_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_backend_service(request) @@ -2323,6 +2336,7 @@ def test_set_backend_service_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_backend_service(**mock_args) @@ -2473,6 +2487,7 @@ def test_set_backend_service_unary_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_backend_service_unary(request) @@ -2531,6 +2546,7 @@ def test_set_backend_service_unary_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_backend_service_unary(**mock_args) @@ -2681,6 +2697,7 @@ def test_set_certificate_map_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_certificate_map(request) @@ -2739,6 +2756,7 @@ def test_set_certificate_map_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_certificate_map(**mock_args) @@ -2889,6 +2907,7 @@ def test_set_certificate_map_unary_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_certificate_map_unary(request) @@ -2947,6 +2966,7 @@ def test_set_certificate_map_unary_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_certificate_map_unary(**mock_args) @@ -3095,6 +3115,7 @@ def test_set_proxy_header_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_proxy_header(request) @@ -3153,6 +3174,7 @@ def test_set_proxy_header_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_proxy_header(**mock_args) @@ -3301,6 +3323,7 @@ def test_set_proxy_header_unary_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_proxy_header_unary(request) @@ -3359,6 +3382,7 @@ def test_set_proxy_header_unary_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_proxy_header_unary(**mock_args) @@ -3509,6 +3533,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -3567,6 +3592,7 @@ def test_set_ssl_certificates_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_ssl_certificates(**mock_args) @@ -3717,6 +3743,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(request) @@ -3775,6 +3802,7 @@ def test_set_ssl_certificates_unary_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_ssl_certificates_unary(**mock_args) @@ -3921,6 +3949,7 @@ def test_set_ssl_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_ssl_policy(request) @@ -3979,6 +4008,7 @@ def test_set_ssl_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_ssl_policy(**mock_args) @@ -4125,6 +4155,7 @@ def test_set_ssl_policy_unary_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_ssl_policy_unary(request) @@ -4183,6 +4214,7 @@ def test_set_ssl_policy_unary_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_ssl_policy_unary(**mock_args) @@ -4317,6 +4349,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetSslProxyReques 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(request) @@ -4373,6 +4406,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4434,6 +4468,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4476,6 +4511,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetSslProxyRequest): 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(request) @@ -4521,6 +4557,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4571,6 +4608,7 @@ def test_get_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 = compute.TargetSslProxy.to_json(compute.TargetSslProxy()) req.return_value.content = return_value @@ -4613,6 +4651,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetSslProxyReques 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.insert(request) @@ -4755,6 +4794,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.insert(request) # Establish that the response is the type that we expect. @@ -4816,6 +4856,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4858,6 +4899,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetSslProxiesRequest) 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(request) @@ -4896,6 +4938,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4939,6 +4982,7 @@ def test_list_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 = compute.TargetSslProxyList.to_json(compute.TargetSslProxyList()) req.return_value.content = return_value @@ -4983,6 +5027,7 @@ def test_set_backend_service_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_backend_service(request) @@ -5124,6 +5169,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.set_backend_service(request) # Establish that the response is the type that we expect. @@ -5185,6 +5231,7 @@ def test_set_backend_service_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5229,6 +5276,7 @@ def test_set_certificate_map_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_certificate_map(request) @@ -5370,6 +5418,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.set_certificate_map(request) # Establish that the response is the type that we expect. @@ -5431,6 +5480,7 @@ def test_set_certificate_map_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5475,6 +5525,7 @@ def test_set_proxy_header_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_proxy_header(request) @@ -5616,6 +5667,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.set_proxy_header(request) # Establish that the response is the type that we expect. @@ -5677,6 +5729,7 @@ def test_set_proxy_header_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5721,6 +5774,7 @@ def test_set_ssl_certificates_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_ssl_certificates(request) @@ -5862,6 +5916,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.set_ssl_certificates(request) # Establish that the response is the type that we expect. @@ -5923,6 +5978,7 @@ def test_set_ssl_certificates_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5967,6 +6023,7 @@ def test_set_ssl_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_ssl_policy(request) @@ -6099,6 +6156,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.set_ssl_policy(request) # Establish that the response is the type that we expect. @@ -6160,6 +6218,7 @@ def test_set_ssl_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_tcp_proxies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_tcp_proxies.py index 49c04c4d54ec..13bddeb6f0a0 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_tcp_proxies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_tcp_proxies.py @@ -1036,6 +1036,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1094,6 +1095,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1308,6 +1310,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteTargetTcpProxyRe 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(request) @@ -1362,6 +1365,7 @@ def test_delete_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.delete(**mock_args) @@ -1504,6 +1508,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1558,6 +1563,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1692,6 +1698,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetTcpProxyRequest) 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(request) @@ -1746,6 +1753,7 @@ def test_get_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(**mock_args) @@ -1883,6 +1891,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertTargetTcpProxyRe 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.insert(request) @@ -1939,6 +1948,7 @@ def test_insert_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.insert(**mock_args) @@ -2080,6 +2090,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2136,6 +2147,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2278,6 +2290,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetTcpProxiesRequ 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(request) @@ -2334,6 +2347,7 @@ def test_list_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(**mock_args) @@ -2541,6 +2555,7 @@ def test_set_backend_service_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_backend_service(request) @@ -2599,6 +2614,7 @@ def test_set_backend_service_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_backend_service(**mock_args) @@ -2749,6 +2765,7 @@ def test_set_backend_service_unary_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_backend_service_unary(request) @@ -2807,6 +2824,7 @@ def test_set_backend_service_unary_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_backend_service_unary(**mock_args) @@ -2955,6 +2973,7 @@ def test_set_proxy_header_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_proxy_header(request) @@ -3013,6 +3032,7 @@ def test_set_proxy_header_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_proxy_header(**mock_args) @@ -3161,6 +3181,7 @@ def test_set_proxy_header_unary_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_proxy_header_unary(request) @@ -3219,6 +3240,7 @@ def test_set_proxy_header_unary_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_proxy_header_unary(**mock_args) @@ -3355,6 +3377,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3394,6 +3417,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3438,6 +3462,7 @@ def test_aggregated_list_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 = compute.TargetTcpProxyAggregatedList.to_json( compute.TargetTcpProxyAggregatedList() ) @@ -3482,6 +3507,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetTcpProxyReques 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(request) @@ -3538,6 +3564,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3599,6 +3626,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3641,6 +3669,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetTcpProxyRequest): 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(request) @@ -3685,6 +3714,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3734,6 +3764,7 @@ def test_get_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 = compute.TargetTcpProxy.to_json(compute.TargetTcpProxy()) req.return_value.content = return_value @@ -3776,6 +3807,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetTcpProxyReques 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.insert(request) @@ -3917,6 +3949,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.insert(request) # Establish that the response is the type that we expect. @@ -3978,6 +4011,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4020,6 +4054,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetTcpProxiesRequest) 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(request) @@ -4058,6 +4093,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4101,6 +4137,7 @@ def test_list_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 = compute.TargetTcpProxyList.to_json(compute.TargetTcpProxyList()) req.return_value.content = return_value @@ -4145,6 +4182,7 @@ def test_set_backend_service_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_backend_service(request) @@ -4286,6 +4324,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.set_backend_service(request) # Establish that the response is the type that we expect. @@ -4347,6 +4386,7 @@ def test_set_backend_service_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4391,6 +4431,7 @@ def test_set_proxy_header_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_proxy_header(request) @@ -4532,6 +4573,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.set_proxy_header(request) # Establish that the response is the type that we expect. @@ -4593,6 +4635,7 @@ def test_set_proxy_header_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_vpn_gateways.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_vpn_gateways.py index 82438edf225b..53fab639dc70 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_vpn_gateways.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_target_vpn_gateways.py @@ -1044,6 +1044,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1102,6 +1103,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1322,6 +1324,7 @@ def test_delete_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.delete(request) @@ -1382,6 +1385,7 @@ def test_delete_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.delete(**mock_args) @@ -1529,6 +1533,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1589,6 +1594,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1728,6 +1734,7 @@ def test_get_rest_required_fields(request_type=compute.GetTargetVpnGatewayReques 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(request) @@ -1788,6 +1795,7 @@ def test_get_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(**mock_args) @@ -1932,6 +1940,7 @@ def test_insert_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.insert(request) @@ -1990,6 +1999,7 @@ def test_insert_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.insert(**mock_args) @@ -2136,6 +2146,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2194,6 +2205,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2341,6 +2353,7 @@ def test_list_rest_required_fields(request_type=compute.ListTargetVpnGatewaysReq 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(request) @@ -2403,6 +2416,7 @@ def test_list_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(**mock_args) @@ -2611,6 +2625,7 @@ def test_set_labels_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_labels(request) @@ -2675,6 +2690,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2826,6 +2842,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2890,6 +2907,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3027,6 +3045,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3066,6 +3085,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3110,6 +3130,7 @@ def test_aggregated_list_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 = compute.TargetVpnGatewayAggregatedList.to_json( compute.TargetVpnGatewayAggregatedList() ) @@ -3158,6 +3179,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteTargetVpnGatewayRequ 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(request) @@ -3218,6 +3240,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3279,6 +3302,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3325,6 +3349,7 @@ def test_get_rest_bad_request(request_type=compute.GetTargetVpnGatewayRequest): 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(request) @@ -3375,6 +3400,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3426,6 +3452,7 @@ def test_get_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 = compute.TargetVpnGateway.to_json(compute.TargetVpnGateway()) req.return_value.content = return_value @@ -3468,6 +3495,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertTargetVpnGatewayRequ 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.insert(request) @@ -3612,6 +3640,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.insert(request) # Establish that the response is the type that we expect. @@ -3673,6 +3702,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3715,6 +3745,7 @@ def test_list_rest_bad_request(request_type=compute.ListTargetVpnGatewaysRequest 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(request) @@ -3753,6 +3784,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3796,6 +3828,7 @@ def test_list_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 = compute.TargetVpnGatewayList.to_json( compute.TargetVpnGatewayList() ) @@ -3842,6 +3875,7 @@ def test_set_labels_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_labels(request) @@ -3977,6 +4011,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4038,6 +4073,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_url_maps.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_url_maps.py index 2d63f5c2c35c..703a138ade2e 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_url_maps.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_url_maps.py @@ -973,6 +973,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1031,6 +1032,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1240,6 +1242,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteUrlMapRequest): 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(request) @@ -1294,6 +1297,7 @@ def test_delete_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.delete(**mock_args) @@ -1434,6 +1438,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteUrlMapRequ 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_unary(request) @@ -1488,6 +1493,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1622,6 +1628,7 @@ def test_get_rest_required_fields(request_type=compute.GetUrlMapRequest): 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(request) @@ -1676,6 +1683,7 @@ def test_get_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(**mock_args) @@ -1813,6 +1821,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertUrlMapRequest): 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.insert(request) @@ -1869,6 +1878,7 @@ def test_insert_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.insert(**mock_args) @@ -2007,6 +2017,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertUrlMapRequ 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.insert_unary(request) @@ -2063,6 +2074,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2209,6 +2221,7 @@ def test_invalidate_cache_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.invalidate_cache(request) @@ -2267,6 +2280,7 @@ def test_invalidate_cache_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.invalidate_cache(**mock_args) @@ -2415,6 +2429,7 @@ def test_invalidate_cache_unary_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.invalidate_cache_unary(request) @@ -2473,6 +2488,7 @@ def test_invalidate_cache_unary_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.invalidate_cache_unary(**mock_args) @@ -2616,6 +2632,7 @@ def test_list_rest_required_fields(request_type=compute.ListUrlMapsRequest): 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(request) @@ -2672,6 +2689,7 @@ def test_list_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(**mock_args) @@ -2872,6 +2890,7 @@ def test_patch_rest_required_fields(request_type=compute.PatchUrlMapRequest): 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.patch(request) @@ -2930,6 +2949,7 @@ def test_patch_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.patch(**mock_args) @@ -3074,6 +3094,7 @@ def test_patch_unary_rest_required_fields(request_type=compute.PatchUrlMapReques 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.patch_unary(request) @@ -3132,6 +3153,7 @@ def test_patch_unary_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.patch_unary(**mock_args) @@ -3276,6 +3298,7 @@ def test_update_rest_required_fields(request_type=compute.UpdateUrlMapRequest): 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(request) @@ -3334,6 +3357,7 @@ def test_update_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(**mock_args) @@ -3478,6 +3502,7 @@ def test_update_unary_rest_required_fields(request_type=compute.UpdateUrlMapRequ 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_unary(request) @@ -3536,6 +3561,7 @@ def test_update_unary_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_unary(**mock_args) @@ -3674,6 +3700,7 @@ def test_validate_rest_required_fields(request_type=compute.ValidateUrlMapReques 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.validate(request) @@ -3732,6 +3759,7 @@ def test_validate_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.validate(**mock_args) @@ -3868,6 +3896,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3907,6 +3936,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3949,6 +3979,7 @@ def test_aggregated_list_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 = compute.UrlMapsAggregatedList.to_json( compute.UrlMapsAggregatedList() ) @@ -3993,6 +4024,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteUrlMapRequest): 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(request) @@ -4049,6 +4081,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -4106,6 +4139,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4148,6 +4182,7 @@ def test_get_rest_bad_request(request_type=compute.GetUrlMapRequest): 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(request) @@ -4191,6 +4226,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -4235,6 +4271,7 @@ def test_get_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 = compute.UrlMap.to_json(compute.UrlMap()) req.return_value.content = return_value @@ -4277,6 +4314,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertUrlMapRequest): 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.insert(request) @@ -4587,6 +4625,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.insert(request) # Establish that the response is the type that we expect. @@ -4644,6 +4683,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4688,6 +4728,7 @@ def test_invalidate_cache_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.invalidate_cache(request) @@ -4823,6 +4864,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.invalidate_cache(request) # Establish that the response is the type that we expect. @@ -4882,6 +4924,7 @@ def test_invalidate_cache_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4924,6 +4967,7 @@ def test_list_rest_bad_request(request_type=compute.ListUrlMapsRequest): 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(request) @@ -4962,6 +5006,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -5001,6 +5046,7 @@ def test_list_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 = compute.UrlMapList.to_json(compute.UrlMapList()) req.return_value.content = return_value @@ -5043,6 +5089,7 @@ def test_patch_rest_bad_request(request_type=compute.PatchUrlMapRequest): 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.patch(request) @@ -5353,6 +5400,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.patch(request) # Establish that the response is the type that we expect. @@ -5410,6 +5458,7 @@ def test_patch_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5452,6 +5501,7 @@ def test_update_rest_bad_request(request_type=compute.UpdateUrlMapRequest): 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(request) @@ -5762,6 +5812,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(request) # Establish that the response is the type that we expect. @@ -5819,6 +5870,7 @@ def test_update_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -5861,6 +5913,7 @@ def test_validate_rest_bad_request(request_type=compute.ValidateUrlMapRequest): 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.validate(request) @@ -6165,6 +6218,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.validate(request) # Establish that the response is the type that we expect. @@ -6200,6 +6254,7 @@ def test_validate_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 = compute.UrlMapsValidateResponse.to_json( compute.UrlMapsValidateResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_gateways.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_gateways.py index 0f396a713d71..de1c3a1b2cd7 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_gateways.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_gateways.py @@ -995,6 +995,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1053,6 +1054,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1269,6 +1271,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteVpnGatewayReques 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(request) @@ -1329,6 +1332,7 @@ def test_delete_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.delete(**mock_args) @@ -1476,6 +1480,7 @@ def test_delete_unary_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.delete_unary(request) @@ -1536,6 +1541,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1675,6 +1681,7 @@ def test_get_rest_required_fields(request_type=compute.GetVpnGatewayRequest): 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(request) @@ -1735,6 +1742,7 @@ def test_get_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(**mock_args) @@ -1876,6 +1884,7 @@ def test_get_status_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_status(request) @@ -1936,6 +1945,7 @@ def test_get_status_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_status(**mock_args) @@ -2078,6 +2088,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertVpnGatewayReques 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.insert(request) @@ -2136,6 +2147,7 @@ def test_insert_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.insert(**mock_args) @@ -2282,6 +2294,7 @@ def test_insert_unary_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.insert_unary(request) @@ -2340,6 +2353,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2487,6 +2501,7 @@ def test_list_rest_required_fields(request_type=compute.ListVpnGatewaysRequest): 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(request) @@ -2549,6 +2564,7 @@ def test_list_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(**mock_args) @@ -2757,6 +2773,7 @@ def test_set_labels_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_labels(request) @@ -2821,6 +2838,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2972,6 +2990,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -3036,6 +3055,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -3185,6 +3205,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) @@ -3249,6 +3270,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) @@ -3386,6 +3408,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3425,6 +3448,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3469,6 +3493,7 @@ def test_aggregated_list_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 = compute.VpnGatewayAggregatedList.to_json( compute.VpnGatewayAggregatedList() ) @@ -3513,6 +3538,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteVpnGatewayRequest): 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(request) @@ -3569,6 +3595,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3630,6 +3657,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3672,6 +3700,7 @@ def test_get_rest_bad_request(request_type=compute.GetVpnGatewayRequest): 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(request) @@ -3717,6 +3746,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3765,6 +3795,7 @@ def test_get_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 = compute.VpnGateway.to_json(compute.VpnGateway()) req.return_value.content = return_value @@ -3807,6 +3838,7 @@ def test_get_status_rest_bad_request(request_type=compute.GetStatusVpnGatewayReq 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_status(request) @@ -3840,6 +3872,7 @@ def test_get_status_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_status(request) # Establish that the response is the type that we expect. @@ -3879,6 +3912,7 @@ def test_get_status_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 = compute.VpnGatewaysGetStatusResponse.to_json( compute.VpnGatewaysGetStatusResponse() ) @@ -3923,6 +3957,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertVpnGatewayRequest): 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.insert(request) @@ -4070,6 +4105,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.insert(request) # Establish that the response is the type that we expect. @@ -4131,6 +4167,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4173,6 +4210,7 @@ def test_list_rest_bad_request(request_type=compute.ListVpnGatewaysRequest): 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(request) @@ -4211,6 +4249,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -4252,6 +4291,7 @@ def test_list_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 = compute.VpnGatewayList.to_json(compute.VpnGatewayList()) req.return_value.content = return_value @@ -4294,6 +4334,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsVpnGatewayReq 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_labels(request) @@ -4429,6 +4470,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.set_labels(request) # Establish that the response is the type that we expect. @@ -4490,6 +4532,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -4534,6 +4577,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) @@ -4647,6 +4691,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.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -4687,6 +4732,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 = compute.TestPermissionsResponse.to_json( compute.TestPermissionsResponse() ) diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_tunnels.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_tunnels.py index a458b42d1c40..e0feaec0db83 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_tunnels.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_vpn_tunnels.py @@ -991,6 +991,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -1049,6 +1050,7 @@ def test_aggregated_list_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.aggregated_list(**mock_args) @@ -1262,6 +1264,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteVpnTunnelRequest 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(request) @@ -1322,6 +1325,7 @@ def test_delete_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.delete(**mock_args) @@ -1467,6 +1471,7 @@ def test_delete_unary_rest_required_fields(request_type=compute.DeleteVpnTunnelR 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_unary(request) @@ -1527,6 +1532,7 @@ def test_delete_unary_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.delete_unary(**mock_args) @@ -1666,6 +1672,7 @@ def test_get_rest_required_fields(request_type=compute.GetVpnTunnelRequest): 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(request) @@ -1726,6 +1733,7 @@ def test_get_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(**mock_args) @@ -1868,6 +1876,7 @@ def test_insert_rest_required_fields(request_type=compute.InsertVpnTunnelRequest 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.insert(request) @@ -1926,6 +1935,7 @@ def test_insert_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.insert(**mock_args) @@ -2070,6 +2080,7 @@ def test_insert_unary_rest_required_fields(request_type=compute.InsertVpnTunnelR 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.insert_unary(request) @@ -2128,6 +2139,7 @@ def test_insert_unary_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.insert_unary(**mock_args) @@ -2275,6 +2287,7 @@ def test_list_rest_required_fields(request_type=compute.ListVpnTunnelsRequest): 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(request) @@ -2337,6 +2350,7 @@ def test_list_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(**mock_args) @@ -2545,6 +2559,7 @@ def test_set_labels_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_labels(request) @@ -2609,6 +2624,7 @@ def test_set_labels_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_labels(**mock_args) @@ -2760,6 +2776,7 @@ def test_set_labels_unary_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_labels_unary(request) @@ -2824,6 +2841,7 @@ def test_set_labels_unary_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_labels_unary(**mock_args) @@ -2961,6 +2979,7 @@ def test_aggregated_list_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.aggregated_list(request) @@ -3000,6 +3019,7 @@ def test_aggregated_list_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.aggregated_list(request) # Establish that the response is the type that we expect. @@ -3044,6 +3064,7 @@ def test_aggregated_list_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 = compute.VpnTunnelAggregatedList.to_json( compute.VpnTunnelAggregatedList() ) @@ -3088,6 +3109,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteVpnTunnelRequest): 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(request) @@ -3144,6 +3166,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -3203,6 +3226,7 @@ def test_delete_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3245,6 +3269,7 @@ def test_get_rest_bad_request(request_type=compute.GetVpnTunnelRequest): 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(request) @@ -3302,6 +3327,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -3362,6 +3388,7 @@ def test_get_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 = compute.VpnTunnel.to_json(compute.VpnTunnel()) req.return_value.content = return_value @@ -3404,6 +3431,7 @@ def test_insert_rest_bad_request(request_type=compute.InsertVpnTunnelRequest): 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.insert(request) @@ -3559,6 +3587,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.insert(request) # Establish that the response is the type that we expect. @@ -3618,6 +3647,7 @@ def test_insert_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -3660,6 +3690,7 @@ def test_list_rest_bad_request(request_type=compute.ListVpnTunnelsRequest): 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(request) @@ -3698,6 +3729,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -3739,6 +3771,7 @@ def test_list_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 = compute.VpnTunnelList.to_json(compute.VpnTunnelList()) req.return_value.content = return_value @@ -3781,6 +3814,7 @@ def test_set_labels_rest_bad_request(request_type=compute.SetLabelsVpnTunnelRequ 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_labels(request) @@ -3916,6 +3950,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.set_labels(request) # Establish that the response is the type that we expect. @@ -3977,6 +4012,7 @@ def test_set_labels_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zone_operations.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zone_operations.py index 9b80960f5c65..561f63b333ae 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zone_operations.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zone_operations.py @@ -1003,6 +1003,7 @@ def test_delete_rest_required_fields(request_type=compute.DeleteZoneOperationReq 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(request) @@ -1063,6 +1064,7 @@ def test_delete_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.delete(**mock_args) @@ -1202,6 +1204,7 @@ def test_get_rest_required_fields(request_type=compute.GetZoneOperationRequest): 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(request) @@ -1262,6 +1265,7 @@ def test_get_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(**mock_args) @@ -1407,6 +1411,7 @@ def test_list_rest_required_fields(request_type=compute.ListZoneOperationsReques 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(request) @@ -1469,6 +1474,7 @@ def test_list_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(**mock_args) @@ -1668,6 +1674,7 @@ def test_wait_rest_required_fields(request_type=compute.WaitZoneOperationRequest 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.wait(request) @@ -1728,6 +1735,7 @@ def test_wait_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.wait(**mock_args) @@ -1860,6 +1868,7 @@ def test_delete_rest_bad_request(request_type=compute.DeleteZoneOperationRequest 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(request) @@ -1893,6 +1902,7 @@ def test_delete_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.delete(request) # Establish that the response is the type that we expect. @@ -1932,6 +1942,7 @@ def test_delete_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 = compute.DeleteZoneOperationResponse.to_json( compute.DeleteZoneOperationResponse() ) @@ -1976,6 +1987,7 @@ def test_get_rest_bad_request(request_type=compute.GetZoneOperationRequest): 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(request) @@ -2032,6 +2044,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -2093,6 +2106,7 @@ def test_get_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value @@ -2135,6 +2149,7 @@ def test_list_rest_bad_request(request_type=compute.ListZoneOperationsRequest): 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(request) @@ -2173,6 +2188,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -2216,6 +2232,7 @@ def test_list_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 = compute.OperationList.to_json(compute.OperationList()) req.return_value.content = return_value @@ -2258,6 +2275,7 @@ def test_wait_rest_bad_request(request_type=compute.WaitZoneOperationRequest): 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.wait(request) @@ -2314,6 +2332,7 @@ def test_wait_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.wait(request) # Establish that the response is the type that we expect. @@ -2375,6 +2394,7 @@ def test_wait_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 = compute.Operation.to_json(compute.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zones.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zones.py index 66afb9cfbc46..73ce2d29a2dd 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zones.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_zones.py @@ -949,6 +949,7 @@ def test_get_rest_required_fields(request_type=compute.GetZoneRequest): 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(request) @@ -1003,6 +1004,7 @@ def test_get_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(**mock_args) @@ -1142,6 +1144,7 @@ def test_list_rest_required_fields(request_type=compute.ListZonesRequest): 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(request) @@ -1198,6 +1201,7 @@ def test_list_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(**mock_args) @@ -1387,6 +1391,7 @@ def test_get_rest_bad_request(request_type=compute.GetZoneRequest): 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(request) @@ -1431,6 +1436,7 @@ def test_get_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(request) # Establish that the response is the type that we expect. @@ -1476,6 +1482,7 @@ def test_get_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 = compute.Zone.to_json(compute.Zone()) req.return_value.content = return_value @@ -1518,6 +1525,7 @@ def test_list_rest_bad_request(request_type=compute.ListZonesRequest): 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(request) @@ -1556,6 +1564,7 @@ def test_list_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(request) # Establish that the response is the type that we expect. @@ -1595,6 +1604,7 @@ def test_list_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 = compute.ZoneList.to_json(compute.ZoneList()) req.return_value.content = return_value From 06e3ecc2631cd5bf18873cb90c4b5026caf7d9d5 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:35:38 +0000 Subject: [PATCH 12/16] feat: [google-apps-chat] Add support for opt-in debug logging (#13324) 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 feat: Add missing field annotations in space.proto, message.proto, reaction.proto, space_event.proto, membership.proto, attachment.proto docs: Update field annotations in space.proto, message.proto, reaction.proto, space_event.proto, membership.proto, attachment.proto There are unrelated changes related to filed annotations, but verified those are in the public dev docs fix!: Changed field behavior for an existing field `update_mask` and `emoji` feat: Chat Apps can now retrieve the import mode expire time information to know when to complete the import mode properly docs: Update reference documentation to include import_mode_expire_time field BEGIN_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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtY2hhdC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT feat: [google-apps-chat] Add missing field annotations in space.proto, message.proto, reaction.proto, space_event.proto, membership.proto, attachment.proto docs: Update field annotations in space.proto, message.proto, reaction.proto, space_event.proto, membership.proto, attachment.proto There are unrelated changes related to filed annotations, but verified those are in the public dev docs fix!: Changed field behavior for an existing field `update_mask` and `emoji` PiperOrigin-RevId: 704249815 Source-Link: https://github.com/googleapis/googleapis/commit/27c0c3c9fb0d9ee17dd3b5fe0329bb9b0d0c2b69 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6c7adc4b90abcb67d118b47dec1de688ad73ea67 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtY2hhdC8uT3dsQm90LnlhbWwiLCJoIjoiNmM3YWRjNGI5MGFiY2I2N2QxMThiNDdkZWMxZGU2ODhhZDczZWE2NyJ9 END_NESTED_COMMIT BEGIN_NESTED_COMMIT feat: [google-apps-chat] Chat Apps can now retrieve the import mode expire time information to know when to complete the import mode properly docs: Update reference documentation to include import_mode_expire_time field PiperOrigin-RevId: 702468699 Source-Link: https://github.com/googleapis/googleapis/commit/608531f2fa278d8cdf362c1b04550c5b5f2a1599 Source-Link: https://github.com/googleapis/googleapis-gen/commit/59d7d9462080ce01d1e3642c1c571a35cfce3796 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtY2hhdC8uT3dsQm90LnlhbWwiLCJoIjoiNTlkN2Q5NDYyMDgwY2UwMWQxZTM2NDJjMWM1NzFhMzVjZmNlMzc5NiJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/apps/chat/gapic_version.py | 2 +- .../google/apps/chat_v1/gapic_version.py | 2 +- .../services/chat_service/async_client.py | 624 ++++-- .../chat_v1/services/chat_service/client.py | 629 ++++-- .../chat_v1/services/chat_service/pagers.py | 96 +- .../services/chat_service/transports/grpc.py | 426 +++- .../chat_service/transports/grpc_asyncio.py | 425 +++- .../services/chat_service/transports/rest.py | 1805 +++++++++++++++-- .../chat_service/transports/rest_base.py | 8 +- .../google/apps/chat_v1/types/attachment.py | 21 +- .../apps/chat_v1/types/deletion_metadata.py | 3 +- .../google/apps/chat_v1/types/membership.py | 99 +- .../google/apps/chat_v1/types/message.py | 94 +- .../google/apps/chat_v1/types/reaction.py | 15 +- .../google/apps/chat_v1/types/space.py | 124 +- .../google/apps/chat_v1/types/space_event.py | 6 +- ...ated_chat_service_create_reaction_async.py | 4 + ...rated_chat_service_create_reaction_sync.py | 4 + .../snippet_metadata_google.chat.v1.json | 146 +- .../unit/gapic/chat_v1/test_chat_service.py | 156 +- 20 files changed, 3668 insertions(+), 1021 deletions(-) diff --git a/packages/google-apps-chat/google/apps/chat/gapic_version.py b/packages/google-apps-chat/google/apps/chat/gapic_version.py index 7a4d810a47da..558c8aab67c5 100644 --- a/packages/google-apps-chat/google/apps/chat/gapic_version.py +++ b/packages/google-apps-chat/google/apps/chat/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-chat/google/apps/chat_v1/gapic_version.py b/packages/google-apps-chat/google/apps/chat_v1/gapic_version.py index 7a4d810a47da..558c8aab67c5 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/gapic_version.py +++ b/packages/google-apps-chat/google/apps/chat_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.14" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/async_client.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/async_client.py index 9a1e11ae520b..58f76edd0c60 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/async_client.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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, @@ -74,6 +75,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ChatServiceTransport from .transports.grpc_asyncio import ChatServiceGrpcAsyncIOTransport +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 ChatServiceAsyncClient: """Enables developers to build Chat apps and @@ -303,6 +313,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.chat_v1.ChatServiceAsyncClient`.", + extra={ + "serviceName": "google.chat.v1.ChatService", + "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.chat.v1.ChatService", + "credentialsType": None, + }, + ) + async def create_message( self, request: Optional[Union[gc_message.CreateMessageRequest, dict]] = None, @@ -312,16 +344,18 @@ async def create_message( message_id: 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]]] = (), ) -> gc_message.Message: r"""Creates a message in a Google Chat space. For an example, see `Send a message `__. - The ``create()`` method requires either user or app - authentication. Chat attributes the message sender differently - depending on the type of authentication that you use in your - request. + The ``create()`` method requires either `user + authentication `__ + or `app + authentication `__. + Chat attributes the message sender differently depending on the + type of authentication that you use in your request. The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the @@ -342,6 +376,12 @@ async def create_message( The maximum message size, including the message contents, is 32,000 bytes. + For + `webhook `__ + requests, the response doesn't contain the full message. The + response only populates the ``name`` and ``thread.name`` fields + in addition to the information that was in the request. + .. |Message sent with app authentication async| image:: https://developers.google.com/workspace/chat/images/message-app-auth.svg .. |Message sent with user authentication async| image:: https://developers.google.com/workspace/chat/images/message-user-auth.svg @@ -414,8 +454,10 @@ async def sample_create_message(): 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.apps.chat_v1.types.Message: @@ -478,7 +520,7 @@ async def list_messages( 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.ListMessagesAsyncPager: r"""Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. If you list @@ -486,6 +528,7 @@ async def list_messages( object. When using a REST/HTTP interface, the response contains an empty JSON object, ``{}``. For an example, see `List messages `__. + Requires `user authentication `__. @@ -532,8 +575,10 @@ async def sample_list_messages(): 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.apps.chat_v1.services.chat_service.pagers.ListMessagesAsyncPager: @@ -608,7 +653,7 @@ async def list_memberships( 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.ListMembershipsAsyncPager: r"""Lists memberships in a space. For an example, see `List users and Google Chat apps in a @@ -622,12 +667,17 @@ async def list_memberships( lists memberships in spaces that the authenticated user has access to. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -673,8 +723,10 @@ async def sample_list_memberships(): 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.apps.chat_v1.services.chat_service.pagers.ListMembershipsAsyncPager: @@ -749,18 +801,23 @@ async def get_membership( 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]]] = (), ) -> membership.Membership: r"""Returns details about a membership. For an example, see `Get details about a user's or Google Chat app's membership `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -802,9 +859,7 @@ async def sample_get_membership(): Format: ``spaces/{space}/members/{member}`` or ``spaces/{space}/members/app`` - When `authenticated as a - user `__, - you can use the user's email as an alias for + You can use the user's email as an alias for ``{member}``. For example, ``spaces/{space}/members/example@gmail.com`` where ``example@gmail.com`` is the email of the Google Chat @@ -816,8 +871,10 @@ async def sample_get_membership(): 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.apps.chat_v1.types.Membership: @@ -880,18 +937,20 @@ async def get_message( 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]]] = (), ) -> message.Message: r"""Returns details about a message. For an example, see `Get details about a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ Note: Might return a message from a blocked member or space. @@ -940,8 +999,10 @@ async def sample_get_message(): 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.apps.chat_v1.types.Message: @@ -1001,7 +1062,7 @@ async def update_message( 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]]] = (), ) -> gc_message.Message: r"""Updates a message. There's a difference between the ``patch`` and ``update`` methods. The ``patch`` method uses a ``patch`` @@ -1010,12 +1071,15 @@ async def update_message( `Update a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only update messages created by the calling Chat app. @@ -1080,8 +1144,10 @@ async def sample_update_message(): 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.apps.chat_v1.types.Message: @@ -1144,17 +1210,20 @@ async def delete_message( 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 message. For an example, see `Delete a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only delete messages created by the calling Chat app. @@ -1200,8 +1269,10 @@ async def sample_delete_message(): 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 @@ -1253,7 +1324,7 @@ async def get_attachment( 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]]] = (), ) -> attachment.Attachment: r"""Gets the metadata of a message attachment. The attachment data is fetched using the `media @@ -1302,8 +1373,10 @@ async def sample_get_attachment(): 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.apps.chat_v1.types.Attachment: @@ -1361,11 +1434,12 @@ async def upload_attachment( *, 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]]] = (), ) -> attachment.UploadAttachmentResponse: r"""Uploads an attachment. For an example, see `Upload media as a file attachment `__. + Requires user `authentication `__. @@ -1406,8 +1480,10 @@ async def sample_upload_attachment(): 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.apps.chat_v1.types.UploadAttachmentResponse: @@ -1451,22 +1527,21 @@ async def list_spaces( *, 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.ListSpacesAsyncPager: r"""Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see `List spaces `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ - Lists spaces visible to the caller or authenticated user. Group - chats and DMs aren't listed until the first message is sent. + - `User + authentication `__ To list all named spaces by Google Workspace organization, use the @@ -1506,8 +1581,10 @@ async def sample_list_spaces(): 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.apps.chat_v1.services.chat_service.pagers.ListSpacesAsyncPager: @@ -1561,11 +1638,12 @@ async def search_spaces( *, 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.SearchSpacesAsyncPager: r"""Returns a list of spaces in a Google Workspace organization - based on an administrator's search. Requires `user - authentication with administrator + based on an administrator's search. + + Requires `user authentication with administrator privileges `__. In the request, set ``use_admin_access`` to ``true``. @@ -1603,8 +1681,10 @@ async def sample_search_spaces(): 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.apps.chat_v1.services.chat_service.pagers.SearchSpacesAsyncPager: @@ -1659,18 +1739,23 @@ async def get_space( 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]]] = (), ) -> space.Space: r"""Returns details about a space. For an example, see `Get details about a space `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -1713,8 +1798,10 @@ async def sample_get_space(): 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.apps.chat_v1.types.Space: @@ -1777,11 +1864,11 @@ async def create_space( space: Optional[gc_space.Space] = 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]]] = (), ) -> gc_space.Space: r"""Creates a space with no members. Can be used to create a named - space. Spaces grouped by topics aren't supported. For an - example, see `Create a + space, or a group chat in ``Import mode``. For an example, see + `Create a space `__. If you receive the error message ``ALREADY_EXISTS`` when @@ -1789,13 +1876,21 @@ async def create_space( space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - you can create a group chat in import mode using - ``spaceType.GROUP_CHAT``. + Supports the following types of + `authentication `__: - Requires `user - authentication `__. + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + + When authenticating as an app, the ``space.customer`` field must + be set in the request. .. code-block:: python @@ -1832,19 +1927,16 @@ async def sample_create_space(): with no members. space (:class:`google.apps.chat_v1.types.Space`): Required. The ``displayName`` and ``spaceType`` fields - must be populated. Only ``SpaceType.SPACE`` is - supported. + must be populated. Only ``SpaceType.SPACE`` and + ``SpaceType.GROUP_CHAT`` are supported. + ``SpaceType.GROUP_CHAT`` can only be used if + ``importMode`` is set to true. If you receive the error message ``ALREADY_EXISTS``, try a different ``displayName``. An existing space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - ``SpaceType.GROUP_CHAT`` can be used if ``importMode`` - is set to true. - The space ``name`` is assigned on the server so anything specified in this field will be ignored. @@ -1854,8 +1946,10 @@ async def sample_create_space(): 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.apps.chat_v1.types.Space: @@ -1911,7 +2005,7 @@ async def set_up_space( *, 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]]] = (), ) -> space.Space: r"""Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified @@ -2008,8 +2102,10 @@ async def sample_set_up_space(): 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.apps.chat_v1.types.Space: @@ -2053,7 +2149,7 @@ async def update_space( 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]]] = (), ) -> gc_space.Space: r"""Updates a space. For an example, see `Update a space `__. @@ -2063,8 +2159,21 @@ async def update_space( An existing space within the Google Workspace organization might already use this display name. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2185,8 +2294,10 @@ async def sample_update_space(): 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.apps.chat_v1.types.Space: @@ -2253,16 +2364,29 @@ async def delete_space( 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 named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see `Delete a space `__. - Requires `user - authentication `__ - from a user who has permission to delete the space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2301,8 +2425,10 @@ async def sample_delete_space(): 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 @@ -2353,13 +2479,16 @@ async def complete_import_space( *, 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]]] = (), ) -> space.CompleteImportSpaceResponse: r"""Completes the `import process `__ - for the specified space and makes it visible to users. Requires - app authentication and domain-wide delegation. For more - information, see `Authorize Google Chat apps to import + for the specified space and makes it visible to users. + + Requires `app + authentication `__ + and domain-wide delegation. For more information, see `Authorize + Google Chat apps to import data `__. .. code-block:: python @@ -2395,8 +2524,10 @@ async def sample_complete_import_space(): 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.apps.chat_v1.types.CompleteImportSpaceResponse: @@ -2442,27 +2573,31 @@ async def find_direct_message( *, 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]]] = (), ) -> space.Space: r"""Returns the existing direct message with the specified user. If no direct message space is found, returns a ``404 NOT_FOUND`` error. For an example, see `Find a direct message `__. + With `app + authentication `__, + returns the direct message space between the specified user and + the calling Chat app. + With `user authentication `__, returns the direct message space between the specified user and the authenticated user. - With `app - authentication `__, - returns the direct message space between the specified user and - the calling Chat app. + // Supports the following types of + `authentication `__: - Requires `user - authentication `__ - or `app - authentication `__. + - `App + authentication `__ + + - `User + authentication `__ .. code-block:: python @@ -2497,8 +2632,10 @@ async def sample_find_direct_message(): 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.apps.chat_v1.types.Space: @@ -2542,7 +2679,7 @@ async def create_membership( membership: Optional[gc_membership.Membership] = 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]]] = (), ) -> gc_membership.Membership: r"""Creates a membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't @@ -2550,8 +2687,23 @@ async def create_membership( has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified - space. Requires `user - authentication `__. + space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. For example usage, see: @@ -2605,27 +2757,52 @@ async def sample_create_membership(): on the ``request`` instance; if ``request`` is provided, this should not be set. membership (:class:`google.apps.chat_v1.types.Membership`): - Required. The membership relation to create. The - ``memberType`` field must contain a user with the + Required. The membership relation to create. + + The ``memberType`` field must contain a user with the ``user.name`` and ``user.type`` fields populated. The server will assign a resource name and overwrite - anything specified. When a Chat app creates a membership - relation for a human user, it must use the - ``chat.memberships`` scope, set ``user.type`` to - ``HUMAN``, and set ``user.name`` with format - ``users/{user}``, where ``{user}`` can be the email - address for the user. For users in the same Workspace - organization ``{user}`` can also be the ``id`` of the - `person `__ - from the People API, or the ``id`` for the user in the - Directory API. For example, if the People API Person - profile ID for ``user@example.com`` is ``123456789``, - you can add the user to the space by setting the - ``membership.member.name`` to ``users/user@example.com`` - or ``users/123456789``. When a Chat app creates a - membership relation for itself, it must use the - ``chat.memberships.app`` scope, set ``user.type`` to - ``BOT``, and set ``user.name`` to ``users/app``. + anything specified. + + When a Chat app creates a membership relation for a + human user, it must use certain authorization scopes and + set specific values for certain fields: + + - When `authenticating as a + user `__, + the ``chat.memberships`` authorization scope is + required. + + - When `authenticating as an + app `__, + the ``chat.app.memberships`` authorization scope is + required. Authenticating as an app is available in + `Developer + Preview `__. + + - Set ``user.type`` to ``HUMAN``, and set ``user.name`` + with format ``users/{user}``, where ``{user}`` can be + the email address for the user. For users in the same + Workspace organization ``{user}`` can also be the + ``id`` of the + `person `__ + from the People API, or the ``id`` for the user in + the Directory API. For example, if the People API + Person profile ID for ``user@example.com`` is + ``123456789``, you can add the user to the space by + setting the ``membership.member.name`` to + ``users/user@example.com`` or ``users/123456789``. + + Inviting users external to the Workspace organization + that owns the space requires `user + authentication `__. + + When a Chat app creates a membership relation for + itself, it must `authenticate as a + user `__ + and use the ``chat.memberships.app`` scope, set + ``user.type`` to ``BOT``, and set ``user.name`` to + ``users/app``. This corresponds to the ``membership`` field on the ``request`` instance; if ``request`` is provided, this @@ -2633,8 +2810,10 @@ async def sample_create_membership(): 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.apps.chat_v1.types.Membership: @@ -2700,14 +2879,27 @@ async def update_membership( 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]]] = (), ) -> gc_membership.Membership: r"""Updates a membership. For an example, see `Update a user's membership in a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2760,8 +2952,10 @@ async def sample_update_membership(): 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.apps.chat_v1.types.Membership: @@ -2828,14 +3022,27 @@ async def delete_membership( 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]]] = (), ) -> membership.Membership: r"""Deletes a membership. For an example, see `Remove a user or a Google Chat app from a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2894,8 +3101,10 @@ async def sample_delete_membership(): 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.apps.chat_v1.types.Membership: @@ -2959,11 +3168,12 @@ async def create_reaction( reaction: Optional[gc_reaction.Reaction] = 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]]] = (), ) -> gc_reaction.Reaction: r"""Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see `Add a reaction to a message `__. + Requires `user authentication `__. @@ -2983,8 +3193,12 @@ async def sample_create_reaction(): client = chat_v1.ChatServiceAsyncClient() # Initialize request argument(s) + reaction = chat_v1.Reaction() + reaction.emoji.unicode = "unicode_value" + request = chat_v1.CreateReactionRequest( parent="parent_value", + reaction=reaction, ) # Make the request @@ -3012,8 +3226,10 @@ async def sample_create_reaction(): 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.apps.chat_v1.types.Reaction: @@ -3074,11 +3290,12 @@ async def list_reactions( 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.ListReactionsAsyncPager: r"""Lists reactions to a message. For an example, see `List reactions for a message `__. + Requires `user authentication `__. @@ -3123,8 +3340,10 @@ async def sample_list_reactions(): 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.apps.chat_v1.services.chat_service.pagers.ListReactionsAsyncPager: @@ -3199,11 +3418,12 @@ async def delete_reaction( 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 reaction to a message. Only unicode emojis are supported. For an example, see `Delete a reaction `__. + Requires `user authentication `__. @@ -3245,8 +3465,10 @@ async def sample_delete_reaction(): 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 @@ -3300,7 +3522,7 @@ async def get_space_read_state( 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]]] = (), ) -> space_read_state.SpaceReadState: r"""Returns details about a user's read state within a space, used to identify read and unread messages. For an example, see `Get @@ -3365,8 +3587,10 @@ async def sample_get_space_read_state(): 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.apps.chat_v1.types.SpaceReadState: @@ -3431,7 +3655,7 @@ async def update_space_read_state( 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]]] = (), ) -> gc_space_read_state.SpaceReadState: r"""Updates a user's read state within a space, used to identify read and unread messages. For an example, see `Update a user's @@ -3515,8 +3739,10 @@ async def sample_update_space_read_state(): 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.apps.chat_v1.types.SpaceReadState: @@ -3584,7 +3810,7 @@ async def get_thread_read_state( 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]]] = (), ) -> thread_read_state.ThreadReadState: r"""Returns details about a user's read state within a thread, used to identify read and unread messages. For an example, see `Get @@ -3650,8 +3876,10 @@ async def sample_get_thread_read_state(): 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.apps.chat_v1.types.ThreadReadState: @@ -3713,7 +3941,7 @@ async def get_space_event( 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]]] = (), ) -> space_event.SpaceEvent: r"""Returns an event from a Google Chat space. The `event payload `__ @@ -3775,8 +4003,10 @@ async def sample_get_space_event(): 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.apps.chat_v1.types.SpaceEvent: @@ -3839,7 +4069,7 @@ async def list_space_events( filter: 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.ListSpaceEventsAsyncPager: r"""Lists events from a Google Chat space. For each event, the `payload `__ @@ -3967,8 +4197,10 @@ async def sample_list_space_events(): 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.apps.chat_v1.services.chat_service.pagers.ListSpaceEventsAsyncPager: diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/client.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/client.py index f38740dd5526..266684cd5ce2 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/client.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -771,6 +781,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( @@ -833,6 +847,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.chat_v1.ChatServiceClient`.", + extra={ + "serviceName": "google.chat.v1.ChatService", + "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.chat.v1.ChatService", + "credentialsType": None, + }, + ) + def create_message( self, request: Optional[Union[gc_message.CreateMessageRequest, dict]] = None, @@ -842,16 +879,18 @@ def create_message( message_id: 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]]] = (), ) -> gc_message.Message: r"""Creates a message in a Google Chat space. For an example, see `Send a message `__. - The ``create()`` method requires either user or app - authentication. Chat attributes the message sender differently - depending on the type of authentication that you use in your - request. + The ``create()`` method requires either `user + authentication `__ + or `app + authentication `__. + Chat attributes the message sender differently depending on the + type of authentication that you use in your request. The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the @@ -872,6 +911,12 @@ def create_message( The maximum message size, including the message contents, is 32,000 bytes. + For + `webhook `__ + requests, the response doesn't contain the full message. The + response only populates the ``name`` and ``thread.name`` fields + in addition to the information that was in the request. + .. |Message sent with app authentication| image:: https://developers.google.com/workspace/chat/images/message-app-auth.svg .. |Message sent with user authentication| image:: https://developers.google.com/workspace/chat/images/message-user-auth.svg @@ -944,8 +989,10 @@ def sample_create_message(): 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.apps.chat_v1.types.Message: @@ -1005,7 +1052,7 @@ def list_messages( 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.ListMessagesPager: r"""Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. If you list @@ -1013,6 +1060,7 @@ def list_messages( object. When using a REST/HTTP interface, the response contains an empty JSON object, ``{}``. For an example, see `List messages `__. + Requires `user authentication `__. @@ -1059,8 +1107,10 @@ def sample_list_messages(): 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.apps.chat_v1.services.chat_service.pagers.ListMessagesPager: @@ -1132,7 +1182,7 @@ def list_memberships( 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.ListMembershipsPager: r"""Lists memberships in a space. For an example, see `List users and Google Chat apps in a @@ -1146,12 +1196,17 @@ def list_memberships( lists memberships in spaces that the authenticated user has access to. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -1197,8 +1252,10 @@ def sample_list_memberships(): 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.apps.chat_v1.services.chat_service.pagers.ListMembershipsPager: @@ -1270,18 +1327,23 @@ def get_membership( 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]]] = (), ) -> membership.Membership: r"""Returns details about a membership. For an example, see `Get details about a user's or Google Chat app's membership `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -1323,9 +1385,7 @@ def sample_get_membership(): Format: ``spaces/{space}/members/{member}`` or ``spaces/{space}/members/app`` - When `authenticated as a - user `__, - you can use the user's email as an alias for + You can use the user's email as an alias for ``{member}``. For example, ``spaces/{space}/members/example@gmail.com`` where ``example@gmail.com`` is the email of the Google Chat @@ -1337,8 +1397,10 @@ def sample_get_membership(): 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.apps.chat_v1.types.Membership: @@ -1398,18 +1460,20 @@ def get_message( 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]]] = (), ) -> message.Message: r"""Returns details about a message. For an example, see `Get details about a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ Note: Might return a message from a blocked member or space. @@ -1458,8 +1522,10 @@ def sample_get_message(): 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.apps.chat_v1.types.Message: @@ -1516,7 +1582,7 @@ def update_message( 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]]] = (), ) -> gc_message.Message: r"""Updates a message. There's a difference between the ``patch`` and ``update`` methods. The ``patch`` method uses a ``patch`` @@ -1525,12 +1591,15 @@ def update_message( `Update a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only update messages created by the calling Chat app. @@ -1595,8 +1664,10 @@ def sample_update_message(): 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.apps.chat_v1.types.Message: @@ -1656,17 +1727,20 @@ def delete_message( 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 message. For an example, see `Delete a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only delete messages created by the calling Chat app. @@ -1712,8 +1786,10 @@ def sample_delete_message(): 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 @@ -1762,7 +1838,7 @@ def get_attachment( 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]]] = (), ) -> attachment.Attachment: r"""Gets the metadata of a message attachment. The attachment data is fetched using the `media @@ -1811,8 +1887,10 @@ def sample_get_attachment(): 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.apps.chat_v1.types.Attachment: @@ -1867,11 +1945,12 @@ def upload_attachment( *, 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]]] = (), ) -> attachment.UploadAttachmentResponse: r"""Uploads an attachment. For an example, see `Upload media as a file attachment `__. + Requires user `authentication `__. @@ -1912,8 +1991,10 @@ def sample_upload_attachment(): 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.apps.chat_v1.types.UploadAttachmentResponse: @@ -1955,22 +2036,21 @@ def list_spaces( *, 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.ListSpacesPager: r"""Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see `List spaces `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ - Lists spaces visible to the caller or authenticated user. Group - chats and DMs aren't listed until the first message is sent. + - `User + authentication `__ To list all named spaces by Google Workspace organization, use the @@ -2010,8 +2090,10 @@ def sample_list_spaces(): 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.apps.chat_v1.services.chat_service.pagers.ListSpacesPager: @@ -2063,11 +2145,12 @@ def search_spaces( *, 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.SearchSpacesPager: r"""Returns a list of spaces in a Google Workspace organization - based on an administrator's search. Requires `user - authentication with administrator + based on an administrator's search. + + Requires `user authentication with administrator privileges `__. In the request, set ``use_admin_access`` to ``true``. @@ -2105,8 +2188,10 @@ def sample_search_spaces(): 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.apps.chat_v1.services.chat_service.pagers.SearchSpacesPager: @@ -2159,18 +2244,23 @@ def get_space( 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]]] = (), ) -> space.Space: r"""Returns details about a space. For an example, see `Get details about a space `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2213,8 +2303,10 @@ def sample_get_space(): 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.apps.chat_v1.types.Space: @@ -2274,11 +2366,11 @@ def create_space( space: Optional[gc_space.Space] = 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]]] = (), ) -> gc_space.Space: r"""Creates a space with no members. Can be used to create a named - space. Spaces grouped by topics aren't supported. For an - example, see `Create a + space, or a group chat in ``Import mode``. For an example, see + `Create a space `__. If you receive the error message ``ALREADY_EXISTS`` when @@ -2286,13 +2378,21 @@ def create_space( space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - you can create a group chat in import mode using - ``spaceType.GROUP_CHAT``. + Supports the following types of + `authentication `__: - Requires `user - authentication `__. + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + + When authenticating as an app, the ``space.customer`` field must + be set in the request. .. code-block:: python @@ -2329,19 +2429,16 @@ def sample_create_space(): with no members. space (google.apps.chat_v1.types.Space): Required. The ``displayName`` and ``spaceType`` fields - must be populated. Only ``SpaceType.SPACE`` is - supported. + must be populated. Only ``SpaceType.SPACE`` and + ``SpaceType.GROUP_CHAT`` are supported. + ``SpaceType.GROUP_CHAT`` can only be used if + ``importMode`` is set to true. If you receive the error message ``ALREADY_EXISTS``, try a different ``displayName``. An existing space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - ``SpaceType.GROUP_CHAT`` can be used if ``importMode`` - is set to true. - The space ``name`` is assigned on the server so anything specified in this field will be ignored. @@ -2351,8 +2448,10 @@ def sample_create_space(): 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.apps.chat_v1.types.Space: @@ -2405,7 +2504,7 @@ def set_up_space( *, 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]]] = (), ) -> space.Space: r"""Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified @@ -2502,8 +2601,10 @@ def sample_set_up_space(): 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.apps.chat_v1.types.Space: @@ -2545,7 +2646,7 @@ def update_space( 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]]] = (), ) -> gc_space.Space: r"""Updates a space. For an example, see `Update a space `__. @@ -2555,8 +2656,21 @@ def update_space( An existing space within the Google Workspace organization might already use this display name. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2677,8 +2791,10 @@ def sample_update_space(): 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.apps.chat_v1.types.Space: @@ -2742,16 +2858,29 @@ def delete_space( 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 named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see `Delete a space `__. - Requires `user - authentication `__ - from a user who has permission to delete the space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -2790,8 +2919,10 @@ def sample_delete_space(): 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 @@ -2839,13 +2970,16 @@ def complete_import_space( *, 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]]] = (), ) -> space.CompleteImportSpaceResponse: r"""Completes the `import process `__ - for the specified space and makes it visible to users. Requires - app authentication and domain-wide delegation. For more - information, see `Authorize Google Chat apps to import + for the specified space and makes it visible to users. + + Requires `app + authentication `__ + and domain-wide delegation. For more information, see `Authorize + Google Chat apps to import data `__. .. code-block:: python @@ -2881,8 +3015,10 @@ def sample_complete_import_space(): 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.apps.chat_v1.types.CompleteImportSpaceResponse: @@ -2926,27 +3062,31 @@ def find_direct_message( *, 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]]] = (), ) -> space.Space: r"""Returns the existing direct message with the specified user. If no direct message space is found, returns a ``404 NOT_FOUND`` error. For an example, see `Find a direct message `__. + With `app + authentication `__, + returns the direct message space between the specified user and + the calling Chat app. + With `user authentication `__, returns the direct message space between the specified user and the authenticated user. - With `app - authentication `__, - returns the direct message space between the specified user and - the calling Chat app. + // Supports the following types of + `authentication `__: - Requires `user - authentication `__ - or `app - authentication `__. + - `App + authentication `__ + + - `User + authentication `__ .. code-block:: python @@ -2981,8 +3121,10 @@ def sample_find_direct_message(): 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.apps.chat_v1.types.Space: @@ -3024,7 +3166,7 @@ def create_membership( membership: Optional[gc_membership.Membership] = 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]]] = (), ) -> gc_membership.Membership: r"""Creates a membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't @@ -3032,8 +3174,23 @@ def create_membership( has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified - space. Requires `user - authentication `__. + space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. For example usage, see: @@ -3087,27 +3244,52 @@ def sample_create_membership(): on the ``request`` instance; if ``request`` is provided, this should not be set. membership (google.apps.chat_v1.types.Membership): - Required. The membership relation to create. The - ``memberType`` field must contain a user with the + Required. The membership relation to create. + + The ``memberType`` field must contain a user with the ``user.name`` and ``user.type`` fields populated. The server will assign a resource name and overwrite - anything specified. When a Chat app creates a membership - relation for a human user, it must use the - ``chat.memberships`` scope, set ``user.type`` to - ``HUMAN``, and set ``user.name`` with format - ``users/{user}``, where ``{user}`` can be the email - address for the user. For users in the same Workspace - organization ``{user}`` can also be the ``id`` of the - `person `__ - from the People API, or the ``id`` for the user in the - Directory API. For example, if the People API Person - profile ID for ``user@example.com`` is ``123456789``, - you can add the user to the space by setting the - ``membership.member.name`` to ``users/user@example.com`` - or ``users/123456789``. When a Chat app creates a - membership relation for itself, it must use the - ``chat.memberships.app`` scope, set ``user.type`` to - ``BOT``, and set ``user.name`` to ``users/app``. + anything specified. + + When a Chat app creates a membership relation for a + human user, it must use certain authorization scopes and + set specific values for certain fields: + + - When `authenticating as a + user `__, + the ``chat.memberships`` authorization scope is + required. + + - When `authenticating as an + app `__, + the ``chat.app.memberships`` authorization scope is + required. Authenticating as an app is available in + `Developer + Preview `__. + + - Set ``user.type`` to ``HUMAN``, and set ``user.name`` + with format ``users/{user}``, where ``{user}`` can be + the email address for the user. For users in the same + Workspace organization ``{user}`` can also be the + ``id`` of the + `person `__ + from the People API, or the ``id`` for the user in + the Directory API. For example, if the People API + Person profile ID for ``user@example.com`` is + ``123456789``, you can add the user to the space by + setting the ``membership.member.name`` to + ``users/user@example.com`` or ``users/123456789``. + + Inviting users external to the Workspace organization + that owns the space requires `user + authentication `__. + + When a Chat app creates a membership relation for + itself, it must `authenticate as a + user `__ + and use the ``chat.memberships.app`` scope, set + ``user.type`` to ``BOT``, and set ``user.name`` to + ``users/app``. This corresponds to the ``membership`` field on the ``request`` instance; if ``request`` is provided, this @@ -3115,8 +3297,10 @@ def sample_create_membership(): 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.apps.chat_v1.types.Membership: @@ -3179,14 +3363,27 @@ def update_membership( 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]]] = (), ) -> gc_membership.Membership: r"""Updates a membership. For an example, see `Update a user's membership in a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -3239,8 +3436,10 @@ def sample_update_membership(): 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.apps.chat_v1.types.Membership: @@ -3304,14 +3503,27 @@ def delete_membership( 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]]] = (), ) -> membership.Membership: r"""Deletes a membership. For an example, see `Remove a user or a Google Chat app from a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. .. code-block:: python @@ -3370,8 +3582,10 @@ def sample_delete_membership(): 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.apps.chat_v1.types.Membership: @@ -3432,11 +3646,12 @@ def create_reaction( reaction: Optional[gc_reaction.Reaction] = 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]]] = (), ) -> gc_reaction.Reaction: r"""Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see `Add a reaction to a message `__. + Requires `user authentication `__. @@ -3456,8 +3671,12 @@ def sample_create_reaction(): client = chat_v1.ChatServiceClient() # Initialize request argument(s) + reaction = chat_v1.Reaction() + reaction.emoji.unicode = "unicode_value" + request = chat_v1.CreateReactionRequest( parent="parent_value", + reaction=reaction, ) # Make the request @@ -3485,8 +3704,10 @@ def sample_create_reaction(): 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.apps.chat_v1.types.Reaction: @@ -3544,11 +3765,12 @@ def list_reactions( 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.ListReactionsPager: r"""Lists reactions to a message. For an example, see `List reactions for a message `__. + Requires `user authentication `__. @@ -3593,8 +3815,10 @@ def sample_list_reactions(): 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.apps.chat_v1.services.chat_service.pagers.ListReactionsPager: @@ -3666,11 +3890,12 @@ def delete_reaction( 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 reaction to a message. Only unicode emojis are supported. For an example, see `Delete a reaction `__. + Requires `user authentication `__. @@ -3712,8 +3937,10 @@ def sample_delete_reaction(): 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 @@ -3764,7 +3991,7 @@ def get_space_read_state( 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]]] = (), ) -> space_read_state.SpaceReadState: r"""Returns details about a user's read state within a space, used to identify read and unread messages. For an example, see `Get @@ -3829,8 +4056,10 @@ def sample_get_space_read_state(): 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.apps.chat_v1.types.SpaceReadState: @@ -3892,7 +4121,7 @@ def update_space_read_state( 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]]] = (), ) -> gc_space_read_state.SpaceReadState: r"""Updates a user's read state within a space, used to identify read and unread messages. For an example, see `Update a user's @@ -3976,8 +4205,10 @@ def sample_update_space_read_state(): 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.apps.chat_v1.types.SpaceReadState: @@ -4042,7 +4273,7 @@ def get_thread_read_state( 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]]] = (), ) -> thread_read_state.ThreadReadState: r"""Returns details about a user's read state within a thread, used to identify read and unread messages. For an example, see `Get @@ -4108,8 +4339,10 @@ def sample_get_thread_read_state(): 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.apps.chat_v1.types.ThreadReadState: @@ -4168,7 +4401,7 @@ def get_space_event( 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]]] = (), ) -> space_event.SpaceEvent: r"""Returns an event from a Google Chat space. The `event payload `__ @@ -4230,8 +4463,10 @@ def sample_get_space_event(): 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.apps.chat_v1.types.SpaceEvent: @@ -4291,7 +4526,7 @@ def list_space_events( filter: 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.ListSpaceEventsPager: r"""Lists events from a Google Chat space. For each event, the `payload `__ @@ -4419,8 +4654,10 @@ def sample_list_space_events(): 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.apps.chat_v1.services.chat_service.pagers.ListSpaceEventsPager: diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/pagers.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/pagers.py index 94763fc39240..ef28d4f71052 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/pagers.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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 = message.ListMessagesRequest(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 = message.ListMessagesRequest(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 = membership.ListMembershipsRequest(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 = membership.ListMembershipsRequest(request) @@ -371,7 +379,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. @@ -385,8 +393,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 = space.ListSpacesRequest(request) @@ -445,7 +455,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. @@ -459,8 +469,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 = space.ListSpacesRequest(request) @@ -523,7 +535,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. @@ -537,8 +549,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 = space.SearchSpacesRequest(request) @@ -597,7 +611,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. @@ -611,8 +625,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 = space.SearchSpacesRequest(request) @@ -675,7 +691,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. @@ -689,8 +705,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 = reaction.ListReactionsRequest(request) @@ -749,7 +767,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. @@ -763,8 +781,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 = reaction.ListReactionsRequest(request) @@ -827,7 +847,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. @@ -841,8 +861,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 = space_event.ListSpaceEventsRequest(request) @@ -901,7 +923,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. @@ -915,8 +937,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 = space_event.ListSpaceEventsRequest(request) diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc.py index d02bc6784c2a..7d85a0a227a9 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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 @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.apps.chat_v1.types import attachment from google.apps.chat_v1.types import membership @@ -39,6 +45,81 @@ from .base import DEFAULT_CLIENT_INFO, ChatServiceTransport +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.chat.v1.ChatService", + "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.chat.v1.ChatService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ChatServiceGrpcTransport(ChatServiceTransport): """gRPC backend transport for ChatService. @@ -193,7 +274,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 @@ -258,10 +344,12 @@ def create_message( `Send a message `__. - The ``create()`` method requires either user or app - authentication. Chat attributes the message sender differently - depending on the type of authentication that you use in your - request. + The ``create()`` method requires either `user + authentication `__ + or `app + authentication `__. + Chat attributes the message sender differently depending on the + type of authentication that you use in your request. The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the @@ -282,6 +370,12 @@ def create_message( The maximum message size, including the message contents, is 32,000 bytes. + For + `webhook `__ + requests, the response doesn't contain the full message. The + response only populates the ``name`` and ``thread.name`` fields + in addition to the information that was in the request. + .. |Message sent with app authentication gRPC| image:: https://developers.google.com/workspace/chat/images/message-app-auth.svg .. |Message sent with user authentication gRPC| image:: https://developers.google.com/workspace/chat/images/message-user-auth.svg @@ -296,7 +390,7 @@ def create_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_message" not in self._stubs: - self._stubs["create_message"] = self.grpc_channel.unary_unary( + self._stubs["create_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateMessage", request_serializer=gc_message.CreateMessageRequest.serialize, response_deserializer=gc_message.Message.deserialize, @@ -315,6 +409,7 @@ def list_messages( object. When using a REST/HTTP interface, the response contains an empty JSON object, ``{}``. For an example, see `List messages `__. + Requires `user authentication `__. @@ -329,7 +424,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListMessages", request_serializer=message.ListMessagesRequest.serialize, response_deserializer=message.ListMessagesResponse.deserialize, @@ -356,12 +451,17 @@ def list_memberships( lists memberships in spaces that the authenticated user has access to. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.ListMembershipsRequest], @@ -374,7 +474,7 @@ def list_memberships( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_memberships" not in self._stubs: - self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + self._stubs["list_memberships"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListMemberships", request_serializer=membership.ListMembershipsRequest.serialize, response_deserializer=membership.ListMembershipsResponse.deserialize, @@ -391,12 +491,17 @@ def get_membership( details about a user's or Google Chat app's membership `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.GetMembershipRequest], @@ -409,7 +514,7 @@ def get_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_membership" not in self._stubs: - self._stubs["get_membership"] = self.grpc_channel.unary_unary( + self._stubs["get_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetMembership", request_serializer=membership.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, @@ -424,12 +529,14 @@ def get_message(self) -> Callable[[message.GetMessageRequest], message.Message]: details about a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ Note: Might return a message from a blocked member or space. @@ -444,7 +551,7 @@ def get_message(self) -> Callable[[message.GetMessageRequest], message.Message]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_message" not in self._stubs: - self._stubs["get_message"] = self.grpc_channel.unary_unary( + self._stubs["get_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetMessage", request_serializer=message.GetMessageRequest.serialize, response_deserializer=message.Message.deserialize, @@ -464,12 +571,15 @@ def update_message( `Update a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only update messages created by the calling Chat app. @@ -484,7 +594,7 @@ def update_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_message" not in self._stubs: - self._stubs["update_message"] = self.grpc_channel.unary_unary( + self._stubs["update_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateMessage", request_serializer=gc_message.UpdateMessageRequest.serialize, response_deserializer=gc_message.Message.deserialize, @@ -500,12 +610,15 @@ def delete_message( Deletes a message. For an example, see `Delete a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only delete messages created by the calling Chat app. @@ -520,7 +633,7 @@ def delete_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_message" not in self._stubs: - self._stubs["delete_message"] = self.grpc_channel.unary_unary( + self._stubs["delete_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteMessage", request_serializer=message.DeleteMessageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -552,7 +665,7 @@ def get_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attachment" not in self._stubs: - self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + self._stubs["get_attachment"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetAttachment", request_serializer=attachment.GetAttachmentRequest.serialize, response_deserializer=attachment.Attachment.deserialize, @@ -570,6 +683,7 @@ def upload_attachment( Uploads an attachment. For an example, see `Upload media as a file attachment `__. + Requires user `authentication `__. @@ -588,7 +702,7 @@ def upload_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_attachment" not in self._stubs: - self._stubs["upload_attachment"] = self.grpc_channel.unary_unary( + self._stubs["upload_attachment"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UploadAttachment", request_serializer=attachment.UploadAttachmentRequest.serialize, response_deserializer=attachment.UploadAttachmentResponse.deserialize, @@ -606,15 +720,14 @@ def list_spaces( see `List spaces `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ - Lists spaces visible to the caller or authenticated user. Group - chats and DMs aren't listed until the first message is sent. + - `User + authentication `__ To list all named spaces by Google Workspace organization, use the @@ -632,7 +745,7 @@ def list_spaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spaces" not in self._stubs: - self._stubs["list_spaces"] = self.grpc_channel.unary_unary( + self._stubs["list_spaces"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListSpaces", request_serializer=space.ListSpacesRequest.serialize, response_deserializer=space.ListSpacesResponse.deserialize, @@ -646,8 +759,9 @@ def search_spaces( r"""Return a callable for the search spaces method over gRPC. Returns a list of spaces in a Google Workspace organization - based on an administrator's search. Requires `user - authentication with administrator + based on an administrator's search. + + Requires `user authentication with administrator privileges `__. In the request, set ``use_admin_access`` to ``true``. @@ -662,7 +776,7 @@ def search_spaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_spaces" not in self._stubs: - self._stubs["search_spaces"] = self.grpc_channel.unary_unary( + self._stubs["search_spaces"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/SearchSpaces", request_serializer=space.SearchSpacesRequest.serialize, response_deserializer=space.SearchSpacesResponse.deserialize, @@ -677,12 +791,17 @@ def get_space(self) -> Callable[[space.GetSpaceRequest], space.Space]: about a space `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.GetSpaceRequest], @@ -695,7 +814,7 @@ def get_space(self) -> Callable[[space.GetSpaceRequest], space.Space]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpace", request_serializer=space.GetSpaceRequest.serialize, response_deserializer=space.Space.deserialize, @@ -707,8 +826,8 @@ def create_space(self) -> Callable[[gc_space.CreateSpaceRequest], gc_space.Space r"""Return a callable for the create space method over gRPC. Creates a space with no members. Can be used to create a named - space. Spaces grouped by topics aren't supported. For an - example, see `Create a + space, or a group chat in ``Import mode``. For an example, see + `Create a space `__. If you receive the error message ``ALREADY_EXISTS`` when @@ -716,13 +835,21 @@ def create_space(self) -> Callable[[gc_space.CreateSpaceRequest], gc_space.Space space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - you can create a group chat in import mode using - ``spaceType.GROUP_CHAT``. + Supports the following types of + `authentication `__: - Requires `user - authentication `__. + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + + When authenticating as an app, the ``space.customer`` field must + be set in the request. Returns: Callable[[~.CreateSpaceRequest], @@ -735,7 +862,7 @@ def create_space(self) -> Callable[[gc_space.CreateSpaceRequest], gc_space.Space # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateSpace", request_serializer=gc_space.CreateSpaceRequest.serialize, response_deserializer=gc_space.Space.deserialize, @@ -816,7 +943,7 @@ def set_up_space(self) -> Callable[[space_setup.SetUpSpaceRequest], space.Space] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_up_space" not in self._stubs: - self._stubs["set_up_space"] = self.grpc_channel.unary_unary( + self._stubs["set_up_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/SetUpSpace", request_serializer=space_setup.SetUpSpaceRequest.serialize, response_deserializer=space.Space.deserialize, @@ -835,8 +962,21 @@ def update_space(self) -> Callable[[gc_space.UpdateSpaceRequest], gc_space.Space An existing space within the Google Workspace organization might already use this display name. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.UpdateSpaceRequest], @@ -849,7 +989,7 @@ def update_space(self) -> Callable[[gc_space.UpdateSpaceRequest], gc_space.Space # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateSpace", request_serializer=gc_space.UpdateSpaceRequest.serialize, response_deserializer=gc_space.Space.deserialize, @@ -865,9 +1005,22 @@ def delete_space(self) -> Callable[[space.DeleteSpaceRequest], empty_pb2.Empty]: the space and memberships in the space—are also deleted. For an example, see `Delete a space `__. - Requires `user - authentication `__ - from a user who has permission to delete the space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.DeleteSpaceRequest], @@ -880,7 +1033,7 @@ def delete_space(self) -> Callable[[space.DeleteSpaceRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_space" not in self._stubs: - self._stubs["delete_space"] = self.grpc_channel.unary_unary( + self._stubs["delete_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteSpace", request_serializer=space.DeleteSpaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -897,9 +1050,12 @@ def complete_import_space( Completes the `import process `__ - for the specified space and makes it visible to users. Requires - app authentication and domain-wide delegation. For more - information, see `Authorize Google Chat apps to import + for the specified space and makes it visible to users. + + Requires `app + authentication `__ + and domain-wide delegation. For more information, see `Authorize + Google Chat apps to import data `__. Returns: @@ -913,7 +1069,7 @@ def complete_import_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_import_space" not in self._stubs: - self._stubs["complete_import_space"] = self.grpc_channel.unary_unary( + self._stubs["complete_import_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CompleteImportSpace", request_serializer=space.CompleteImportSpaceRequest.serialize, response_deserializer=space.CompleteImportSpaceResponse.deserialize, @@ -931,20 +1087,24 @@ def find_direct_message( error. For an example, see `Find a direct message `__. + With `app + authentication `__, + returns the direct message space between the specified user and + the calling Chat app. + With `user authentication `__, returns the direct message space between the specified user and the authenticated user. - With `app - authentication `__, - returns the direct message space between the specified user and - the calling Chat app. + // Supports the following types of + `authentication `__: - Requires `user - authentication `__ - or `app - authentication `__. + - `App + authentication `__ + + - `User + authentication `__ Returns: Callable[[~.FindDirectMessageRequest], @@ -957,7 +1117,7 @@ def find_direct_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "find_direct_message" not in self._stubs: - self._stubs["find_direct_message"] = self.grpc_channel.unary_unary( + self._stubs["find_direct_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/FindDirectMessage", request_serializer=space.FindDirectMessageRequest.serialize, response_deserializer=space.Space.deserialize, @@ -976,8 +1136,23 @@ def create_membership( has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified - space. Requires `user - authentication `__. + space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. For example usage, see: @@ -1001,7 +1176,7 @@ def create_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_membership" not in self._stubs: - self._stubs["create_membership"] = self.grpc_channel.unary_unary( + self._stubs["create_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateMembership", request_serializer=gc_membership.CreateMembershipRequest.serialize, response_deserializer=gc_membership.Membership.deserialize, @@ -1018,8 +1193,21 @@ def update_membership( membership in a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.UpdateMembershipRequest], @@ -1032,7 +1220,7 @@ def update_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_membership" not in self._stubs: - self._stubs["update_membership"] = self.grpc_channel.unary_unary( + self._stubs["update_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateMembership", request_serializer=gc_membership.UpdateMembershipRequest.serialize, response_deserializer=gc_membership.Membership.deserialize, @@ -1049,8 +1237,21 @@ def delete_membership( Google Chat app from a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.DeleteMembershipRequest], @@ -1063,7 +1264,7 @@ def delete_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_membership" not in self._stubs: - self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + self._stubs["delete_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteMembership", request_serializer=membership.DeleteMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, @@ -1079,6 +1280,7 @@ def create_reaction( Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see `Add a reaction to a message `__. + Requires `user authentication `__. @@ -1093,7 +1295,7 @@ def create_reaction( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reaction" not in self._stubs: - self._stubs["create_reaction"] = self.grpc_channel.unary_unary( + self._stubs["create_reaction"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateReaction", request_serializer=gc_reaction.CreateReactionRequest.serialize, response_deserializer=gc_reaction.Reaction.deserialize, @@ -1109,6 +1311,7 @@ def list_reactions( Lists reactions to a message. For an example, see `List reactions for a message `__. + Requires `user authentication `__. @@ -1123,7 +1326,7 @@ def list_reactions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reactions" not in self._stubs: - self._stubs["list_reactions"] = self.grpc_channel.unary_unary( + self._stubs["list_reactions"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListReactions", request_serializer=reaction.ListReactionsRequest.serialize, response_deserializer=reaction.ListReactionsResponse.deserialize, @@ -1139,6 +1342,7 @@ def delete_reaction( Deletes a reaction to a message. Only unicode emojis are supported. For an example, see `Delete a reaction `__. + Requires `user authentication `__. @@ -1153,7 +1357,7 @@ def delete_reaction( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reaction" not in self._stubs: - self._stubs["delete_reaction"] = self.grpc_channel.unary_unary( + self._stubs["delete_reaction"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteReaction", request_serializer=reaction.DeleteReactionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1187,7 +1391,7 @@ def get_space_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space_read_state" not in self._stubs: - self._stubs["get_space_read_state"] = self.grpc_channel.unary_unary( + self._stubs["get_space_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpaceReadState", request_serializer=space_read_state.GetSpaceReadStateRequest.serialize, response_deserializer=space_read_state.SpaceReadState.deserialize, @@ -1222,7 +1426,7 @@ def update_space_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space_read_state" not in self._stubs: - self._stubs["update_space_read_state"] = self.grpc_channel.unary_unary( + self._stubs["update_space_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateSpaceReadState", request_serializer=gc_space_read_state.UpdateSpaceReadStateRequest.serialize, response_deserializer=gc_space_read_state.SpaceReadState.deserialize, @@ -1256,7 +1460,7 @@ def get_thread_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_thread_read_state" not in self._stubs: - self._stubs["get_thread_read_state"] = self.grpc_channel.unary_unary( + self._stubs["get_thread_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetThreadReadState", request_serializer=thread_read_state.GetThreadReadStateRequest.serialize, response_deserializer=thread_read_state.ThreadReadState.deserialize, @@ -1299,7 +1503,7 @@ def get_space_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space_event" not in self._stubs: - self._stubs["get_space_event"] = self.grpc_channel.unary_unary( + self._stubs["get_space_event"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpaceEvent", request_serializer=space_event.GetSpaceEventRequest.serialize, response_deserializer=space_event.SpaceEvent.deserialize, @@ -1342,7 +1546,7 @@ def list_space_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_space_events" not in self._stubs: - self._stubs["list_space_events"] = self.grpc_channel.unary_unary( + self._stubs["list_space_events"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListSpaceEvents", request_serializer=space_event.ListSpaceEventsRequest.serialize, response_deserializer=space_event.ListSpaceEventsResponse.deserialize, @@ -1350,7 +1554,7 @@ def list_space_events( return self._stubs["list_space_events"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc_asyncio.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc_asyncio.py index d871ee9211f9..8512dd48da9f 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/grpc_asyncio.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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 @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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.apps.chat_v1.types import attachment from google.apps.chat_v1.types import membership @@ -43,6 +49,82 @@ from .base import DEFAULT_CLIENT_INFO, ChatServiceTransport from .grpc import ChatServiceGrpcTransport +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.chat.v1.ChatService", + "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.chat.v1.ChatService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ChatServiceGrpcAsyncIOTransport(ChatServiceTransport): """gRPC AsyncIO backend transport for ChatService. @@ -240,10 +322,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 @@ -266,10 +351,12 @@ def create_message( `Send a message `__. - The ``create()`` method requires either user or app - authentication. Chat attributes the message sender differently - depending on the type of authentication that you use in your - request. + The ``create()`` method requires either `user + authentication `__ + or `app + authentication `__. + Chat attributes the message sender differently depending on the + type of authentication that you use in your request. The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the @@ -290,6 +377,12 @@ def create_message( The maximum message size, including the message contents, is 32,000 bytes. + For + `webhook `__ + requests, the response doesn't contain the full message. The + response only populates the ``name`` and ``thread.name`` fields + in addition to the information that was in the request. + .. |Message sent with app authentication async gRPC| image:: https://developers.google.com/workspace/chat/images/message-app-auth.svg .. |Message sent with user authentication async gRPC| image:: https://developers.google.com/workspace/chat/images/message-user-auth.svg @@ -304,7 +397,7 @@ def create_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_message" not in self._stubs: - self._stubs["create_message"] = self.grpc_channel.unary_unary( + self._stubs["create_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateMessage", request_serializer=gc_message.CreateMessageRequest.serialize, response_deserializer=gc_message.Message.deserialize, @@ -325,6 +418,7 @@ def list_messages( object. When using a REST/HTTP interface, the response contains an empty JSON object, ``{}``. For an example, see `List messages `__. + Requires `user authentication `__. @@ -339,7 +433,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListMessages", request_serializer=message.ListMessagesRequest.serialize, response_deserializer=message.ListMessagesResponse.deserialize, @@ -367,12 +461,17 @@ def list_memberships( lists memberships in spaces that the authenticated user has access to. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.ListMembershipsRequest], @@ -385,7 +484,7 @@ def list_memberships( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_memberships" not in self._stubs: - self._stubs["list_memberships"] = self.grpc_channel.unary_unary( + self._stubs["list_memberships"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListMemberships", request_serializer=membership.ListMembershipsRequest.serialize, response_deserializer=membership.ListMembershipsResponse.deserialize, @@ -402,12 +501,17 @@ def get_membership( details about a user's or Google Chat app's membership `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.GetMembershipRequest], @@ -420,7 +524,7 @@ def get_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_membership" not in self._stubs: - self._stubs["get_membership"] = self.grpc_channel.unary_unary( + self._stubs["get_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetMembership", request_serializer=membership.GetMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, @@ -437,12 +541,14 @@ def get_message( details about a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ Note: Might return a message from a blocked member or space. @@ -457,7 +563,7 @@ def get_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_message" not in self._stubs: - self._stubs["get_message"] = self.grpc_channel.unary_unary( + self._stubs["get_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetMessage", request_serializer=message.GetMessageRequest.serialize, response_deserializer=message.Message.deserialize, @@ -477,12 +583,15 @@ def update_message( `Update a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only update messages created by the calling Chat app. @@ -497,7 +606,7 @@ def update_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_message" not in self._stubs: - self._stubs["update_message"] = self.grpc_channel.unary_unary( + self._stubs["update_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateMessage", request_serializer=gc_message.UpdateMessageRequest.serialize, response_deserializer=gc_message.Message.deserialize, @@ -513,12 +622,15 @@ def delete_message( Deletes a message. For an example, see `Delete a message `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + When using app authentication, requests can only delete messages created by the calling Chat app. @@ -533,7 +645,7 @@ def delete_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_message" not in self._stubs: - self._stubs["delete_message"] = self.grpc_channel.unary_unary( + self._stubs["delete_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteMessage", request_serializer=message.DeleteMessageRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -565,7 +677,7 @@ def get_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attachment" not in self._stubs: - self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + self._stubs["get_attachment"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetAttachment", request_serializer=attachment.GetAttachmentRequest.serialize, response_deserializer=attachment.Attachment.deserialize, @@ -584,6 +696,7 @@ def upload_attachment( Uploads an attachment. For an example, see `Upload media as a file attachment `__. + Requires user `authentication `__. @@ -602,7 +715,7 @@ def upload_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_attachment" not in self._stubs: - self._stubs["upload_attachment"] = self.grpc_channel.unary_unary( + self._stubs["upload_attachment"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UploadAttachment", request_serializer=attachment.UploadAttachmentRequest.serialize, response_deserializer=attachment.UploadAttachmentResponse.deserialize, @@ -620,15 +733,14 @@ def list_spaces( see `List spaces `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ - Lists spaces visible to the caller or authenticated user. Group - chats and DMs aren't listed until the first message is sent. + - `User + authentication `__ To list all named spaces by Google Workspace organization, use the @@ -646,7 +758,7 @@ def list_spaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_spaces" not in self._stubs: - self._stubs["list_spaces"] = self.grpc_channel.unary_unary( + self._stubs["list_spaces"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListSpaces", request_serializer=space.ListSpacesRequest.serialize, response_deserializer=space.ListSpacesResponse.deserialize, @@ -660,8 +772,9 @@ def search_spaces( r"""Return a callable for the search spaces method over gRPC. Returns a list of spaces in a Google Workspace organization - based on an administrator's search. Requires `user - authentication with administrator + based on an administrator's search. + + Requires `user authentication with administrator privileges `__. In the request, set ``use_admin_access`` to ``true``. @@ -676,7 +789,7 @@ def search_spaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_spaces" not in self._stubs: - self._stubs["search_spaces"] = self.grpc_channel.unary_unary( + self._stubs["search_spaces"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/SearchSpaces", request_serializer=space.SearchSpacesRequest.serialize, response_deserializer=space.SearchSpacesResponse.deserialize, @@ -691,12 +804,17 @@ def get_space(self) -> Callable[[space.GetSpaceRequest], Awaitable[space.Space]] about a space `__. - Requires - `authentication `__. - Supports `app - authentication `__ - and `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.GetSpaceRequest], @@ -709,7 +827,7 @@ def get_space(self) -> Callable[[space.GetSpaceRequest], Awaitable[space.Space]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpace", request_serializer=space.GetSpaceRequest.serialize, response_deserializer=space.Space.deserialize, @@ -723,8 +841,8 @@ def create_space( r"""Return a callable for the create space method over gRPC. Creates a space with no members. Can be used to create a named - space. Spaces grouped by topics aren't supported. For an - example, see `Create a + space, or a group chat in ``Import mode``. For an example, see + `Create a space `__. If you receive the error message ``ALREADY_EXISTS`` when @@ -732,13 +850,21 @@ def create_space( space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - you can create a group chat in import mode using - ``spaceType.GROUP_CHAT``. + Supports the following types of + `authentication `__: - Requires `user - authentication `__. + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + + When authenticating as an app, the ``space.customer`` field must + be set in the request. Returns: Callable[[~.CreateSpaceRequest], @@ -751,7 +877,7 @@ def create_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateSpace", request_serializer=gc_space.CreateSpaceRequest.serialize, response_deserializer=gc_space.Space.deserialize, @@ -834,7 +960,7 @@ def set_up_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_up_space" not in self._stubs: - self._stubs["set_up_space"] = self.grpc_channel.unary_unary( + self._stubs["set_up_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/SetUpSpace", request_serializer=space_setup.SetUpSpaceRequest.serialize, response_deserializer=space.Space.deserialize, @@ -855,8 +981,21 @@ def update_space( An existing space within the Google Workspace organization might already use this display name. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.UpdateSpaceRequest], @@ -869,7 +1008,7 @@ def update_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateSpace", request_serializer=gc_space.UpdateSpaceRequest.serialize, response_deserializer=gc_space.Space.deserialize, @@ -887,9 +1026,22 @@ def delete_space( the space and memberships in the space—are also deleted. For an example, see `Delete a space `__. - Requires `user - authentication `__ - from a user who has permission to delete the space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.DeleteSpaceRequest], @@ -902,7 +1054,7 @@ def delete_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_space" not in self._stubs: - self._stubs["delete_space"] = self.grpc_channel.unary_unary( + self._stubs["delete_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteSpace", request_serializer=space.DeleteSpaceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -919,9 +1071,12 @@ def complete_import_space( Completes the `import process `__ - for the specified space and makes it visible to users. Requires - app authentication and domain-wide delegation. For more - information, see `Authorize Google Chat apps to import + for the specified space and makes it visible to users. + + Requires `app + authentication `__ + and domain-wide delegation. For more information, see `Authorize + Google Chat apps to import data `__. Returns: @@ -935,7 +1090,7 @@ def complete_import_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_import_space" not in self._stubs: - self._stubs["complete_import_space"] = self.grpc_channel.unary_unary( + self._stubs["complete_import_space"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CompleteImportSpace", request_serializer=space.CompleteImportSpaceRequest.serialize, response_deserializer=space.CompleteImportSpaceResponse.deserialize, @@ -953,20 +1108,24 @@ def find_direct_message( error. For an example, see `Find a direct message `__. + With `app + authentication `__, + returns the direct message space between the specified user and + the calling Chat app. + With `user authentication `__, returns the direct message space between the specified user and the authenticated user. - With `app - authentication `__, - returns the direct message space between the specified user and - the calling Chat app. + // Supports the following types of + `authentication `__: - Requires `user - authentication `__ - or `app - authentication `__. + - `App + authentication `__ + + - `User + authentication `__ Returns: Callable[[~.FindDirectMessageRequest], @@ -979,7 +1138,7 @@ def find_direct_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "find_direct_message" not in self._stubs: - self._stubs["find_direct_message"] = self.grpc_channel.unary_unary( + self._stubs["find_direct_message"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/FindDirectMessage", request_serializer=space.FindDirectMessageRequest.serialize, response_deserializer=space.Space.deserialize, @@ -1000,8 +1159,23 @@ def create_membership( has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified - space. Requires `user - authentication `__. + space. + + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. For example usage, see: @@ -1025,7 +1199,7 @@ def create_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_membership" not in self._stubs: - self._stubs["create_membership"] = self.grpc_channel.unary_unary( + self._stubs["create_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateMembership", request_serializer=gc_membership.CreateMembershipRequest.serialize, response_deserializer=gc_membership.Membership.deserialize, @@ -1044,8 +1218,21 @@ def update_membership( membership in a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.UpdateMembershipRequest], @@ -1058,7 +1245,7 @@ def update_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_membership" not in self._stubs: - self._stubs["update_membership"] = self.grpc_channel.unary_unary( + self._stubs["update_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateMembership", request_serializer=gc_membership.UpdateMembershipRequest.serialize, response_deserializer=gc_membership.Membership.deserialize, @@ -1077,8 +1264,21 @@ def delete_membership( Google Chat app from a space `__. - Requires `user - authentication `__. + Supports the following types of + `authentication `__: + + - `App + authentication `__ + with `administrator + approval `__ in + `Developer + Preview `__ + + - `User + authentication `__ + You can authenticate and authorize this method with + administrator privileges by setting the ``use_admin_access`` + field in the request. Returns: Callable[[~.DeleteMembershipRequest], @@ -1091,7 +1291,7 @@ def delete_membership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_membership" not in self._stubs: - self._stubs["delete_membership"] = self.grpc_channel.unary_unary( + self._stubs["delete_membership"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteMembership", request_serializer=membership.DeleteMembershipRequest.serialize, response_deserializer=membership.Membership.deserialize, @@ -1107,6 +1307,7 @@ def create_reaction( Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see `Add a reaction to a message `__. + Requires `user authentication `__. @@ -1121,7 +1322,7 @@ def create_reaction( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reaction" not in self._stubs: - self._stubs["create_reaction"] = self.grpc_channel.unary_unary( + self._stubs["create_reaction"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/CreateReaction", request_serializer=gc_reaction.CreateReactionRequest.serialize, response_deserializer=gc_reaction.Reaction.deserialize, @@ -1139,6 +1340,7 @@ def list_reactions( Lists reactions to a message. For an example, see `List reactions for a message `__. + Requires `user authentication `__. @@ -1153,7 +1355,7 @@ def list_reactions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reactions" not in self._stubs: - self._stubs["list_reactions"] = self.grpc_channel.unary_unary( + self._stubs["list_reactions"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListReactions", request_serializer=reaction.ListReactionsRequest.serialize, response_deserializer=reaction.ListReactionsResponse.deserialize, @@ -1169,6 +1371,7 @@ def delete_reaction( Deletes a reaction to a message. Only unicode emojis are supported. For an example, see `Delete a reaction `__. + Requires `user authentication `__. @@ -1183,7 +1386,7 @@ def delete_reaction( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reaction" not in self._stubs: - self._stubs["delete_reaction"] = self.grpc_channel.unary_unary( + self._stubs["delete_reaction"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/DeleteReaction", request_serializer=reaction.DeleteReactionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1218,7 +1421,7 @@ def get_space_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space_read_state" not in self._stubs: - self._stubs["get_space_read_state"] = self.grpc_channel.unary_unary( + self._stubs["get_space_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpaceReadState", request_serializer=space_read_state.GetSpaceReadStateRequest.serialize, response_deserializer=space_read_state.SpaceReadState.deserialize, @@ -1253,7 +1456,7 @@ def update_space_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space_read_state" not in self._stubs: - self._stubs["update_space_read_state"] = self.grpc_channel.unary_unary( + self._stubs["update_space_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/UpdateSpaceReadState", request_serializer=gc_space_read_state.UpdateSpaceReadStateRequest.serialize, response_deserializer=gc_space_read_state.SpaceReadState.deserialize, @@ -1288,7 +1491,7 @@ def get_thread_read_state( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_thread_read_state" not in self._stubs: - self._stubs["get_thread_read_state"] = self.grpc_channel.unary_unary( + self._stubs["get_thread_read_state"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetThreadReadState", request_serializer=thread_read_state.GetThreadReadStateRequest.serialize, response_deserializer=thread_read_state.ThreadReadState.deserialize, @@ -1333,7 +1536,7 @@ def get_space_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space_event" not in self._stubs: - self._stubs["get_space_event"] = self.grpc_channel.unary_unary( + self._stubs["get_space_event"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/GetSpaceEvent", request_serializer=space_event.GetSpaceEventRequest.serialize, response_deserializer=space_event.SpaceEvent.deserialize, @@ -1377,7 +1580,7 @@ def list_space_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_space_events" not in self._stubs: - self._stubs["list_space_events"] = self.grpc_channel.unary_unary( + self._stubs["list_space_events"] = self._logged_channel.unary_unary( "/google.chat.v1.ChatService/ListSpaceEvents", request_serializer=space_event.ListSpaceEventsRequest.serialize, response_deserializer=space_event.ListSpaceEventsResponse.deserialize, @@ -1801,7 +2004,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: diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest.py index e2892374b18c..fe861b816728 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/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 @@ -50,6 +50,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, @@ -302,8 +310,10 @@ def post_upload_attachment(self, response): def pre_complete_import_space( self, request: space.CompleteImportSpaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space.CompleteImportSpaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + space.CompleteImportSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for complete_import_space Override in a subclass to manipulate the request or metadata @@ -325,8 +335,10 @@ def post_complete_import_space( def pre_create_membership( self, request: gc_membership.CreateMembershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gc_membership.CreateMembershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gc_membership.CreateMembershipRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_membership Override in a subclass to manipulate the request or metadata @@ -348,8 +360,10 @@ def post_create_membership( def pre_create_message( self, request: gc_message.CreateMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gc_message.CreateMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gc_message.CreateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_message Override in a subclass to manipulate the request or metadata @@ -369,8 +383,10 @@ def post_create_message(self, response: gc_message.Message) -> gc_message.Messag def pre_create_reaction( self, request: gc_reaction.CreateReactionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gc_reaction.CreateReactionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gc_reaction.CreateReactionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_reaction Override in a subclass to manipulate the request or metadata @@ -390,8 +406,10 @@ def post_create_reaction( return response def pre_create_space( - self, request: gc_space.CreateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gc_space.CreateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: gc_space.CreateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gc_space.CreateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_space Override in a subclass to manipulate the request or metadata @@ -411,8 +429,10 @@ def post_create_space(self, response: gc_space.Space) -> gc_space.Space: def pre_delete_membership( self, request: membership.DeleteMembershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[membership.DeleteMembershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + membership.DeleteMembershipRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_membership Override in a subclass to manipulate the request or metadata @@ -432,8 +452,10 @@ def post_delete_membership( return response def pre_delete_message( - self, request: message.DeleteMessageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[message.DeleteMessageRequest, Sequence[Tuple[str, str]]]: + self, + request: message.DeleteMessageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[message.DeleteMessageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_message Override in a subclass to manipulate the request or metadata @@ -444,8 +466,8 @@ def pre_delete_message( def pre_delete_reaction( self, request: reaction.DeleteReactionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reaction.DeleteReactionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[reaction.DeleteReactionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_reaction Override in a subclass to manipulate the request or metadata @@ -454,8 +476,10 @@ def pre_delete_reaction( return request, metadata def pre_delete_space( - self, request: space.DeleteSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[space.DeleteSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: space.DeleteSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space.DeleteSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_space Override in a subclass to manipulate the request or metadata @@ -466,8 +490,8 @@ def pre_delete_space( def pre_find_direct_message( self, request: space.FindDirectMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space.FindDirectMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space.FindDirectMessageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for find_direct_message Override in a subclass to manipulate the request or metadata @@ -487,8 +511,10 @@ def post_find_direct_message(self, response: space.Space) -> space.Space: def pre_get_attachment( self, request: attachment.GetAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment.GetAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment.GetAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_attachment Override in a subclass to manipulate the request or metadata @@ -510,8 +536,10 @@ def post_get_attachment( def pre_get_membership( self, request: membership.GetMembershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[membership.GetMembershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + membership.GetMembershipRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_membership Override in a subclass to manipulate the request or metadata @@ -531,8 +559,10 @@ def post_get_membership( return response def pre_get_message( - self, request: message.GetMessageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[message.GetMessageRequest, Sequence[Tuple[str, str]]]: + self, + request: message.GetMessageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[message.GetMessageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_message Override in a subclass to manipulate the request or metadata @@ -550,8 +580,10 @@ def post_get_message(self, response: message.Message) -> message.Message: return response def pre_get_space( - self, request: space.GetSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[space.GetSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: space.GetSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space.GetSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_space Override in a subclass to manipulate the request or metadata @@ -571,8 +603,10 @@ def post_get_space(self, response: space.Space) -> space.Space: def pre_get_space_event( self, request: space_event.GetSpaceEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space_event.GetSpaceEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + space_event.GetSpaceEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_space_event Override in a subclass to manipulate the request or metadata @@ -594,8 +628,11 @@ def post_get_space_event( def pre_get_space_read_state( self, request: space_read_state.GetSpaceReadStateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space_read_state.GetSpaceReadStateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + space_read_state.GetSpaceReadStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_space_read_state Override in a subclass to manipulate the request or metadata @@ -617,8 +654,11 @@ def post_get_space_read_state( def pre_get_thread_read_state( self, request: thread_read_state.GetThreadReadStateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[thread_read_state.GetThreadReadStateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + thread_read_state.GetThreadReadStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_thread_read_state Override in a subclass to manipulate the request or metadata @@ -640,8 +680,10 @@ def post_get_thread_read_state( def pre_list_memberships( self, request: membership.ListMembershipsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[membership.ListMembershipsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + membership.ListMembershipsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_memberships Override in a subclass to manipulate the request or metadata @@ -661,8 +703,10 @@ def post_list_memberships( return response def pre_list_messages( - self, request: message.ListMessagesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[message.ListMessagesRequest, Sequence[Tuple[str, str]]]: + self, + request: message.ListMessagesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[message.ListMessagesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_messages Override in a subclass to manipulate the request or metadata @@ -684,8 +728,8 @@ def post_list_messages( def pre_list_reactions( self, request: reaction.ListReactionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reaction.ListReactionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[reaction.ListReactionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_reactions Override in a subclass to manipulate the request or metadata @@ -707,8 +751,10 @@ def post_list_reactions( def pre_list_space_events( self, request: space_event.ListSpaceEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space_event.ListSpaceEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + space_event.ListSpaceEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_space_events Override in a subclass to manipulate the request or metadata @@ -728,8 +774,10 @@ def post_list_space_events( return response def pre_list_spaces( - self, request: space.ListSpacesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[space.ListSpacesRequest, Sequence[Tuple[str, str]]]: + self, + request: space.ListSpacesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space.ListSpacesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_spaces Override in a subclass to manipulate the request or metadata @@ -749,8 +797,10 @@ def post_list_spaces( return response def pre_search_spaces( - self, request: space.SearchSpacesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[space.SearchSpacesRequest, Sequence[Tuple[str, str]]]: + self, + request: space.SearchSpacesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space.SearchSpacesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_spaces Override in a subclass to manipulate the request or metadata @@ -772,8 +822,8 @@ def post_search_spaces( def pre_set_up_space( self, request: space_setup.SetUpSpaceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[space_setup.SetUpSpaceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[space_setup.SetUpSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_up_space Override in a subclass to manipulate the request or metadata @@ -793,8 +843,10 @@ def post_set_up_space(self, response: space.Space) -> space.Space: def pre_update_membership( self, request: gc_membership.UpdateMembershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gc_membership.UpdateMembershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gc_membership.UpdateMembershipRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_membership Override in a subclass to manipulate the request or metadata @@ -816,8 +868,10 @@ def post_update_membership( def pre_update_message( self, request: gc_message.UpdateMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gc_message.UpdateMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gc_message.UpdateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_message Override in a subclass to manipulate the request or metadata @@ -835,8 +889,10 @@ def post_update_message(self, response: gc_message.Message) -> gc_message.Messag return response def pre_update_space( - self, request: gc_space.UpdateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gc_space.UpdateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: gc_space.UpdateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gc_space.UpdateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_space Override in a subclass to manipulate the request or metadata @@ -856,9 +912,10 @@ def post_update_space(self, response: gc_space.Space) -> gc_space.Space: def pre_update_space_read_state( self, request: gc_space_read_state.UpdateSpaceReadStateRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gc_space_read_state.UpdateSpaceReadStateRequest, Sequence[Tuple[str, str]] + gc_space_read_state.UpdateSpaceReadStateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_space_read_state @@ -881,8 +938,10 @@ def post_update_space_read_state( def pre_upload_attachment( self, request: attachment.UploadAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment.UploadAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment.UploadAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for upload_attachment Override in a subclass to manipulate the request or metadata @@ -1024,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]]] = (), ) -> space.CompleteImportSpaceResponse: r"""Call the complete import space method over HTTP. @@ -1035,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: ~.space.CompleteImportSpaceResponse: @@ -1048,6 +1109,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseCompleteImportSpace._get_http_options() ) + request, metadata = self._interceptor.pre_complete_import_space( request, metadata ) @@ -1064,6 +1126,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 = 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.chat_v1.ChatServiceClient.CompleteImportSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CompleteImportSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._CompleteImportSpace._get_response( self._host, @@ -1085,7 +1174,31 @@ def __call__( pb_resp = space.CompleteImportSpaceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_import_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.CompleteImportSpaceResponse.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.chat_v1.ChatServiceClient.complete_import_space", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CompleteImportSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMembership( @@ -1123,7 +1236,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]]] = (), ) -> gc_membership.Membership: r"""Call the create membership method over HTTP. @@ -1134,8 +1247,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: ~.gc_membership.Membership: @@ -1149,6 +1264,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseCreateMembership._get_http_options() ) + request, metadata = self._interceptor.pre_create_membership( request, metadata ) @@ -1165,6 +1281,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 = 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.chat_v1.ChatServiceClient.CreateMembership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateMembership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._CreateMembership._get_response( self._host, @@ -1186,7 +1329,29 @@ def __call__( pb_resp = gc_membership.Membership.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_membership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_membership.Membership.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.chat_v1.ChatServiceClient.create_membership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateMembership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMessage( @@ -1224,7 +1389,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]]] = (), ) -> gc_message.Message: r"""Call the create message method over HTTP. @@ -1234,8 +1399,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: ~.gc_message.Message: @@ -1245,6 +1412,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseCreateMessage._get_http_options() ) + request, metadata = self._interceptor.pre_create_message(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseCreateMessage._get_transcoded_request( http_options, request @@ -1263,6 +1431,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.chat_v1.ChatServiceClient.CreateMessage", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._CreateMessage._get_response( self._host, @@ -1284,7 +1479,29 @@ def __call__( pb_resp = gc_message.Message.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_message.Message.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.chat_v1.ChatServiceClient.create_message", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReaction( @@ -1322,7 +1539,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]]] = (), ) -> gc_reaction.Reaction: r"""Call the create reaction method over HTTP. @@ -1332,8 +1549,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: ~.gc_reaction.Reaction: @@ -1343,6 +1562,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseCreateReaction._get_http_options() ) + request, metadata = self._interceptor.pre_create_reaction(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseCreateReaction._get_transcoded_request( http_options, request @@ -1357,6 +1577,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 = 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.chat_v1.ChatServiceClient.CreateReaction", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateReaction", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._CreateReaction._get_response( self._host, @@ -1378,7 +1625,29 @@ def __call__( pb_resp = gc_reaction.Reaction.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reaction(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_reaction.Reaction.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.chat_v1.ChatServiceClient.create_reaction", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateReaction", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSpace( @@ -1416,7 +1685,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]]] = (), ) -> gc_space.Space: r"""Call the create space method over HTTP. @@ -1427,8 +1696,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: ~.gc_space.Space: @@ -1442,6 +1713,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseCreateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_create_space(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseCreateSpace._get_transcoded_request( @@ -1462,6 +1734,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.chat_v1.ChatServiceClient.CreateSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._CreateSpace._get_response( self._host, @@ -1483,7 +1782,29 @@ def __call__( pb_resp = gc_space.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_space.Space.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.chat_v1.ChatServiceClient.create_space", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "CreateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteMembership( @@ -1520,7 +1841,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]]] = (), ) -> membership.Membership: r"""Call the delete membership method over HTTP. @@ -1531,8 +1852,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: ~.membership.Membership: @@ -1546,6 +1869,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseDeleteMembership._get_http_options() ) + request, metadata = self._interceptor.pre_delete_membership( request, metadata ) @@ -1558,6 +1882,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 = 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.chat_v1.ChatServiceClient.DeleteMembership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "DeleteMembership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._DeleteMembership._get_response( self._host, @@ -1578,7 +1929,29 @@ def __call__( pb_resp = membership.Membership.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_membership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = membership.Membership.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.chat_v1.ChatServiceClient.delete_membership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "DeleteMembership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteMessage( @@ -1615,7 +1988,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 message method over HTTP. @@ -1625,13 +1998,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 = ( _BaseChatServiceRestTransport._BaseDeleteMessage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_message(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseDeleteMessage._get_transcoded_request( http_options, request @@ -1644,6 +2020,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.chat_v1.ChatServiceClient.DeleteMessage", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "DeleteMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._DeleteMessage._get_response( self._host, @@ -1693,7 +2096,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 reaction method over HTTP. @@ -1703,13 +2106,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 = ( _BaseChatServiceRestTransport._BaseDeleteReaction._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reaction(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseDeleteReaction._get_transcoded_request( http_options, request @@ -1720,6 +2126,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.chat_v1.ChatServiceClient.DeleteReaction", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "DeleteReaction", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._DeleteReaction._get_response( self._host, @@ -1769,7 +2202,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 space method over HTTP. @@ -1779,13 +2212,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 = ( _BaseChatServiceRestTransport._BaseDeleteSpace._get_http_options() ) + request, metadata = self._interceptor.pre_delete_space(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseDeleteSpace._get_transcoded_request( @@ -1800,6 +2236,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.chat_v1.ChatServiceClient.DeleteSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "DeleteSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._DeleteSpace._get_response( self._host, @@ -1849,7 +2312,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]]] = (), ) -> space.Space: r"""Call the find direct message method over HTTP. @@ -1860,8 +2323,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: ~.space.Space: @@ -1875,6 +2340,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseFindDirectMessage._get_http_options() ) + request, metadata = self._interceptor.pre_find_direct_message( request, metadata ) @@ -1887,6 +2353,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 = 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.chat_v1.ChatServiceClient.FindDirectMessage", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "FindDirectMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._FindDirectMessage._get_response( self._host, @@ -1907,7 +2400,29 @@ def __call__( pb_resp = space.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_find_direct_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.Space.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.chat_v1.ChatServiceClient.find_direct_message", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "FindDirectMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttachment( @@ -1944,7 +2459,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]]] = (), ) -> attachment.Attachment: r"""Call the get attachment method over HTTP. @@ -1954,8 +2469,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: ~.attachment.Attachment: @@ -1965,6 +2482,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_get_attachment(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseGetAttachment._get_transcoded_request( http_options, request @@ -1977,6 +2495,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.chat_v1.ChatServiceClient.GetAttachment", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetAttachment._get_response( self._host, @@ -1997,7 +2542,29 @@ def __call__( pb_resp = attachment.Attachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = attachment.Attachment.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.chat_v1.ChatServiceClient.get_attachment", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMembership( @@ -2034,7 +2601,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]]] = (), ) -> membership.Membership: r"""Call the get membership method over HTTP. @@ -2045,8 +2612,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: ~.membership.Membership: @@ -2060,6 +2629,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetMembership._get_http_options() ) + request, metadata = self._interceptor.pre_get_membership(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseGetMembership._get_transcoded_request( http_options, request @@ -2072,6 +2642,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.chat_v1.ChatServiceClient.GetMembership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetMembership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetMembership._get_response( self._host, @@ -2092,7 +2689,29 @@ def __call__( pb_resp = membership.Membership.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_membership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = membership.Membership.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.chat_v1.ChatServiceClient.get_membership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetMembership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMessage( @@ -2129,7 +2748,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]]] = (), ) -> message.Message: r"""Call the get message method over HTTP. @@ -2139,8 +2758,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: ~.message.Message: @@ -2150,6 +2771,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetMessage._get_http_options() ) + request, metadata = self._interceptor.pre_get_message(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseGetMessage._get_transcoded_request( @@ -2164,6 +2786,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.chat_v1.ChatServiceClient.GetMessage", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetMessage._get_response( self._host, @@ -2184,7 +2833,29 @@ def __call__( pb_resp = message.Message.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = message.Message.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.chat_v1.ChatServiceClient.get_message", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSpace(_BaseChatServiceRestTransport._BaseGetSpace, ChatServiceRestStub): @@ -2219,7 +2890,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]]] = (), ) -> space.Space: r"""Call the get space method over HTTP. @@ -2229,8 +2900,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: ~.space.Space: @@ -2244,6 +2917,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetSpace._get_http_options() ) + request, metadata = self._interceptor.pre_get_space(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseGetSpace._get_transcoded_request( @@ -2258,6 +2932,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.chat_v1.ChatServiceClient.GetSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetSpace._get_response( self._host, @@ -2278,7 +2979,29 @@ def __call__( pb_resp = space.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.Space.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.chat_v1.ChatServiceClient.get_space", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSpaceEvent( @@ -2315,7 +3038,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]]] = (), ) -> space_event.SpaceEvent: r"""Call the get space event method over HTTP. @@ -2326,8 +3049,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: ~.space_event.SpaceEvent: @@ -2341,6 +3066,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetSpaceEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_space_event(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseGetSpaceEvent._get_transcoded_request( http_options, request @@ -2353,6 +3079,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.chat_v1.ChatServiceClient.GetSpaceEvent", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpaceEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetSpaceEvent._get_response( self._host, @@ -2373,7 +3126,29 @@ def __call__( pb_resp = space_event.SpaceEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_space_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space_event.SpaceEvent.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.chat_v1.ChatServiceClient.get_space_event", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpaceEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSpaceReadState( @@ -2410,7 +3185,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]]] = (), ) -> space_read_state.SpaceReadState: r"""Call the get space read state method over HTTP. @@ -2421,8 +3196,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: ~.space_read_state.SpaceReadState: @@ -2435,6 +3212,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetSpaceReadState._get_http_options() ) + request, metadata = self._interceptor.pre_get_space_read_state( request, metadata ) @@ -2447,6 +3225,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 = 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.chat_v1.ChatServiceClient.GetSpaceReadState", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpaceReadState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetSpaceReadState._get_response( self._host, @@ -2467,7 +3272,29 @@ def __call__( pb_resp = space_read_state.SpaceReadState.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_space_read_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space_read_state.SpaceReadState.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.chat_v1.ChatServiceClient.get_space_read_state", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetSpaceReadState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetThreadReadState( @@ -2504,7 +3331,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]]] = (), ) -> thread_read_state.ThreadReadState: r"""Call the get thread read state method over HTTP. @@ -2515,8 +3342,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: ~.thread_read_state.ThreadReadState: @@ -2529,6 +3358,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseGetThreadReadState._get_http_options() ) + request, metadata = self._interceptor.pre_get_thread_read_state( request, metadata ) @@ -2541,6 +3371,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 = 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.chat_v1.ChatServiceClient.GetThreadReadState", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetThreadReadState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._GetThreadReadState._get_response( self._host, @@ -2561,7 +3418,31 @@ def __call__( pb_resp = thread_read_state.ThreadReadState.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_thread_read_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = thread_read_state.ThreadReadState.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.chat_v1.ChatServiceClient.get_thread_read_state", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "GetThreadReadState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMemberships( @@ -2598,7 +3479,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]]] = (), ) -> membership.ListMembershipsResponse: r"""Call the list memberships method over HTTP. @@ -2609,8 +3490,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: ~.membership.ListMembershipsResponse: @@ -2622,6 +3505,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseListMemberships._get_http_options() ) + request, metadata = self._interceptor.pre_list_memberships( request, metadata ) @@ -2634,6 +3518,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 = 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.chat_v1.ChatServiceClient.ListMemberships", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListMemberships", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._ListMemberships._get_response( self._host, @@ -2654,7 +3565,31 @@ def __call__( pb_resp = membership.ListMembershipsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_memberships(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = membership.ListMembershipsResponse.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.chat_v1.ChatServiceClient.list_memberships", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListMemberships", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMessages( @@ -2691,7 +3626,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]]] = (), ) -> message.ListMessagesResponse: r"""Call the list messages method over HTTP. @@ -2702,8 +3637,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: ~.message.ListMessagesResponse: @@ -2715,6 +3652,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseListMessages._get_http_options() ) + request, metadata = self._interceptor.pre_list_messages(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseListMessages._get_transcoded_request( @@ -2729,6 +3667,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.chat_v1.ChatServiceClient.ListMessages", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListMessages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._ListMessages._get_response( self._host, @@ -2749,7 +3714,29 @@ def __call__( pb_resp = message.ListMessagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_messages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = message.ListMessagesResponse.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.chat_v1.ChatServiceClient.list_messages", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListMessages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReactions( @@ -2786,7 +3773,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]]] = (), ) -> reaction.ListReactionsResponse: r"""Call the list reactions method over HTTP. @@ -2796,8 +3783,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: ~.reaction.ListReactionsResponse: @@ -2807,6 +3796,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseListReactions._get_http_options() ) + request, metadata = self._interceptor.pre_list_reactions(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseListReactions._get_transcoded_request( http_options, request @@ -2819,6 +3809,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.chat_v1.ChatServiceClient.ListReactions", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListReactions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._ListReactions._get_response( self._host, @@ -2839,7 +3856,29 @@ def __call__( pb_resp = reaction.ListReactionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reactions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reaction.ListReactionsResponse.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.chat_v1.ChatServiceClient.list_reactions", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListReactions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSpaceEvents( @@ -2876,7 +3915,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]]] = (), ) -> space_event.ListSpaceEventsResponse: r"""Call the list space events method over HTTP. @@ -2887,8 +3926,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: ~.space_event.ListSpaceEventsResponse: @@ -2900,6 +3941,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseListSpaceEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_space_events( request, metadata ) @@ -2912,6 +3954,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 = 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.chat_v1.ChatServiceClient.ListSpaceEvents", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListSpaceEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._ListSpaceEvents._get_response( self._host, @@ -2932,7 +4001,31 @@ def __call__( pb_resp = space_event.ListSpaceEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_space_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space_event.ListSpaceEventsResponse.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.chat_v1.ChatServiceClient.list_space_events", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListSpaceEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSpaces( @@ -2969,7 +4062,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]]] = (), ) -> space.ListSpacesResponse: r"""Call the list spaces method over HTTP. @@ -2980,8 +4073,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: ~.space.ListSpacesResponse: @@ -2993,6 +4088,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseListSpaces._get_http_options() ) + request, metadata = self._interceptor.pre_list_spaces(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseListSpaces._get_transcoded_request( @@ -3007,6 +4103,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.chat_v1.ChatServiceClient.ListSpaces", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListSpaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._ListSpaces._get_response( self._host, @@ -3027,7 +4150,29 @@ def __call__( pb_resp = space.ListSpacesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_spaces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.ListSpacesResponse.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.chat_v1.ChatServiceClient.list_spaces", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "ListSpaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchSpaces( @@ -3064,7 +4209,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]]] = (), ) -> space.SearchSpacesResponse: r"""Call the search spaces method over HTTP. @@ -3075,8 +4220,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: ~.space.SearchSpacesResponse: @@ -3089,6 +4236,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseSearchSpaces._get_http_options() ) + request, metadata = self._interceptor.pre_search_spaces(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseSearchSpaces._get_transcoded_request( @@ -3103,6 +4251,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.chat_v1.ChatServiceClient.SearchSpaces", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "SearchSpaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._SearchSpaces._get_response( self._host, @@ -3123,7 +4298,29 @@ def __call__( pb_resp = space.SearchSpacesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_spaces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.SearchSpacesResponse.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.chat_v1.ChatServiceClient.search_spaces", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "SearchSpaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetUpSpace( @@ -3161,7 +4358,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]]] = (), ) -> space.Space: r"""Call the set up space method over HTTP. @@ -3172,8 +4369,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: ~.space.Space: @@ -3187,6 +4386,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseSetUpSpace._get_http_options() ) + request, metadata = self._interceptor.pre_set_up_space(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseSetUpSpace._get_transcoded_request( @@ -3205,6 +4405,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.chat_v1.ChatServiceClient.SetUpSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "SetUpSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._SetUpSpace._get_response( self._host, @@ -3226,7 +4453,29 @@ def __call__( pb_resp = space.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_up_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = space.Space.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.chat_v1.ChatServiceClient.set_up_space", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "SetUpSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMembership( @@ -3264,7 +4513,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]]] = (), ) -> gc_membership.Membership: r"""Call the update membership method over HTTP. @@ -3275,8 +4524,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: ~.gc_membership.Membership: @@ -3290,6 +4541,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseUpdateMembership._get_http_options() ) + request, metadata = self._interceptor.pre_update_membership( request, metadata ) @@ -3306,6 +4558,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 = 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.chat_v1.ChatServiceClient.UpdateMembership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateMembership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._UpdateMembership._get_response( self._host, @@ -3327,7 +4606,29 @@ def __call__( pb_resp = gc_membership.Membership.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_membership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_membership.Membership.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.chat_v1.ChatServiceClient.update_membership", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateMembership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMessage( @@ -3365,7 +4666,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]]] = (), ) -> gc_message.Message: r"""Call the update message method over HTTP. @@ -3375,8 +4676,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: ~.gc_message.Message: @@ -3386,6 +4689,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseUpdateMessage._get_http_options() ) + request, metadata = self._interceptor.pre_update_message(request, metadata) transcoded_request = _BaseChatServiceRestTransport._BaseUpdateMessage._get_transcoded_request( http_options, request @@ -3404,6 +4708,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.chat_v1.ChatServiceClient.UpdateMessage", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._UpdateMessage._get_response( self._host, @@ -3425,7 +4756,29 @@ def __call__( pb_resp = gc_message.Message.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_message.Message.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.chat_v1.ChatServiceClient.update_message", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSpace( @@ -3463,7 +4816,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]]] = (), ) -> gc_space.Space: r"""Call the update space method over HTTP. @@ -3473,8 +4826,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: ~.gc_space.Space: @@ -3488,6 +4843,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseUpdateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_update_space(request, metadata) transcoded_request = ( _BaseChatServiceRestTransport._BaseUpdateSpace._get_transcoded_request( @@ -3508,6 +4864,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.chat_v1.ChatServiceClient.UpdateSpace", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._UpdateSpace._get_response( self._host, @@ -3529,7 +4912,29 @@ def __call__( pb_resp = gc_space.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_space.Space.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.chat_v1.ChatServiceClient.update_space", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSpaceReadState( @@ -3567,7 +4972,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]]] = (), ) -> gc_space_read_state.SpaceReadState: r"""Call the update space read state method over HTTP. @@ -3578,8 +4983,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: ~.gc_space_read_state.SpaceReadState: @@ -3592,6 +4999,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseUpdateSpaceReadState._get_http_options() ) + request, metadata = self._interceptor.pre_update_space_read_state( request, metadata ) @@ -3608,6 +5016,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 = 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.chat_v1.ChatServiceClient.UpdateSpaceReadState", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateSpaceReadState", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._UpdateSpaceReadState._get_response( self._host, @@ -3629,7 +5064,31 @@ def __call__( pb_resp = gc_space_read_state.SpaceReadState.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_space_read_state(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gc_space_read_state.SpaceReadState.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.chat_v1.ChatServiceClient.update_space_read_state", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UpdateSpaceReadState", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UploadAttachment( @@ -3667,7 +5126,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]]] = (), ) -> attachment.UploadAttachmentResponse: r"""Call the upload attachment method over HTTP. @@ -3677,8 +5136,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: ~.attachment.UploadAttachmentResponse: @@ -3688,6 +5149,7 @@ def __call__( http_options = ( _BaseChatServiceRestTransport._BaseUploadAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_upload_attachment( request, metadata ) @@ -3704,6 +5166,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 = 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.chat_v1.ChatServiceClient.UploadAttachment", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UploadAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ChatServiceRestTransport._UploadAttachment._get_response( self._host, @@ -3725,7 +5214,31 @@ def __call__( pb_resp = attachment.UploadAttachmentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upload_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = attachment.UploadAttachmentResponse.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.chat_v1.ChatServiceClient.upload_attachment", + extra={ + "serviceName": "google.chat.v1.ChatService", + "rpcName": "UploadAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest_base.py b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest_base.py index 116f6c2b56d6..a0bd2de186d5 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest_base.py +++ b/packages/google-apps-chat/google/apps/chat_v1/services/chat_service/transports/rest_base.py @@ -1342,7 +1342,9 @@ class _BaseUpdateMessage: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1404,7 +1406,9 @@ class _BaseUpdateSpace: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/attachment.py b/packages/google-apps-chat/google/apps/chat_v1/types/attachment.py index c9b2ca2855aa..07c0357606b2 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/attachment.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/attachment.py @@ -44,7 +44,7 @@ class Attachment(proto.Message): Attributes: name (str): - Resource name of the attachment, in the form + Optional. Resource name of the attachment, in the form ``spaces/{space}/messages/{message}/attachments/{attachment}``. content_name (str): Output only. The original file name for the @@ -53,9 +53,10 @@ class Attachment(proto.Message): Output only. The content type (MIME type) of the file. attachment_data_ref (google.apps.chat_v1.types.AttachmentDataRef): - A reference to the attachment data. This - field is used with the media API to download the - attachment data. + Optional. A reference to the attachment data. + This field is used to create or update messages + with attachments, or with the media API to + download the attachment data. This field is a member of `oneof`_ ``data_ref``. drive_data_ref (google.apps.chat_v1.types.DriveDataRef): @@ -152,14 +153,14 @@ class AttachmentDataRef(proto.Message): Attributes: resource_name (str): - The resource name of the attachment data. - This field is used with the media API to + Optional. The resource name of the attachment + data. This field is used with the media API to download the attachment data. attachment_upload_token (str): - Opaque token containing a reference to an - uploaded attachment. Treated by clients as an - opaque string and used to create or update Chat - messages with attachments. + Optional. Opaque token containing a reference + to an uploaded attachment. Treated by clients as + an opaque string and used to create or update + Chat messages with attachments. """ resource_name: str = proto.Field( diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/deletion_metadata.py b/packages/google-apps-chat/google/apps/chat_v1/types/deletion_metadata.py index 1d0204db4006..f32cc4aa3c1a 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/deletion_metadata.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/deletion_metadata.py @@ -37,7 +37,8 @@ class DeletionMetadata(proto.Message): """ class DeletionType(proto.Enum): - r"""Who deleted the message and how it was deleted. + r"""Who deleted the message and how it was deleted. More values + may be added in the future. Values: DELETION_TYPE_UNSPECIFIED (0): diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/membership.py b/packages/google-apps-chat/google/apps/chat_v1/types/membership.py index f0e00c470930..2cefcdffaccc 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/membership.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/membership.py @@ -51,7 +51,8 @@ class Membership(proto.Message): Attributes: name (str): - Resource name of the membership, assigned by the server. + Identifier. Resource name of the membership, assigned by the + server. Format: ``spaces/{space}/members/{member}`` state (google.apps.chat_v1.types.Membership.MembershipState): @@ -63,8 +64,8 @@ class Membership(proto.Message): This field can only be used as input in ``UpdateMembership``. member (google.apps.chat_v1.types.User): - The Google Chat user or app the membership corresponds to. - If your Chat app `authenticates as a + Optional. The Google Chat user or app the membership + corresponds to. If your Chat app `authenticates as a user `__, the output populates the `user `__ @@ -72,8 +73,11 @@ class Membership(proto.Message): This field is a member of `oneof`_ ``memberType``. group_member (google.apps.chat_v1.types.Group): - The Google Group the membership corresponds - to. + Optional. The Google Group the membership corresponds to. + + Reading or mutating memberships for Google Groups requires + `user + authentication `__. This field is a member of `oneof`_ ``memberType``. create_time (google.protobuf.timestamp_pb2.Timestamp): @@ -188,29 +192,54 @@ class CreateMembershipRequest(proto.Message): Format: spaces/{space} membership (google.apps.chat_v1.types.Membership): - Required. The membership relation to create. The - ``memberType`` field must contain a user with the + Required. The membership relation to create. + + The ``memberType`` field must contain a user with the ``user.name`` and ``user.type`` fields populated. The server will assign a resource name and overwrite anything - specified. When a Chat app creates a membership relation for - a human user, it must use the ``chat.memberships`` scope, - set ``user.type`` to ``HUMAN``, and set ``user.name`` with - format ``users/{user}``, where ``{user}`` can be the email - address for the user. For users in the same Workspace - organization ``{user}`` can also be the ``id`` of the - `person `__ - from the People API, or the ``id`` for the user in the - Directory API. For example, if the People API Person profile - ID for ``user@example.com`` is ``123456789``, you can add - the user to the space by setting the - ``membership.member.name`` to ``users/user@example.com`` or - ``users/123456789``. When a Chat app creates a membership - relation for itself, it must use the - ``chat.memberships.app`` scope, set ``user.type`` to - ``BOT``, and set ``user.name`` to ``users/app``. + specified. + + When a Chat app creates a membership relation for a human + user, it must use certain authorization scopes and set + specific values for certain fields: + + - When `authenticating as a + user `__, + the ``chat.memberships`` authorization scope is required. + + - When `authenticating as an + app `__, + the ``chat.app.memberships`` authorization scope is + required. Authenticating as an app is available in + `Developer + Preview `__. + + - Set ``user.type`` to ``HUMAN``, and set ``user.name`` + with format ``users/{user}``, where ``{user}`` can be the + email address for the user. For users in the same + Workspace organization ``{user}`` can also be the ``id`` + of the + `person `__ + from the People API, or the ``id`` for the user in the + Directory API. For example, if the People API Person + profile ID for ``user@example.com`` is ``123456789``, you + can add the user to the space by setting the + ``membership.member.name`` to ``users/user@example.com`` + or ``users/123456789``. + + Inviting users external to the Workspace organization that + owns the space requires `user + authentication `__. + + When a Chat app creates a membership relation for itself, it + must `authenticate as a + user `__ + and use the ``chat.memberships.app`` scope, set + ``user.type`` to ``BOT``, and set ``user.name`` to + ``users/app``. use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -254,8 +283,8 @@ class UpdateMembershipRequest(proto.Message): - ``role`` use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -371,8 +400,8 @@ class ListMembershipsRequest(proto.Message): Currently requires `user authentication `__. use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -458,15 +487,13 @@ class GetMembershipRequest(proto.Message): Format: ``spaces/{space}/members/{member}`` or ``spaces/{space}/members/app`` - When `authenticated as a - user `__, - you can use the user's email as an alias for ``{member}``. + You can use the user's email as an alias for ``{member}``. For example, ``spaces/{space}/members/example@gmail.com`` where ``example@gmail.com`` is the email of the Google Chat user. use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -513,8 +540,8 @@ class DeleteMembershipRequest(proto.Message): Format: ``spaces/{space}/members/{member}`` or ``spaces/{space}/members/app``. use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/message.py b/packages/google-apps-chat/google/apps/chat_v1/types/message.py index 56d10d7b3574..612a374dff16 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/message.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/message.py @@ -60,7 +60,7 @@ class Message(proto.Message): Attributes: name (str): - Resource name of the message. + Identifier. Resource name of the message. Format: ``spaces/{space}/messages/{message}`` @@ -102,8 +102,8 @@ class Message(proto.Message): was deleted in Google Chat. If the message is never deleted, this field is empty. text (str): - Plain-text body of the message. The first link to an image, - video, or web page generates a `preview + Optional. Plain-text body of the message. The first link to + an image, video, or web page generates a `preview chip `__. You can also `@mention a Google Chat user `__, @@ -146,7 +146,7 @@ class Message(proto.Message): plain-text body of the message. ``cards`` and ``cards_v2`` can have a maximum size of 32 KB. cards_v2 (MutableSequence[google.apps.chat_v1.types.CardWithId]): - An array of + Optional. An array of `cards `__. Only Chat apps can create cards. If your Chat app @@ -168,15 +168,16 @@ class Message(proto.Message): `Start or reply to a message thread `__. space (google.apps.chat_v1.types.Space): - If your Chat app `authenticates as a + Output only. If your Chat app `authenticates as a user `__, - the output populates the + the output only populates the `space `__ ``name``. fallback_text (str): - A plain-text description of the message's - cards, used when the actual cards can't be - displayed—for example, mobile notifications. + Optional. A plain-text description of the + message's cards, used when the actual cards + can't be displayed—for example, mobile + notifications. action_response (google.apps.chat_v1.types.ActionResponse): Input only. Parameters that a Chat app can use to configure how its response is posted. @@ -187,7 +188,7 @@ class Message(proto.Message): Output only. Slash command information, if applicable. attachment (MutableSequence[google.apps.chat_v1.types.Attachment]): - User-uploaded attachment. + Optional. User-uploaded attachment. matched_url (google.apps.chat_v1.types.MatchedUrl): Output only. A URL in ``spaces.messages.text`` that matches a link preview pattern. For more information, see `Preview @@ -211,11 +212,11 @@ class Message(proto.Message): Output only. The list of emoji reaction summaries on the message. private_message_viewer (google.apps.chat_v1.types.User): - Immutable. Input for creating a message, otherwise output - only. The user that can view the message. When set, the - message is private and only visible to the specified user - and the Chat app. To include this field in your request, you - must call the Chat API using `app + Optional. Immutable. Input for creating a message, otherwise + output only. The user that can view the message. When set, + the message is private and only visible to the specified + user and the Chat app. To include this field in your + request, you must call the Chat API using `app authentication `__ and omit the following: @@ -237,11 +238,11 @@ class Message(proto.Message): Output only. GIF images that are attached to the message. accessory_widgets (MutableSequence[google.apps.chat_v1.types.AccessoryWidget]): - One or more interactive widgets that appear at the bottom of - a message. You can add accessory widgets to messages that - contain text, cards, or both text and cards. Not supported - for messages that contain dialogs. For details, see `Add - interactive widgets at the bottom of a + Optional. One or more interactive widgets that appear at the + bottom of a message. You can add accessory widgets to + messages that contain text, cards, or both text and cards. + Not supported for messages that contain dialogs. For + details, see `Add interactive widgets at the bottom of a message `__. Creating a message with accessory widgets requires [app @@ -429,7 +430,7 @@ class Thread(proto.Message): Attributes: name (str): - Resource name of the thread. + Identifier. Resource name of the thread. Example: ``spaces/{space}/threads/{thread}`` thread_key (str): @@ -524,8 +525,8 @@ class SelectionItems(proto.Message): ) class UpdatedWidget(proto.Message): - r"""The response of the updated widget. - Used to provide autocomplete options for a widget. + r"""For ``selectionInput`` widgets, returns autocomplete suggestions for + a multiselect menu. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields @@ -632,9 +633,9 @@ class DeleteMessageRequest(proto.Message): ``{message}``. For details, see [Name a message] (https://developers.google.com/workspace/chat/create-messages#name_a_created_message). force (bool): - When ``true``, deleting a message also deletes its threaded - replies. When ``false``, if a message has threaded replies, - deletion fails. + Optional. When ``true``, deleting a message also deletes its + threaded replies. When ``false``, if a message has threaded + replies, deletion fails. Only applies when `authenticating as a user `__. @@ -726,9 +727,14 @@ class CreateMessageRequest(proto.Message): returns the message created with that ID instead of creating a new message. message_reply_option (google.apps.chat_v1.types.CreateMessageRequest.MessageReplyOption): - Optional. Specifies whether a message starts - a thread or replies to one. Only supported in - named spaces. + Optional. Specifies whether a message starts a thread or + replies to one. Only supported in named spaces. + + When `responding to user + interactions `__, + this field is ignored. For interactions within a thread, the + reply is created in the same thread. Otherwise, the reply is + created as a new thread. message_id (str): Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the @@ -816,8 +822,8 @@ class ListMessagesRequest(proto.Message): Format: ``spaces/{space}`` page_size (int): - The maximum number of messages returned. The service might - return fewer messages than this value. + Optional. The maximum number of messages returned. The + service might return fewer messages than this value. If unspecified, at most 25 are returned. @@ -826,18 +832,16 @@ class ListMessagesRequest(proto.Message): Negative values return an ``INVALID_ARGUMENT`` error. page_token (str): - Optional, if resuming from a previous query. - - A page token received from a previous list - messages call. Provide this parameter to - retrieve the subsequent page. + Optional. A page token received from a + previous list messages call. Provide this + parameter to retrieve the subsequent page. When paginating, all other parameters provided should match the call that provided the page token. Passing different values to the other parameters might lead to unexpected results. filter (str): - A query filter. + Optional. A query filter. You can filter messages by date (``create_time``) and thread (``thread.name``). @@ -879,11 +883,9 @@ class ListMessagesRequest(proto.Message): Invalid queries are rejected by the server with an ``INVALID_ARGUMENT`` error. order_by (str): - Optional, if resuming from a previous query. - - How the list of messages is ordered. Specify a value to - order by an ordering operation. Valid ordering operation - values are as follows: + Optional. How the list of messages is ordered. Specify a + value to order by an ordering operation. Valid ordering + operation values are as follows: - ``ASC`` for ascending. @@ -891,10 +893,10 @@ class ListMessagesRequest(proto.Message): The default ordering is ``create_time ASC``. show_deleted (bool): - Whether to include deleted messages. Deleted - messages include deleted time and metadata about - their deletion, but message content is - unavailable. + Optional. Whether to include deleted + messages. Deleted messages include deleted time + and metadata about their deletion, but message + content is unavailable. """ parent: str = proto.Field( diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/reaction.py b/packages/google-apps-chat/google/apps/chat_v1/types/reaction.py index c64f3d2ef5b3..9b2d3c05c5e0 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/reaction.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/reaction.py @@ -41,7 +41,7 @@ class Reaction(proto.Message): Attributes: name (str): - The resource name of the reaction. + Identifier. The resource name of the reaction. Format: ``spaces/{space}/messages/{message}/reactions/{reaction}`` @@ -49,7 +49,7 @@ class Reaction(proto.Message): Output only. The user who created the reaction. emoji (google.apps.chat_v1.types.Emoji): - The emoji used in the reaction. + Required. The emoji used in the reaction. """ name: str = proto.Field( @@ -80,8 +80,8 @@ class Emoji(proto.Message): Attributes: unicode (str): - A basic emoji represented by a unicode - string. + Optional. A basic emoji represented by a + unicode string. This field is a member of `oneof`_ ``content``. custom_emoji (google.apps.chat_v1.types.CustomEmoji): @@ -127,10 +127,11 @@ class EmojiReactionSummary(proto.Message): Attributes: emoji (google.apps.chat_v1.types.Emoji): - Emoji associated with the reactions. + Output only. Emoji associated with the + reactions. reaction_count (int): - The total number of reactions using the - associated emoji. + Output only. The total number of reactions + using the associated emoji. This field is a member of `oneof`_ ``_reaction_count``. """ diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/space.py b/packages/google-apps-chat/google/apps/chat_v1/types/space.py index 694375fc0ebd..d676ebfbe2ad 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/space.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/space.py @@ -55,7 +55,7 @@ class Space(proto.Message): Attributes: name (str): - Resource name of the space. + Identifier. Resource name of the space. Format: ``spaces/{space}`` @@ -70,9 +70,9 @@ class Space(proto.Message): Output only. Deprecated: Use ``space_type`` instead. The type of a space. space_type (google.apps.chat_v1.types.Space.SpaceType): - The type of space. Required when creating a - space or updating the space type of a space. - Output only for other usage. + Optional. The type of space. Required when + creating a space or updating the space type of a + space. Output only for other usage. single_user_bot_dm (bool): Optional. Whether the space is a DM between a Chat app and a single human. @@ -80,7 +80,8 @@ class Space(proto.Message): Output only. Deprecated: Use ``spaceThreadingState`` instead. Whether messages are threaded in this space. display_name (str): - The space's display name. Required when `creating a + Optional. The space's display name. Required when `creating + a space `__ with a ``spaceType`` of ``SPACE``. If you receive the error message ``ALREADY_EXISTS`` when creating a space or updating @@ -92,10 +93,10 @@ class Space(proto.Message): Supports up to 128 characters. external_user_allowed (bool): - Immutable. Whether this space permits any Google Chat user - as a member. Input when creating a space in a Google - Workspace organization. Omit this field when creating spaces - in the following conditions: + Optional. Immutable. Whether this space permits any Google + Chat user as a member. Input when creating a space in a + Google Workspace organization. Omit this field when creating + spaces in the following conditions: - The authenticated user uses a consumer account (unmanaged user account). By default, a space created by a consumer @@ -106,16 +107,19 @@ class Space(proto.Message): Output only. The threading state in the Chat space. space_details (google.apps.chat_v1.types.Space.SpaceDetails): - Details about the space including description - and rules. + Optional. Details about the space including + description and rules. space_history_state (google.apps.chat_v1.types.HistoryState): - The message history state for messages and - threads in this space. + Optional. The message history state for + messages and threads in this space. import_mode (bool): Optional. Whether this space is created in ``Import Mode`` as part of a data migration into Google Workspace. While spaces are being imported, they aren't visible to users until the import is complete. + + Creating a space in ``Import Mode``\ requires `user + authentication `__. create_time (google.protobuf.timestamp_pb2.Timestamp): Optional. Immutable. For spaces created in Chat, the time the space was created. This field is output only, except @@ -167,6 +171,15 @@ class Space(proto.Message): permission settings. This field is a member of `oneof`_ ``space_permission_settings``. + import_mode_expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the space will be automatically + deleted by the system if it remains in import mode. + + Each space created in import mode must exit this mode before + this expire time using ``spaces.completeImport``. + + This field is only populated for spaces that were created + with import mode. """ class Type(proto.Enum): @@ -285,12 +298,12 @@ class MembershipCount(proto.Message): Attributes: joined_direct_human_user_count (int): - Count of human users that have directly - joined the space, not counting users joined by - having membership in a joined group. + Output only. Count of human users that have + directly joined the space, not counting users + joined by having membership in a joined group. joined_group_count (int): - Count of all groups that have directly joined - the space. + Output only. Count of all groups that have + directly joined the space. """ joined_direct_human_user_count: int = proto.Field( @@ -326,9 +339,24 @@ class AccessSettings(proto.Message): To use the default target audience for the Google Workspace organization, set to ``audiences/default``. + Reading the target audience supports: + + - `User + authentication `__ + + - `App + authentication `__ + with `administrator + approval `__ + with the ``chat.app.spaces`` scope in `Developer + Preview `__. + This field is not populated when using the ``chat.bot`` scope with `app authentication `__. + + Setting the target audience requires `user + authentication `__. """ class AccessState(proto.Enum): @@ -350,6 +378,9 @@ class AccessState(proto.Enum): the space. To learn more, see `Make a space discoverable to specific users `__. + + Creating discoverable spaces requires `user + authentication `__. """ ACCESS_STATE_UNSPECIFIED = 0 PRIVATE = 1 @@ -378,30 +409,32 @@ class PermissionSettings(proto.Message): Attributes: manage_members_and_groups (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for managing members and groups in a - space. + Optional. Setting for managing members and + groups in a space. This field is a member of `oneof`_ ``_manage_members_and_groups``. modify_space_details (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for updating space name, avatar, - description and guidelines. + Optional. Setting for updating space name, + avatar, description and guidelines. This field is a member of `oneof`_ ``_modify_space_details``. toggle_history (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for toggling space history on and - off. + Optional. Setting for toggling space history + on and off. This field is a member of `oneof`_ ``_toggle_history``. use_at_mention_all (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for using @all in a space. + Optional. Setting for using @all in a space. This field is a member of `oneof`_ ``_use_at_mention_all``. manage_apps (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for managing apps in a space. + Optional. Setting for managing apps in a + space. This field is a member of `oneof`_ ``_manage_apps``. manage_webhooks (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for managing webhooks in a space. + Optional. Setting for managing webhooks in a + space. This field is a member of `oneof`_ ``_manage_webhooks``. post_messages (google.apps.chat_v1.types.Space.PermissionSetting): @@ -410,7 +443,8 @@ class PermissionSettings(proto.Message): This field is a member of `oneof`_ ``_post_messages``. reply_messages (google.apps.chat_v1.types.Space.PermissionSetting): - Setting for replying to messages in a space. + Optional. Setting for replying to messages in + a space. This field is a member of `oneof`_ ``_reply_messages``. """ @@ -469,10 +503,11 @@ class PermissionSetting(proto.Message): Attributes: managers_allowed (bool): - Whether spaces managers have this permission. - members_allowed (bool): - Whether non-manager members have this + Optional. Whether spaces managers have this permission. + members_allowed (bool): + Optional. Whether non-manager members have + this permission. """ managers_allowed: bool = proto.Field( @@ -573,6 +608,11 @@ class PermissionSetting(proto.Message): oneof="space_permission_settings", message=PermissionSettings, ) + import_mode_expire_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=28, + message=timestamp_pb2.Timestamp, + ) class CreateSpaceRequest(proto.Message): @@ -581,18 +621,16 @@ class CreateSpaceRequest(proto.Message): Attributes: space (google.apps.chat_v1.types.Space): Required. The ``displayName`` and ``spaceType`` fields must - be populated. Only ``SpaceType.SPACE`` is supported. + be populated. Only ``SpaceType.SPACE`` and + ``SpaceType.GROUP_CHAT`` are supported. + ``SpaceType.GROUP_CHAT`` can only be used if ``importMode`` + is set to true. If you receive the error message ``ALREADY_EXISTS``, try a different ``displayName``. An existing space within the Google Workspace organization might already use this display name. - If you're a member of the `Developer Preview - program `__, - ``SpaceType.GROUP_CHAT`` can be used if ``importMode`` is - set to true. - The space ``name`` is assigned on the server so anything specified in this field will be ignored. request_id (str): @@ -713,8 +751,8 @@ class GetSpaceRequest(proto.Message): Format: ``spaces/{space}`` use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -841,8 +879,8 @@ class UpdateSpaceRequest(proto.Message): - ``permission_settings.manageWebhooks`` - ``permission_settings.replyMessages`` use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations @@ -1079,8 +1117,8 @@ class DeleteSpaceRequest(proto.Message): Format: ``spaces/{space}`` use_admin_access (bool): - When ``true``, the method runs using the user's Google - Workspace administrator privileges. + Optional. When ``true``, the method runs using the user's + Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the `manage chat and spaces conversations diff --git a/packages/google-apps-chat/google/apps/chat_v1/types/space_event.py b/packages/google-apps-chat/google/apps/chat_v1/types/space_event.py index 17bf07ba27d7..6c6fcfb052ad 100644 --- a/packages/google-apps-chat/google/apps/chat_v1/types/space_event.py +++ b/packages/google-apps-chat/google/apps/chat_v1/types/space_event.py @@ -399,9 +399,9 @@ class ListSpaceEventsRequest(proto.Message): Negative values return an ``INVALID_ARGUMENT`` error. page_token (str): - A page token, received from a previous list - space events call. Provide this to retrieve the - subsequent page. + Optional. A page token, received from a + previous list space events call. Provide this to + retrieve the subsequent page. When paginating, all other parameters provided to list space events must match the call that diff --git a/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_async.py b/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_async.py index 11207c61d5a5..6ffc85b4496b 100644 --- a/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_async.py +++ b/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_async.py @@ -39,8 +39,12 @@ async def sample_create_reaction(): client = chat_v1.ChatServiceAsyncClient() # Initialize request argument(s) + reaction = chat_v1.Reaction() + reaction.emoji.unicode = "unicode_value" + request = chat_v1.CreateReactionRequest( parent="parent_value", + reaction=reaction, ) # Make the request diff --git a/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_sync.py b/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_sync.py index fc0a1dcbfa71..8af6d97b1669 100644 --- a/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_sync.py +++ b/packages/google-apps-chat/samples/generated_samples/chat_v1_generated_chat_service_create_reaction_sync.py @@ -39,8 +39,12 @@ def sample_create_reaction(): client = chat_v1.ChatServiceClient() # Initialize request argument(s) + reaction = chat_v1.Reaction() + reaction.emoji.unicode = "unicode_value" + request = chat_v1.CreateReactionRequest( parent="parent_value", + reaction=reaction, ) # Make the request diff --git a/packages/google-apps-chat/samples/generated_samples/snippet_metadata_google.chat.v1.json b/packages/google-apps-chat/samples/generated_samples/snippet_metadata_google.chat.v1.json index b4693d56a9b2..55a30ce1c225 100644 --- a/packages/google-apps-chat/samples/generated_samples/snippet_metadata_google.chat.v1.json +++ b/packages/google-apps-chat/samples/generated_samples/snippet_metadata_google.chat.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-apps-chat", - "version": "0.1.14" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.CompleteImportSpaceResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.CompleteImportSpaceResponse", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -550,7 +550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Reaction", @@ -563,12 +563,12 @@ "regionTag": "chat_v1_generated_ChatService_CreateReaction_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -578,18 +578,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Reaction", @@ -647,12 +647,12 @@ "regionTag": "chat_v1_generated_ChatService_CreateReaction_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -662,18 +662,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 52, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -1037,7 +1037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_message" @@ -1114,7 +1114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_message" @@ -1192,7 +1192,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reaction" @@ -1269,7 +1269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reaction" @@ -1347,7 +1347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_space" @@ -1424,7 +1424,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_space" @@ -1498,7 +1498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -1574,7 +1574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -1655,7 +1655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Attachment", @@ -1735,7 +1735,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Attachment", @@ -1816,7 +1816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -1896,7 +1896,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -1977,7 +1977,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -2057,7 +2057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -2138,7 +2138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceEvent", @@ -2218,7 +2218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceEvent", @@ -2299,7 +2299,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceReadState", @@ -2379,7 +2379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceReadState", @@ -2460,7 +2460,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -2540,7 +2540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -2621,7 +2621,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.ThreadReadState", @@ -2701,7 +2701,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.ThreadReadState", @@ -2782,7 +2782,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListMembershipsAsyncPager", @@ -2862,7 +2862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListMembershipsPager", @@ -2943,7 +2943,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListMessagesAsyncPager", @@ -3023,7 +3023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListMessagesPager", @@ -3104,7 +3104,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListReactionsAsyncPager", @@ -3184,7 +3184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListReactionsPager", @@ -3269,7 +3269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListSpaceEventsAsyncPager", @@ -3353,7 +3353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListSpaceEventsPager", @@ -3430,7 +3430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListSpacesAsyncPager", @@ -3506,7 +3506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.ListSpacesPager", @@ -3583,7 +3583,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.SearchSpacesAsyncPager", @@ -3659,7 +3659,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.services.chat_service.pagers.SearchSpacesPager", @@ -3736,7 +3736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -3812,7 +3812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -3897,7 +3897,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -3981,7 +3981,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Membership", @@ -4066,7 +4066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -4150,7 +4150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Message", @@ -4235,7 +4235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceReadState", @@ -4319,7 +4319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.SpaceReadState", @@ -4404,7 +4404,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -4488,7 +4488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.Space", @@ -4565,7 +4565,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.UploadAttachmentResponse", @@ -4641,7 +4641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.chat_v1.types.UploadAttachmentResponse", diff --git a/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py b/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py index b5c828d4d20d..af05fac42229 100644 --- a/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py +++ b/packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py @@ -11506,6 +11506,7 @@ def test_create_message_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.create_message(request) @@ -11568,6 +11569,7 @@ def test_create_message_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_message(**mock_args) @@ -11707,6 +11709,7 @@ def test_list_messages_rest_required_fields(request_type=message.ListMessagesReq 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_messages(request) @@ -11763,6 +11766,7 @@ def test_list_messages_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_messages(**mock_args) @@ -11966,6 +11970,7 @@ def test_list_memberships_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.list_memberships(request) @@ -12023,6 +12028,7 @@ def test_list_memberships_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_memberships(**mock_args) @@ -12217,6 +12223,7 @@ def test_get_membership_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_membership(request) @@ -12262,6 +12269,7 @@ def test_get_membership_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_membership(**mock_args) @@ -12389,6 +12397,7 @@ def test_get_message_rest_required_fields(request_type=message.GetMessageRequest 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_message(request) @@ -12434,6 +12443,7 @@ def test_get_message_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_message(**mock_args) @@ -12566,6 +12576,7 @@ def test_update_message_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.update_message(request) @@ -12587,7 +12598,12 @@ def test_update_message_rest_unset_required_fields(): "updateMask", ) ) - & set(("message",)) + & set( + ( + "message", + "updateMask", + ) + ) ) @@ -12620,6 +12636,7 @@ def test_update_message_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_message(**mock_args) @@ -12747,6 +12764,7 @@ def test_delete_message_rest_required_fields(request_type=message.DeleteMessageR 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_message(request) @@ -12790,6 +12808,7 @@ def test_delete_message_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_message(**mock_args) @@ -12919,6 +12938,7 @@ def test_get_attachment_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_attachment(request) @@ -12964,6 +12984,7 @@ def test_get_attachment_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_attachment(**mock_args) @@ -13101,6 +13122,7 @@ def test_upload_attachment_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.upload_attachment(request) @@ -13336,6 +13358,7 @@ def test_search_spaces_rest_required_fields(request_type=space.SearchSpacesReque 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.search_spaces(request) @@ -13533,6 +13556,7 @@ def test_get_space_rest_required_fields(request_type=space.GetSpaceRequest): 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_space(request) @@ -13578,6 +13602,7 @@ def test_get_space_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_space(**mock_args) @@ -13703,6 +13728,7 @@ def test_create_space_rest_required_fields(request_type=gc_space.CreateSpaceRequ 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_space(request) @@ -13748,6 +13774,7 @@ def test_create_space_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_space(**mock_args) @@ -13869,6 +13896,7 @@ def test_set_up_space_rest_required_fields(request_type=space_setup.SetUpSpaceRe 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_up_space(request) @@ -13989,6 +14017,7 @@ def test_update_space_rest_required_fields(request_type=gc_space.UpdateSpaceRequ 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_space(request) @@ -14010,7 +14039,12 @@ def test_update_space_rest_unset_required_fields(): "useAdminAccess", ) ) - & set(("space",)) + & set( + ( + "space", + "updateMask", + ) + ) ) @@ -14043,6 +14077,7 @@ def test_update_space_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_space(**mock_args) @@ -14170,6 +14205,7 @@ def test_delete_space_rest_required_fields(request_type=space.DeleteSpaceRequest 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_space(request) @@ -14213,6 +14249,7 @@ def test_delete_space_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_space(**mock_args) @@ -14348,6 +14385,7 @@ def test_complete_import_space_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.complete_import_space(request) @@ -14476,6 +14514,7 @@ def test_find_direct_message_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.find_direct_message(request) @@ -14606,6 +14645,7 @@ def test_create_membership_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.create_membership(request) @@ -14660,6 +14700,7 @@ def test_create_membership_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_membership(**mock_args) @@ -14795,6 +14836,7 @@ def test_update_membership_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.update_membership(request) @@ -14854,6 +14896,7 @@ def test_update_membership_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_membership(**mock_args) @@ -14989,6 +15032,7 @@ def test_delete_membership_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.delete_membership(request) @@ -15034,6 +15078,7 @@ def test_delete_membership_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.delete_membership(**mock_args) @@ -15164,6 +15209,7 @@ def test_create_reaction_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.create_reaction(request) @@ -15218,6 +15264,7 @@ def test_create_reaction_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_reaction(**mock_args) @@ -15357,6 +15404,7 @@ def test_list_reactions_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.list_reactions(request) @@ -15411,6 +15459,7 @@ def test_list_reactions_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_reactions(**mock_args) @@ -15599,6 +15648,7 @@ def test_delete_reaction_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.delete_reaction(request) @@ -15642,6 +15692,7 @@ def test_delete_reaction_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_reaction(**mock_args) @@ -15776,6 +15827,7 @@ def test_get_space_read_state_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_space_read_state(request) @@ -15821,6 +15873,7 @@ def test_get_space_read_state_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_space_read_state(**mock_args) @@ -15954,6 +16007,7 @@ def test_update_space_read_state_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.update_space_read_state(request) @@ -16010,6 +16064,7 @@ def test_update_space_read_state_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_space_read_state(**mock_args) @@ -16147,6 +16202,7 @@ def test_get_thread_read_state_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_thread_read_state(request) @@ -16194,6 +16250,7 @@ def test_get_thread_read_state_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_thread_read_state(**mock_args) @@ -16325,6 +16382,7 @@ def test_get_space_event_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_space_event(request) @@ -16370,6 +16428,7 @@ def test_get_space_event_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_space_event(**mock_args) @@ -16516,6 +16575,7 @@ def test_list_space_events_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.list_space_events(request) @@ -16582,6 +16642,7 @@ def test_list_space_events_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_space_events(**mock_args) @@ -18323,6 +18384,7 @@ def test_create_message_rest_bad_request(request_type=gc_message.CreateMessageRe 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_message(request) @@ -18675,6 +18737,7 @@ def test_create_message_rest_call_success(request_type): "post_messages": {}, "reply_messages": {}, }, + "import_mode_expire_time": {}, }, "fallback_text": "fallback_text_value", "action_response": { @@ -18815,6 +18878,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_message(request) # Establish that the response is the type that we expect. @@ -18861,6 +18925,7 @@ def test_create_message_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 = gc_message.Message.to_json(gc_message.Message()) req.return_value.content = return_value @@ -18903,6 +18968,7 @@ def test_list_messages_rest_bad_request(request_type=message.ListMessagesRequest 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_messages(request) @@ -18938,6 +19004,7 @@ def test_list_messages_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_messages(request) # Establish that the response is the type that we expect. @@ -18976,6 +19043,7 @@ def test_list_messages_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 = message.ListMessagesResponse.to_json( message.ListMessagesResponse() ) @@ -19022,6 +19090,7 @@ def test_list_memberships_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.list_memberships(request) @@ -19057,6 +19126,7 @@ def test_list_memberships_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_memberships(request) # Establish that the response is the type that we expect. @@ -19097,6 +19167,7 @@ def test_list_memberships_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 = membership.ListMembershipsResponse.to_json( membership.ListMembershipsResponse() ) @@ -19141,6 +19212,7 @@ def test_get_membership_rest_bad_request(request_type=membership.GetMembershipRe 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_membership(request) @@ -19178,6 +19250,7 @@ def test_get_membership_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_membership(request) # Establish that the response is the type that we expect. @@ -19220,6 +19293,7 @@ def test_get_membership_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 = membership.Membership.to_json(membership.Membership()) req.return_value.content = return_value @@ -19262,6 +19336,7 @@ def test_get_message_rest_bad_request(request_type=message.GetMessageRequest): 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_message(request) @@ -19303,6 +19378,7 @@ def test_get_message_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_message(request) # Establish that the response is the type that we expect. @@ -19347,6 +19423,7 @@ def test_get_message_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 = message.Message.to_json(message.Message()) req.return_value.content = return_value @@ -19389,6 +19466,7 @@ def test_update_message_rest_bad_request(request_type=gc_message.UpdateMessageRe 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_message(request) @@ -19741,6 +19819,7 @@ def test_update_message_rest_call_success(request_type): "post_messages": {}, "reply_messages": {}, }, + "import_mode_expire_time": {}, }, "fallback_text": "fallback_text_value", "action_response": { @@ -19881,6 +19960,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_message(request) # Establish that the response is the type that we expect. @@ -19927,6 +20007,7 @@ def test_update_message_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 = gc_message.Message.to_json(gc_message.Message()) req.return_value.content = return_value @@ -19969,6 +20050,7 @@ def test_delete_message_rest_bad_request(request_type=message.DeleteMessageReque 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_message(request) @@ -19999,6 +20081,7 @@ def test_delete_message_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_message(request) # Establish that the response is the type that we expect. @@ -20033,6 +20116,7 @@ def test_delete_message_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 = message.DeleteMessageRequest() metadata = [ @@ -20071,6 +20155,7 @@ def test_get_attachment_rest_bad_request(request_type=attachment.GetAttachmentRe 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_attachment(request) @@ -20111,6 +20196,7 @@ def test_get_attachment_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_attachment(request) # Establish that the response is the type that we expect. @@ -20156,6 +20242,7 @@ def test_get_attachment_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 = attachment.Attachment.to_json(attachment.Attachment()) req.return_value.content = return_value @@ -20200,6 +20287,7 @@ def test_upload_attachment_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.upload_attachment(request) @@ -20233,6 +20321,7 @@ def test_upload_attachment_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.upload_attachment(request) # Establish that the response is the type that we expect. @@ -20272,6 +20361,7 @@ def test_upload_attachment_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 = attachment.UploadAttachmentResponse.to_json( attachment.UploadAttachmentResponse() ) @@ -20316,6 +20406,7 @@ def test_list_spaces_rest_bad_request(request_type=space.ListSpacesRequest): 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_spaces(request) @@ -20351,6 +20442,7 @@ def test_list_spaces_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_spaces(request) # Establish that the response is the type that we expect. @@ -20389,6 +20481,7 @@ def test_list_spaces_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 = space.ListSpacesResponse.to_json(space.ListSpacesResponse()) req.return_value.content = return_value @@ -20431,6 +20524,7 @@ def test_search_spaces_rest_bad_request(request_type=space.SearchSpacesRequest): 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.search_spaces(request) @@ -20467,6 +20561,7 @@ def test_search_spaces_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.search_spaces(request) # Establish that the response is the type that we expect. @@ -20506,6 +20601,7 @@ def test_search_spaces_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 = space.SearchSpacesResponse.to_json(space.SearchSpacesResponse()) req.return_value.content = return_value @@ -20548,6 +20644,7 @@ def test_get_space_rest_bad_request(request_type=space.GetSpaceRequest): 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_space(request) @@ -20595,6 +20692,7 @@ def test_get_space_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_space(request) # Establish that the response is the type that we expect. @@ -20647,6 +20745,7 @@ def test_get_space_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 = space.Space.to_json(space.Space()) req.return_value.content = return_value @@ -20689,6 +20788,7 @@ def test_create_space_rest_bad_request(request_type=gc_space.CreateSpaceRequest) 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_space(request) @@ -20744,6 +20844,7 @@ def test_create_space_rest_call_success(request_type): "post_messages": {}, "reply_messages": {}, }, + "import_mode_expire_time": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -20842,6 +20943,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_space(request) # Establish that the response is the type that we expect. @@ -20894,6 +20996,7 @@ def test_create_space_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 = gc_space.Space.to_json(gc_space.Space()) req.return_value.content = return_value @@ -20936,6 +21039,7 @@ def test_set_up_space_rest_bad_request(request_type=space_setup.SetUpSpaceReques 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_up_space(request) @@ -20983,6 +21087,7 @@ def test_set_up_space_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_up_space(request) # Establish that the response is the type that we expect. @@ -21035,6 +21140,7 @@ def test_set_up_space_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 = space.Space.to_json(space.Space()) req.return_value.content = return_value @@ -21077,6 +21183,7 @@ def test_update_space_rest_bad_request(request_type=gc_space.UpdateSpaceRequest) 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_space(request) @@ -21132,6 +21239,7 @@ def test_update_space_rest_call_success(request_type): "post_messages": {}, "reply_messages": {}, }, + "import_mode_expire_time": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency @@ -21230,6 +21338,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_space(request) # Establish that the response is the type that we expect. @@ -21282,6 +21391,7 @@ def test_update_space_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 = gc_space.Space.to_json(gc_space.Space()) req.return_value.content = return_value @@ -21324,6 +21434,7 @@ def test_delete_space_rest_bad_request(request_type=space.DeleteSpaceRequest): 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_space(request) @@ -21354,6 +21465,7 @@ def test_delete_space_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_space(request) # Establish that the response is the type that we expect. @@ -21388,6 +21500,7 @@ def test_delete_space_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 = space.DeleteSpaceRequest() metadata = [ @@ -21428,6 +21541,7 @@ def test_complete_import_space_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.complete_import_space(request) @@ -21461,6 +21575,7 @@ def test_complete_import_space_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.complete_import_space(request) # Establish that the response is the type that we expect. @@ -21500,6 +21615,7 @@ def test_complete_import_space_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 = space.CompleteImportSpaceResponse.to_json( space.CompleteImportSpaceResponse() ) @@ -21546,6 +21662,7 @@ def test_find_direct_message_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.find_direct_message(request) @@ -21593,6 +21710,7 @@ def test_find_direct_message_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.find_direct_message(request) # Establish that the response is the type that we expect. @@ -21645,6 +21763,7 @@ def test_find_direct_message_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 = space.Space.to_json(space.Space()) req.return_value.content = return_value @@ -21689,6 +21808,7 @@ def test_create_membership_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.create_membership(request) @@ -21808,6 +21928,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_membership(request) # Establish that the response is the type that we expect. @@ -21850,6 +21971,7 @@ def test_create_membership_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 = gc_membership.Membership.to_json(gc_membership.Membership()) req.return_value.content = return_value @@ -21894,6 +22016,7 @@ def test_update_membership_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.update_membership(request) @@ -22013,6 +22136,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_membership(request) # Establish that the response is the type that we expect. @@ -22055,6 +22179,7 @@ def test_update_membership_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 = gc_membership.Membership.to_json(gc_membership.Membership()) req.return_value.content = return_value @@ -22099,6 +22224,7 @@ def test_delete_membership_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.delete_membership(request) @@ -22136,6 +22262,7 @@ def test_delete_membership_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.delete_membership(request) # Establish that the response is the type that we expect. @@ -22178,6 +22305,7 @@ def test_delete_membership_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 = membership.Membership.to_json(membership.Membership()) req.return_value.content = return_value @@ -22222,6 +22350,7 @@ def test_create_reaction_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.create_reaction(request) @@ -22335,6 +22464,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_reaction(request) # Establish that the response is the type that we expect. @@ -22375,6 +22505,7 @@ def test_create_reaction_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 = gc_reaction.Reaction.to_json(gc_reaction.Reaction()) req.return_value.content = return_value @@ -22417,6 +22548,7 @@ def test_list_reactions_rest_bad_request(request_type=reaction.ListReactionsRequ 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_reactions(request) @@ -22452,6 +22584,7 @@ def test_list_reactions_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_reactions(request) # Establish that the response is the type that we expect. @@ -22490,6 +22623,7 @@ def test_list_reactions_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 = reaction.ListReactionsResponse.to_json( reaction.ListReactionsResponse() ) @@ -22534,6 +22668,7 @@ def test_delete_reaction_rest_bad_request(request_type=reaction.DeleteReactionRe 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_reaction(request) @@ -22564,6 +22699,7 @@ def test_delete_reaction_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_reaction(request) # Establish that the response is the type that we expect. @@ -22598,6 +22734,7 @@ def test_delete_reaction_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 = reaction.DeleteReactionRequest() metadata = [ @@ -22638,6 +22775,7 @@ def test_get_space_read_state_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_space_read_state(request) @@ -22673,6 +22811,7 @@ def test_get_space_read_state_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_space_read_state(request) # Establish that the response is the type that we expect. @@ -22713,6 +22852,7 @@ def test_get_space_read_state_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 = space_read_state.SpaceReadState.to_json( space_read_state.SpaceReadState() ) @@ -22761,6 +22901,7 @@ def test_update_space_read_state_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.update_space_read_state(request) @@ -22871,6 +23012,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_space_read_state(request) # Establish that the response is the type that we expect. @@ -22911,6 +23053,7 @@ def test_update_space_read_state_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 = gc_space_read_state.SpaceReadState.to_json( gc_space_read_state.SpaceReadState() ) @@ -22959,6 +23102,7 @@ def test_get_thread_read_state_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_thread_read_state(request) @@ -22996,6 +23140,7 @@ def test_get_thread_read_state_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_thread_read_state(request) # Establish that the response is the type that we expect. @@ -23036,6 +23181,7 @@ def test_get_thread_read_state_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 = thread_read_state.ThreadReadState.to_json( thread_read_state.ThreadReadState() ) @@ -23082,6 +23228,7 @@ def test_get_space_event_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_space_event(request) @@ -23118,6 +23265,7 @@ def test_get_space_event_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_space_event(request) # Establish that the response is the type that we expect. @@ -23159,6 +23307,7 @@ def test_get_space_event_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 = space_event.SpaceEvent.to_json(space_event.SpaceEvent()) req.return_value.content = return_value @@ -23203,6 +23352,7 @@ def test_list_space_events_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.list_space_events(request) @@ -23238,6 +23388,7 @@ def test_list_space_events_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_space_events(request) # Establish that the response is the type that we expect. @@ -23278,6 +23429,7 @@ def test_list_space_events_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 = space_event.ListSpaceEventsResponse.to_json( space_event.ListSpaceEventsResponse() ) From 247863d68bed85b452aff82b444bcef222e0c1c1 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:40:25 +0000 Subject: [PATCH 13/16] feat: [google-cloud-dialogflow] Add support for opt-in debug logging (#13326) 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 feat: properly mark TrainingPhrase name field output-only docs: fixed the references to proto method / fields 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpYWxvZ2Zsb3cvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== BEGIN_NESTED_COMMIT feat: [google-cloud-dialogflow] properly mark TrainingPhrase name field output-only docs: fixed the references to proto method / fields PiperOrigin-RevId: 702736565 Source-Link: https://github.com/googleapis/googleapis/commit/6989f679896e2318b02d7e6c74b6d65aa2290824 Source-Link: https://github.com/googleapis/googleapis-gen/commit/50364718af0486eaa5c2fa2925414be858d0cf7d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpYWxvZ2Zsb3cvLk93bEJvdC55YW1sIiwiaCI6IjUwMzY0NzE4YWYwNDg2ZWFhNWMyZmEyOTI1NDE0YmU4NThkMGNmN2QifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/dialogflow/gapic_version.py | 2 +- .../cloud/dialogflow_v2/gapic_version.py | 2 +- .../services/agents/async_client.py | 144 ++- .../dialogflow_v2/services/agents/client.py | 149 ++- .../dialogflow_v2/services/agents/pagers.py | 16 +- .../services/agents/transports/grpc.py | 122 +- .../agents/transports/grpc_asyncio.py | 119 +- .../services/agents/transports/rest.py | 860 ++++++++++++-- .../services/answer_records/async_client.py | 95 +- .../services/answer_records/client.py | 100 +- .../services/answer_records/pagers.py | 16 +- .../answer_records/transports/grpc.py | 104 +- .../answer_records/transports/grpc_asyncio.py | 103 +- .../answer_records/transports/rest.py | 442 ++++++- .../services/contexts/async_client.py | 120 +- .../dialogflow_v2/services/contexts/client.py | 125 +- .../dialogflow_v2/services/contexts/pagers.py | 16 +- .../services/contexts/transports/grpc.py | 112 +- .../contexts/transports/grpc_asyncio.py | 111 +- .../services/contexts/transports/rest.py | 644 ++++++++++- .../conversation_datasets/async_client.py | 112 +- .../services/conversation_datasets/client.py | 117 +- .../services/conversation_datasets/pagers.py | 16 +- .../conversation_datasets/transports/grpc.py | 120 +- .../transports/grpc_asyncio.py | 117 +- .../conversation_datasets/transports/rest.py | 624 +++++++++- .../conversation_models/async_client.py | 144 ++- .../services/conversation_models/client.py | 149 ++- .../services/conversation_models/pagers.py | 32 +- .../conversation_models/transports/grpc.py | 124 +- .../transports/grpc_asyncio.py | 121 +- .../conversation_models/transports/rest.py | 878 ++++++++++++-- .../conversation_profiles/async_client.py | 146 ++- .../services/conversation_profiles/client.py | 151 ++- .../services/conversation_profiles/pagers.py | 16 +- .../conversation_profiles/transports/grpc.py | 140 ++- .../transports/grpc_asyncio.py | 137 ++- .../conversation_profiles/transports/rest.py | 733 +++++++++++- .../services/conversations/async_client.py | 144 ++- .../services/conversations/client.py | 149 ++- .../services/conversations/pagers.py | 32 +- .../services/conversations/transports/grpc.py | 122 +- .../conversations/transports/grpc_asyncio.py | 121 +- .../services/conversations/transports/rest.py | 897 ++++++++++++-- .../services/documents/async_client.py | 136 ++- .../services/documents/client.py | 141 ++- .../services/documents/pagers.py | 16 +- .../services/documents/transports/grpc.py | 120 +- .../documents/transports/grpc_asyncio.py | 117 +- .../services/documents/transports/rest.py | 808 +++++++++++-- .../encryption_spec_service/async_client.py | 88 +- .../encryption_spec_service/client.py | 93 +- .../transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 107 +- .../transports/rest.py | 432 ++++++- .../services/entity_types/async_client.py | 152 ++- .../services/entity_types/client.py | 157 ++- .../services/entity_types/pagers.py | 16 +- .../services/entity_types/transports/grpc.py | 124 +- .../entity_types/transports/grpc_asyncio.py | 121 +- .../services/entity_types/transports/rest.py | 926 +++++++++++++-- .../services/environments/async_client.py | 120 +- .../services/environments/client.py | 125 +- .../services/environments/pagers.py | 32 +- .../services/environments/transports/grpc.py | 112 +- .../environments/transports/grpc_asyncio.py | 111 +- .../services/environments/transports/rest.py | 669 ++++++++++- .../services/fulfillments/async_client.py | 88 +- .../services/fulfillments/client.py | 93 +- .../services/fulfillments/transports/grpc.py | 104 +- .../fulfillments/transports/grpc_asyncio.py | 103 +- .../services/fulfillments/transports/rest.py | 433 ++++++- .../services/generators/async_client.py | 112 +- .../services/generators/client.py | 117 +- .../services/generators/pagers.py | 16 +- .../services/generators/transports/grpc.py | 110 +- .../generators/transports/grpc_asyncio.py | 109 +- .../services/generators/transports/rest.py | 602 +++++++++- .../services/intents/async_client.py | 128 +- .../dialogflow_v2/services/intents/client.py | 133 ++- .../dialogflow_v2/services/intents/pagers.py | 16 +- .../services/intents/transports/grpc.py | 118 +- .../intents/transports/grpc_asyncio.py | 115 +- .../services/intents/transports/rest.py | 726 +++++++++++- .../services/knowledge_bases/async_client.py | 112 +- .../services/knowledge_bases/client.py | 117 +- .../services/knowledge_bases/pagers.py | 16 +- .../knowledge_bases/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../knowledge_bases/transports/rest.py | 608 +++++++++- .../services/participants/async_client.py | 152 ++- .../services/participants/client.py | 157 ++- .../services/participants/pagers.py | 16 +- .../services/participants/transports/grpc.py | 122 +- .../participants/transports/grpc_asyncio.py | 121 +- .../services/participants/transports/rest.py | 897 ++++++++++++-- .../session_entity_types/async_client.py | 112 +- .../services/session_entity_types/client.py | 117 +- .../services/session_entity_types/pagers.py | 16 +- .../session_entity_types/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../session_entity_types/transports/rest.py | 605 +++++++++- .../services/sessions/async_client.py | 111 +- .../dialogflow_v2/services/sessions/client.py | 116 +- .../services/sessions/transports/grpc.py | 104 +- .../sessions/transports/grpc_asyncio.py | 103 +- .../services/sessions/transports/rest.py | 376 +++++- .../services/versions/async_client.py | 112 +- .../dialogflow_v2/services/versions/client.py | 117 +- .../dialogflow_v2/services/versions/pagers.py | 16 +- .../services/versions/transports/grpc.py | 110 +- .../versions/transports/grpc_asyncio.py | 109 +- .../services/versions/transports/rest.py | 602 +++++++++- .../dialogflow_v2/types/answer_record.py | 6 +- .../cloud/dialogflow_v2/types/audio_config.py | 5 +- .../cloud/dialogflow_v2/types/conversation.py | 19 +- .../types/conversation_dataset.py | 4 +- .../types/conversation_profile.py | 11 +- .../cloud/dialogflow_v2/types/participant.py | 28 +- .../cloud/dialogflow_v2/types/session.py | 43 +- .../cloud/dialogflow_v2beta1/gapic_version.py | 2 +- .../services/agents/async_client.py | 144 ++- .../services/agents/client.py | 149 ++- .../services/agents/pagers.py | 16 +- .../services/agents/transports/grpc.py | 122 +- .../agents/transports/grpc_asyncio.py | 119 +- .../services/agents/transports/rest.py | 860 ++++++++++++-- .../services/answer_records/async_client.py | 96 +- .../services/answer_records/client.py | 101 +- .../services/answer_records/pagers.py | 16 +- .../answer_records/transports/grpc.py | 106 +- .../answer_records/transports/grpc_asyncio.py | 105 +- .../answer_records/transports/rest.py | 499 +++++++- .../services/contexts/async_client.py | 120 +- .../services/contexts/client.py | 125 +- .../services/contexts/pagers.py | 16 +- .../services/contexts/transports/grpc.py | 112 +- .../contexts/transports/grpc_asyncio.py | 111 +- .../services/contexts/transports/rest.py | 644 ++++++++++- .../conversation_profiles/async_client.py | 128 +- .../services/conversation_profiles/client.py | 133 ++- .../services/conversation_profiles/pagers.py | 16 +- .../conversation_profiles/transports/grpc.py | 126 +- .../transports/grpc_asyncio.py | 123 +- .../conversation_profiles/transports/rest.py | 729 +++++++++++- .../services/conversations/async_client.py | 152 ++- .../services/conversations/client.py | 157 ++- .../services/conversations/pagers.py | 32 +- .../services/conversations/transports/grpc.py | 124 +- .../conversations/transports/grpc_asyncio.py | 123 +- .../services/conversations/transports/rest.py | 963 +++++++++++++-- .../services/documents/async_client.py | 128 +- .../services/documents/client.py | 133 ++- .../services/documents/pagers.py | 16 +- .../services/documents/transports/grpc.py | 118 +- .../documents/transports/grpc_asyncio.py | 115 +- .../services/documents/transports/rest.py | 746 +++++++++++- .../encryption_spec_service/async_client.py | 88 +- .../encryption_spec_service/client.py | 93 +- .../transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 107 +- .../transports/rest.py | 432 ++++++- .../services/entity_types/async_client.py | 152 ++- .../services/entity_types/client.py | 157 ++- .../services/entity_types/pagers.py | 16 +- .../services/entity_types/transports/grpc.py | 124 +- .../entity_types/transports/grpc_asyncio.py | 121 +- .../services/entity_types/transports/rest.py | 926 +++++++++++++-- .../services/environments/async_client.py | 120 +- .../services/environments/client.py | 125 +- .../services/environments/pagers.py | 32 +- .../services/environments/transports/grpc.py | 112 +- .../environments/transports/grpc_asyncio.py | 111 +- .../services/environments/transports/rest.py | 669 ++++++++++- .../services/fulfillments/async_client.py | 88 +- .../services/fulfillments/client.py | 93 +- .../services/fulfillments/transports/grpc.py | 104 +- .../fulfillments/transports/grpc_asyncio.py | 103 +- .../services/fulfillments/transports/rest.py | 433 ++++++- .../services/generators/async_client.py | 112 +- .../services/generators/client.py | 117 +- .../services/generators/pagers.py | 16 +- .../services/generators/transports/grpc.py | 110 +- .../generators/transports/grpc_asyncio.py | 109 +- .../services/generators/transports/rest.py | 602 +++++++++- .../services/intents/async_client.py | 128 +- .../services/intents/client.py | 133 ++- .../services/intents/pagers.py | 16 +- .../services/intents/transports/grpc.py | 118 +- .../intents/transports/grpc_asyncio.py | 115 +- .../services/intents/transports/rest.py | 726 +++++++++++- .../services/knowledge_bases/async_client.py | 112 +- .../services/knowledge_bases/client.py | 117 +- .../services/knowledge_bases/pagers.py | 16 +- .../knowledge_bases/transports/grpc.py | 110 +- .../transports/grpc_asyncio.py | 109 +- .../knowledge_bases/transports/rest.py | 608 +++++++++- .../services/participants/async_client.py | 168 ++- .../services/participants/client.py | 173 ++- .../services/participants/pagers.py | 32 +- .../services/participants/transports/grpc.py | 126 +- .../participants/transports/grpc_asyncio.py | 125 +- .../services/participants/transports/rest.py | 1029 +++++++++++++++-- .../session_entity_types/async_client.py | 112 +- .../services/session_entity_types/client.py | 117 +- .../services/session_entity_types/pagers.py | 16 +- .../session_entity_types/transports/grpc.py | 116 +- .../transports/grpc_asyncio.py | 115 +- .../session_entity_types/transports/rest.py | 605 +++++++++- .../services/sessions/async_client.py | 88 +- .../services/sessions/client.py | 93 +- .../services/sessions/transports/grpc.py | 104 +- .../sessions/transports/grpc_asyncio.py | 103 +- .../services/sessions/transports/rest.py | 372 +++++- .../services/sip_trunks/async_client.py | 112 +- .../services/sip_trunks/client.py | 117 +- .../services/sip_trunks/pagers.py | 16 +- .../services/sip_trunks/transports/grpc.py | 110 +- .../sip_trunks/transports/grpc_asyncio.py | 109 +- .../services/sip_trunks/transports/rest.py | 600 +++++++++- .../services/versions/async_client.py | 112 +- .../services/versions/client.py | 117 +- .../services/versions/pagers.py | 16 +- .../services/versions/transports/grpc.py | 110 +- .../versions/transports/grpc_asyncio.py | 109 +- .../services/versions/transports/rest.py | 602 +++++++++- ...t_metadata_google.cloud.dialogflow.v2.json | 458 ++++---- ...adata_google.cloud.dialogflow.v2beta1.json | 434 +++---- .../unit/gapic/dialogflow_v2/test_agents.py | 52 + .../dialogflow_v2/test_answer_records.py | 20 + .../unit/gapic/dialogflow_v2/test_contexts.py | 40 + .../test_conversation_datasets.py | 34 + .../dialogflow_v2/test_conversation_models.py | 53 + .../test_conversation_profiles.py | 45 + .../gapic/dialogflow_v2/test_conversations.py | 52 + .../gapic/dialogflow_v2/test_documents.py | 48 + .../test_encryption_spec_service.py | 20 + .../gapic/dialogflow_v2/test_entity_types.py | 59 + .../gapic/dialogflow_v2/test_environments.py | 35 + .../gapic/dialogflow_v2/test_fulfillments.py | 20 + .../gapic/dialogflow_v2/test_generators.py | 35 + .../unit/gapic/dialogflow_v2/test_intents.py | 45 + .../dialogflow_v2/test_knowledge_bases.py | 35 + .../gapic/dialogflow_v2/test_participants.py | 54 + .../test_session_entity_types.py | 35 + .../unit/gapic/dialogflow_v2/test_sessions.py | 15 + .../unit/gapic/dialogflow_v2/test_versions.py | 35 + .../gapic/dialogflow_v2beta1/test_agents.py | 52 + .../dialogflow_v2beta1/test_answer_records.py | 22 + .../gapic/dialogflow_v2beta1/test_contexts.py | 40 + .../test_conversation_profiles.py | 45 + .../dialogflow_v2beta1/test_conversations.py | 57 + .../dialogflow_v2beta1/test_documents.py | 44 + .../test_encryption_spec_service.py | 20 + .../dialogflow_v2beta1/test_entity_types.py | 59 + .../dialogflow_v2beta1/test_environments.py | 35 + .../dialogflow_v2beta1/test_fulfillments.py | 20 + .../dialogflow_v2beta1/test_generators.py | 35 + .../gapic/dialogflow_v2beta1/test_intents.py | 45 + .../test_knowledge_bases.py | 35 + .../dialogflow_v2beta1/test_participants.py | 60 + .../test_session_entity_types.py | 35 + .../gapic/dialogflow_v2beta1/test_sessions.py | 15 + .../dialogflow_v2beta1/test_sip_trunks.py | 35 + .../gapic/dialogflow_v2beta1/test_versions.py | 35 + 265 files changed, 39179 insertions(+), 6283 deletions(-) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py index 102e325cdfdf..558c8aab67c5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.36.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py index 102e325cdfdf..558c8aab67c5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.36.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/async_client.py index ee05cfb24395..29bd01a96915 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AgentsTransport from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport +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 AgentsAsyncClient: """Service for managing [Agents][google.cloud.dialogflow.v2.Agent].""" @@ -253,6 +263,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.dialogflow_v2.AgentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "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.dialogflow.v2.Agents", + "credentialsType": None, + }, + ) + async def get_agent( self, request: Optional[Union[agent.GetAgentRequest, dict]] = None, @@ -260,7 +292,7 @@ async def get_agent( 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]]] = (), ) -> agent.Agent: r"""Retrieves the specified agent. @@ -304,8 +336,10 @@ async def sample_get_agent(): 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.dialogflow_v2.types.Agent: @@ -375,7 +409,7 @@ async def set_agent( agent: Optional[gcd_agent.Agent] = 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]]] = (), ) -> gcd_agent.Agent: r"""Creates/updates the specified agent. @@ -427,8 +461,10 @@ async def sample_set_agent(): 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.dialogflow_v2.types.Agent: @@ -500,7 +536,7 @@ async def delete_agent( 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]]] = (), ) -> None: r"""Deletes the specified agent. @@ -541,8 +577,10 @@ async def sample_delete_agent(): 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 @@ -594,7 +632,7 @@ async def search_agents( 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.SearchAgentsAsyncPager: r"""Returns the list of agents. @@ -645,8 +683,10 @@ async def sample_search_agents(): 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.dialogflow_v2.services.agents.pagers.SearchAgentsAsyncPager: @@ -721,7 +761,7 @@ async def train_agent( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Trains the specified agent. @@ -783,8 +823,10 @@ async def sample_train_agent(): 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.api_core.operation_async.AsyncOperation: @@ -863,7 +905,7 @@ async def export_agent( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports the specified agent to a ZIP file. @@ -922,8 +964,10 @@ async def sample_export_agent(): 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.api_core.operation_async.AsyncOperation: @@ -993,7 +1037,7 @@ async def import_agent( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Imports the specified agent from a ZIP file. @@ -1063,8 +1107,10 @@ async def sample_import_agent(): 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.api_core.operation_async.AsyncOperation: @@ -1128,7 +1174,7 @@ async def restore_agent( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Restores the specified agent from a ZIP file. @@ -1196,8 +1242,10 @@ async def sample_restore_agent(): 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.api_core.operation_async.AsyncOperation: @@ -1261,7 +1309,7 @@ async def get_validation_result( *, 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]]] = (), ) -> validation_result.ValidationResult: r"""Gets agent validation result. Agent validation is performed during training time and is updated @@ -1300,8 +1348,10 @@ async def sample_get_validation_result(): 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.dialogflow_v2.types.ValidationResult: @@ -1347,7 +1397,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1358,8 +1408,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1400,7 +1452,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1411,8 +1463,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1453,7 +1507,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1468,8 +1522,10 @@ async def cancel_operation( 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: None """ @@ -1506,7 +1562,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. @@ -1517,8 +1573,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. @@ -1559,7 +1617,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. @@ -1570,8 +1628,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-dialogflow/google/cloud/dialogflow_v2/services/agents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/client.py index d7c32d2724b4..d78e35631c64 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -578,6 +588,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( @@ -640,6 +654,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.dialogflow_v2.AgentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "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.dialogflow.v2.Agents", + "credentialsType": None, + }, + ) + def get_agent( self, request: Optional[Union[agent.GetAgentRequest, dict]] = None, @@ -647,7 +684,7 @@ def get_agent( 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]]] = (), ) -> agent.Agent: r"""Retrieves the specified agent. @@ -691,8 +728,10 @@ def sample_get_agent(): 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.dialogflow_v2.types.Agent: @@ -759,7 +798,7 @@ def set_agent( agent: Optional[gcd_agent.Agent] = 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]]] = (), ) -> gcd_agent.Agent: r"""Creates/updates the specified agent. @@ -811,8 +850,10 @@ def sample_set_agent(): 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.dialogflow_v2.types.Agent: @@ -881,7 +922,7 @@ def delete_agent( 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]]] = (), ) -> None: r"""Deletes the specified agent. @@ -922,8 +963,10 @@ def sample_delete_agent(): 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 @@ -972,7 +1015,7 @@ def search_agents( 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.SearchAgentsPager: r"""Returns the list of agents. @@ -1023,8 +1066,10 @@ def sample_search_agents(): 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.dialogflow_v2.services.agents.pagers.SearchAgentsPager: @@ -1096,7 +1141,7 @@ def train_agent( 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]]] = (), ) -> operation.Operation: r"""Trains the specified agent. @@ -1158,8 +1203,10 @@ def sample_train_agent(): 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.api_core.operation.Operation: @@ -1235,7 +1282,7 @@ def export_agent( 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]]] = (), ) -> operation.Operation: r"""Exports the specified agent to a ZIP file. @@ -1294,8 +1341,10 @@ def sample_export_agent(): 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.api_core.operation.Operation: @@ -1362,7 +1411,7 @@ def import_agent( *, 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]]] = (), ) -> operation.Operation: r"""Imports the specified agent from a ZIP file. @@ -1432,8 +1481,10 @@ def sample_import_agent(): 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.api_core.operation.Operation: @@ -1495,7 +1546,7 @@ def restore_agent( *, 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]]] = (), ) -> operation.Operation: r"""Restores the specified agent from a ZIP file. @@ -1563,8 +1614,10 @@ def sample_restore_agent(): 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.api_core.operation.Operation: @@ -1626,7 +1679,7 @@ def get_validation_result( *, 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]]] = (), ) -> validation_result.ValidationResult: r"""Gets agent validation result. Agent validation is performed during training time and is updated @@ -1665,8 +1718,10 @@ def sample_get_validation_result(): 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.dialogflow_v2.types.ValidationResult: @@ -1723,7 +1778,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1734,8 +1789,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1776,7 +1833,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1787,8 +1844,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1829,7 +1888,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1844,8 +1903,10 @@ def cancel_operation( 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: None """ @@ -1882,7 +1943,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. @@ -1893,8 +1954,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. @@ -1935,7 +1998,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. @@ -1946,8 +2009,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-dialogflow/google/cloud/dialogflow_v2/services/agents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/pagers.py index 39ac5b3a3d21..8d3649675d95 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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 = agent.SearchAgentsRequest(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 = agent.SearchAgentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc.py index 5546230c723f..e9421455ff8c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import agent from google.cloud.dialogflow_v2.types import agent as gcd_agent @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, AgentsTransport +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.dialogflow.v2.Agents", + "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.dialogflow.v2.Agents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AgentsGrpcTransport(AgentsTransport): """gRPC backend transport for Agents. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def get_agent(self) -> Callable[[agent.GetAgentRequest], agent.Agent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent" not in self._stubs: - self._stubs["get_agent"] = self.grpc_channel.unary_unary( + self._stubs["get_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/GetAgent", request_serializer=agent.GetAgentRequest.serialize, response_deserializer=agent.Agent.deserialize, @@ -299,7 +387,7 @@ def set_agent(self) -> Callable[[gcd_agent.SetAgentRequest], gcd_agent.Agent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_agent" not in self._stubs: - self._stubs["set_agent"] = self.grpc_channel.unary_unary( + self._stubs["set_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/SetAgent", request_serializer=gcd_agent.SetAgentRequest.serialize, response_deserializer=gcd_agent.Agent.deserialize, @@ -323,7 +411,7 @@ def delete_agent(self) -> Callable[[agent.DeleteAgentRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent" not in self._stubs: - self._stubs["delete_agent"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/DeleteAgent", request_serializer=agent.DeleteAgentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -355,7 +443,7 @@ def search_agents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_agents" not in self._stubs: - self._stubs["search_agents"] = self.grpc_channel.unary_unary( + self._stubs["search_agents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/SearchAgents", request_serializer=agent.SearchAgentsRequest.serialize, response_deserializer=agent.SearchAgentsResponse.deserialize, @@ -395,7 +483,7 @@ def train_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "train_agent" not in self._stubs: - self._stubs["train_agent"] = self.grpc_channel.unary_unary( + self._stubs["train_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/TrainAgent", request_serializer=agent.TrainAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def export_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_agent" not in self._stubs: - self._stubs["export_agent"] = self.grpc_channel.unary_unary( + self._stubs["export_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/ExportAgent", request_serializer=agent.ExportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +573,7 @@ def import_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_agent" not in self._stubs: - self._stubs["import_agent"] = self.grpc_channel.unary_unary( + self._stubs["import_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/ImportAgent", request_serializer=agent.ImportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -537,7 +625,7 @@ def restore_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_agent" not in self._stubs: - self._stubs["restore_agent"] = self.grpc_channel.unary_unary( + self._stubs["restore_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/RestoreAgent", request_serializer=agent.RestoreAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -567,7 +655,7 @@ def get_validation_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_validation_result" not in self._stubs: - self._stubs["get_validation_result"] = self.grpc_channel.unary_unary( + self._stubs["get_validation_result"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/GetValidationResult", request_serializer=agent.GetValidationResultRequest.serialize, response_deserializer=validation_result.ValidationResult.deserialize, @@ -575,7 +663,7 @@ def get_validation_result( return self._stubs["get_validation_result"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -587,7 +675,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -604,7 +692,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -623,7 +711,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -642,7 +730,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, @@ -659,7 +747,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-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py index 4e595ccd4c80..3859c6d04c02 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import agent from google.cloud.dialogflow_v2.types import agent as gcd_agent @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, AgentsTransport from .grpc import AgentsGrpcTransport +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.dialogflow.v2.Agents", + "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.dialogflow.v2.Agents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AgentsGrpcAsyncIOTransport(AgentsTransport): """gRPC AsyncIO backend transport for Agents. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -281,7 +366,7 @@ def get_agent(self) -> Callable[[agent.GetAgentRequest], Awaitable[agent.Agent]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent" not in self._stubs: - self._stubs["get_agent"] = self.grpc_channel.unary_unary( + self._stubs["get_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/GetAgent", request_serializer=agent.GetAgentRequest.serialize, response_deserializer=agent.Agent.deserialize, @@ -311,7 +396,7 @@ def set_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_agent" not in self._stubs: - self._stubs["set_agent"] = self.grpc_channel.unary_unary( + self._stubs["set_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/SetAgent", request_serializer=gcd_agent.SetAgentRequest.serialize, response_deserializer=gcd_agent.Agent.deserialize, @@ -337,7 +422,7 @@ def delete_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent" not in self._stubs: - self._stubs["delete_agent"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/DeleteAgent", request_serializer=agent.DeleteAgentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -369,7 +454,7 @@ def search_agents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_agents" not in self._stubs: - self._stubs["search_agents"] = self.grpc_channel.unary_unary( + self._stubs["search_agents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/SearchAgents", request_serializer=agent.SearchAgentsRequest.serialize, response_deserializer=agent.SearchAgentsResponse.deserialize, @@ -409,7 +494,7 @@ def train_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "train_agent" not in self._stubs: - self._stubs["train_agent"] = self.grpc_channel.unary_unary( + self._stubs["train_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/TrainAgent", request_serializer=agent.TrainAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -445,7 +530,7 @@ def export_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_agent" not in self._stubs: - self._stubs["export_agent"] = self.grpc_channel.unary_unary( + self._stubs["export_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/ExportAgent", request_serializer=agent.ExportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -499,7 +584,7 @@ def import_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_agent" not in self._stubs: - self._stubs["import_agent"] = self.grpc_channel.unary_unary( + self._stubs["import_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/ImportAgent", request_serializer=agent.ImportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -551,7 +636,7 @@ def restore_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_agent" not in self._stubs: - self._stubs["restore_agent"] = self.grpc_channel.unary_unary( + self._stubs["restore_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/RestoreAgent", request_serializer=agent.RestoreAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -582,7 +667,7 @@ def get_validation_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_validation_result" not in self._stubs: - self._stubs["get_validation_result"] = self.grpc_channel.unary_unary( + self._stubs["get_validation_result"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Agents/GetValidationResult", request_serializer=agent.GetValidationResultRequest.serialize, response_deserializer=validation_result.ValidationResult.deserialize, @@ -670,7 +755,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: @@ -686,7 +771,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -703,7 +788,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -722,7 +807,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -741,7 +826,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, @@ -758,7 +843,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-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/rest.py index f5bc1d920725..f14c8a452f2a 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/agents/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 @@ -42,6 +42,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, @@ -140,8 +148,10 @@ def post_train_agent(self, response): """ def pre_delete_agent( - self, request: agent.DeleteAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.DeleteAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.DeleteAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.DeleteAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_agent Override in a subclass to manipulate the request or metadata @@ -150,8 +160,10 @@ def pre_delete_agent( return request, metadata def pre_export_agent( - self, request: agent.ExportAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.ExportAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.ExportAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.ExportAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_agent Override in a subclass to manipulate the request or metadata @@ -171,8 +183,10 @@ def post_export_agent( return response def pre_get_agent( - self, request: agent.GetAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.GetAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.GetAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.GetAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_agent Override in a subclass to manipulate the request or metadata @@ -192,8 +206,10 @@ def post_get_agent(self, response: agent.Agent) -> agent.Agent: def pre_get_validation_result( self, request: agent.GetValidationResultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[agent.GetValidationResultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + agent.GetValidationResultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_validation_result Override in a subclass to manipulate the request or metadata @@ -213,8 +229,10 @@ def post_get_validation_result( return response def pre_import_agent( - self, request: agent.ImportAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.ImportAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.ImportAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.ImportAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_agent Override in a subclass to manipulate the request or metadata @@ -234,8 +252,10 @@ def post_import_agent( return response def pre_restore_agent( - self, request: agent.RestoreAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.RestoreAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.RestoreAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.RestoreAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restore_agent Override in a subclass to manipulate the request or metadata @@ -255,8 +275,10 @@ def post_restore_agent( return response def pre_search_agents( - self, request: agent.SearchAgentsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.SearchAgentsRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.SearchAgentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.SearchAgentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_agents Override in a subclass to manipulate the request or metadata @@ -276,8 +298,10 @@ def post_search_agents( return response def pre_set_agent( - self, request: gcd_agent.SetAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gcd_agent.SetAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: gcd_agent.SetAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_agent.SetAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_agent Override in a subclass to manipulate the request or metadata @@ -295,8 +319,10 @@ def post_set_agent(self, response: gcd_agent.Agent) -> gcd_agent.Agent: return response def pre_train_agent( - self, request: agent.TrainAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.TrainAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.TrainAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.TrainAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for train_agent Override in a subclass to manipulate the request or metadata @@ -318,8 +344,10 @@ def post_train_agent( 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 @@ -341,8 +369,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 @@ -364,8 +394,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -385,8 +417,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -408,8 +442,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -606,7 +642,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 agent method over HTTP. @@ -617,11 +653,14 @@ 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 = _BaseAgentsRestTransport._BaseDeleteAgent._get_http_options() + request, metadata = self._interceptor.pre_delete_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseDeleteAgent._get_transcoded_request( @@ -636,6 +675,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.dialogflow_v2.AgentsClient.DeleteAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "DeleteAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._DeleteAgent._get_response( self._host, @@ -684,7 +750,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export agent method over HTTP. @@ -695,8 +761,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: ~.operations_pb2.Operation: @@ -707,6 +775,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseExportAgent._get_http_options() + request, metadata = self._interceptor.pre_export_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseExportAgent._get_transcoded_request( @@ -725,6 +794,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.dialogflow_v2.AgentsClient.ExportAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ExportAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ExportAgent._get_response( self._host, @@ -744,7 +840,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_agent(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.dialogflow_v2.AgentsClient.export_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ExportAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAgent(_BaseAgentsRestTransport._BaseGetAgent, AgentsRestStub): @@ -779,7 +897,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]]] = (), ) -> agent.Agent: r"""Call the get agent method over HTTP. @@ -790,8 +908,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: ~.agent.Agent: @@ -811,6 +931,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseGetAgent._get_http_options() + request, metadata = self._interceptor.pre_get_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetAgent._get_transcoded_request( @@ -825,6 +946,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.dialogflow_v2.AgentsClient.GetAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetAgent._get_response( self._host, @@ -845,7 +993,29 @@ def __call__( pb_resp = agent.Agent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_agent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = agent.Agent.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.dialogflow_v2.AgentsClient.get_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetValidationResult( @@ -882,7 +1052,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]]] = (), ) -> validation_result.ValidationResult: r"""Call the get validation result method over HTTP. @@ -893,8 +1063,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: ~.validation_result.ValidationResult: @@ -906,6 +1078,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseGetValidationResult._get_http_options() ) + request, metadata = self._interceptor.pre_get_validation_result( request, metadata ) @@ -918,6 +1091,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 = 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.dialogflow_v2.AgentsClient.GetValidationResult", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetValidationResult", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetValidationResult._get_response( self._host, @@ -938,7 +1138,31 @@ def __call__( pb_resp = validation_result.ValidationResult.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_validation_result(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = validation_result.ValidationResult.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.dialogflow_v2.AgentsClient.get_validation_result", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetValidationResult", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAgent(_BaseAgentsRestTransport._BaseImportAgent, AgentsRestStub): @@ -974,7 +1198,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import agent method over HTTP. @@ -985,8 +1209,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: ~.operations_pb2.Operation: @@ -997,6 +1223,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseImportAgent._get_http_options() + request, metadata = self._interceptor.pre_import_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseImportAgent._get_transcoded_request( @@ -1015,6 +1242,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.dialogflow_v2.AgentsClient.ImportAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ImportAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ImportAgent._get_response( self._host, @@ -1034,7 +1288,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_agent(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.dialogflow_v2.AgentsClient.import_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ImportAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreAgent(_BaseAgentsRestTransport._BaseRestoreAgent, AgentsRestStub): @@ -1070,7 +1346,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]]] = (), ) -> operations_pb2.Operation: r"""Call the restore agent method over HTTP. @@ -1081,8 +1357,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: ~.operations_pb2.Operation: @@ -1095,6 +1373,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseRestoreAgent._get_http_options() ) + request, metadata = self._interceptor.pre_restore_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseRestoreAgent._get_transcoded_request( @@ -1113,6 +1392,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.dialogflow_v2.AgentsClient.RestoreAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "RestoreAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._RestoreAgent._get_response( self._host, @@ -1132,7 +1438,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_agent(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.dialogflow_v2.AgentsClient.restore_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "RestoreAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAgents(_BaseAgentsRestTransport._BaseSearchAgents, AgentsRestStub): @@ -1167,7 +1495,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]]] = (), ) -> agent.SearchAgentsResponse: r"""Call the search agents method over HTTP. @@ -1178,8 +1506,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: ~.agent.SearchAgentsResponse: @@ -1191,6 +1521,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseSearchAgents._get_http_options() ) + request, metadata = self._interceptor.pre_search_agents(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseSearchAgents._get_transcoded_request( @@ -1205,6 +1536,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.dialogflow_v2.AgentsClient.SearchAgents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "SearchAgents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._SearchAgents._get_response( self._host, @@ -1225,7 +1583,29 @@ def __call__( pb_resp = agent.SearchAgentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_agents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = agent.SearchAgentsResponse.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.dialogflow_v2.AgentsClient.search_agents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "SearchAgents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetAgent(_BaseAgentsRestTransport._BaseSetAgent, AgentsRestStub): @@ -1261,7 +1641,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]]] = (), ) -> gcd_agent.Agent: r"""Call the set agent method over HTTP. @@ -1272,8 +1652,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: ~.gcd_agent.Agent: @@ -1293,6 +1675,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseSetAgent._get_http_options() + request, metadata = self._interceptor.pre_set_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseSetAgent._get_transcoded_request( @@ -1311,6 +1694,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.dialogflow_v2.AgentsClient.SetAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "SetAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._SetAgent._get_response( self._host, @@ -1332,7 +1742,29 @@ def __call__( pb_resp = gcd_agent.Agent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_agent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_agent.Agent.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.dialogflow_v2.AgentsClient.set_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "SetAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TrainAgent(_BaseAgentsRestTransport._BaseTrainAgent, AgentsRestStub): @@ -1368,7 +1800,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]]] = (), ) -> operations_pb2.Operation: r"""Call the train agent method over HTTP. @@ -1379,8 +1811,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: ~.operations_pb2.Operation: @@ -1391,6 +1825,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseTrainAgent._get_http_options() + request, metadata = self._interceptor.pre_train_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseTrainAgent._get_transcoded_request( @@ -1409,6 +1844,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.dialogflow_v2.AgentsClient.TrainAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "TrainAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._TrainAgent._get_response( self._host, @@ -1428,7 +1890,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_train_agent(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.dialogflow_v2.AgentsClient.train_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "TrainAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1535,7 +2019,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. @@ -1545,14 +2029,17 @@ 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. """ http_options = _BaseAgentsRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1567,6 +2054,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.dialogflow_v2.AgentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetLocation._get_response( self._host, @@ -1586,6 +2100,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.dialogflow_v2.AgentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1624,7 +2159,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. @@ -1634,8 +2169,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. @@ -1644,6 +2181,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1658,6 +2196,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.dialogflow_v2.AgentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ListLocations._get_response( self._host, @@ -1677,6 +2242,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.dialogflow_v2.AgentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1717,7 +2303,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1727,13 +2313,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 = ( _BaseAgentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1750,6 +2339,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.dialogflow_v2.AgentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._CancelOperation._get_response( self._host, @@ -1803,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1813,8 +2429,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: operations_pb2.Operation: Response from GetOperation method. @@ -1823,6 +2441,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1837,6 +2456,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.dialogflow_v2.AgentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetOperation._get_response( self._host, @@ -1856,6 +2502,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.AgentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1894,7 +2561,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1904,8 +2571,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1914,6 +2583,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1928,6 +2598,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.dialogflow_v2.AgentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ListOperations._get_response( self._host, @@ -1947,6 +2644,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.AgentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Agents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/async_client.py index 6b1df1e03bac..cbea235d28e8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport from .transports.grpc_asyncio import AnswerRecordsGrpcAsyncIOTransport +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 AnswerRecordsAsyncClient: """Service for managing @@ -267,6 +277,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.dialogflow_v2.AnswerRecordsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "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.dialogflow.v2.AnswerRecords", + "credentialsType": None, + }, + ) + async def list_answer_records( self, request: Optional[Union[answer_record.ListAnswerRecordsRequest, dict]] = None, @@ -274,7 +306,7 @@ async def list_answer_records( 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.ListAnswerRecordsAsyncPager: r"""Returns the list of all answer records in the specified project in reverse chronological order. @@ -321,8 +353,10 @@ async def sample_list_answer_records(): 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.dialogflow_v2.services.answer_records.pagers.ListAnswerRecordsAsyncPager: @@ -400,7 +434,7 @@ async def update_answer_record( 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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Updates the specified answer record. @@ -448,8 +482,10 @@ async def sample_update_answer_record(): 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.dialogflow_v2.types.AnswerRecord: @@ -484,9 +520,10 @@ async def sample_update_answer_record(): 2. The customer uses the [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name] - to call the [UpdateAnswerRecord][] method to send - feedback about a specific answer that they believe is - wrong. + to call the + [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord] + method to send feedback about a specific answer that + they believe is wrong. """ # Create or coerce a protobuf request object. @@ -545,7 +582,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -556,8 +593,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -598,7 +637,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -609,8 +648,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -651,7 +692,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -666,8 +707,10 @@ async def cancel_operation( 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: None """ @@ -704,7 +747,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. @@ -715,8 +758,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. @@ -757,7 +802,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. @@ -768,8 +813,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-dialogflow/google/cloud/dialogflow_v2/services/answer_records/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/client.py index a46c15f776e1..92520ab73796 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -619,6 +629,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( @@ -684,6 +698,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.dialogflow_v2.AnswerRecordsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "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.dialogflow.v2.AnswerRecords", + "credentialsType": None, + }, + ) + def list_answer_records( self, request: Optional[Union[answer_record.ListAnswerRecordsRequest, dict]] = None, @@ -691,7 +728,7 @@ def list_answer_records( 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.ListAnswerRecordsPager: r"""Returns the list of all answer records in the specified project in reverse chronological order. @@ -738,8 +775,10 @@ def sample_list_answer_records(): 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.dialogflow_v2.services.answer_records.pagers.ListAnswerRecordsPager: @@ -814,7 +853,7 @@ def update_answer_record( 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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Updates the specified answer record. @@ -862,8 +901,10 @@ def sample_update_answer_record(): 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.dialogflow_v2.types.AnswerRecord: @@ -898,9 +939,10 @@ def sample_update_answer_record(): 2. The customer uses the [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name] - to call the [UpdateAnswerRecord][] method to send - feedback about a specific answer that they believe is - wrong. + to call the + [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord] + method to send feedback about a specific answer that + they believe is wrong. """ # Create or coerce a protobuf request object. @@ -969,7 +1011,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -980,8 +1022,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1022,7 +1066,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1033,8 +1077,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1075,7 +1121,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1090,8 +1136,10 @@ def cancel_operation( 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: None """ @@ -1128,7 +1176,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. @@ -1139,8 +1187,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. @@ -1181,7 +1231,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. @@ -1192,8 +1242,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-dialogflow/google/cloud/dialogflow_v2/services/answer_records/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/pagers.py index 3e85aa8403aa..5b7f8ece22ad 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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 = answer_record.ListAnswerRecordsRequest(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 = answer_record.ListAnswerRecordsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py index 53b1d9ab3619..684f775a3fc1 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import answer_record from google.cloud.dialogflow_v2.types import answer_record as gcd_answer_record from .base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport +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.dialogflow.v2.AnswerRecords", + "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.dialogflow.v2.AnswerRecords", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnswerRecordsGrpcTransport(AnswerRecordsTransport): """gRPC backend transport for AnswerRecords. @@ -183,7 +264,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 @@ -261,7 +347,7 @@ def list_answer_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_answer_records" not in self._stubs: - self._stubs["list_answer_records"] = self.grpc_channel.unary_unary( + self._stubs["list_answer_records"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.AnswerRecords/ListAnswerRecords", request_serializer=answer_record.ListAnswerRecordsRequest.serialize, response_deserializer=answer_record.ListAnswerRecordsResponse.deserialize, @@ -289,7 +375,7 @@ def update_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_answer_record" not in self._stubs: - self._stubs["update_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["update_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.AnswerRecords/UpdateAnswerRecord", request_serializer=gcd_answer_record.UpdateAnswerRecordRequest.serialize, response_deserializer=gcd_answer_record.AnswerRecord.deserialize, @@ -297,7 +383,7 @@ def update_answer_record( return self._stubs["update_answer_record"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -309,7 +395,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -326,7 +412,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -345,7 +431,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -364,7 +450,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, @@ -381,7 +467,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-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py index d6b2484123ad..24455b7c64a7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import answer_record from google.cloud.dialogflow_v2.types import answer_record as gcd_answer_record @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport from .grpc import AnswerRecordsGrpcTransport +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.dialogflow.v2.AnswerRecords", + "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.dialogflow.v2.AnswerRecords", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnswerRecordsGrpcAsyncIOTransport(AnswerRecordsTransport): """gRPC AsyncIO backend transport for AnswerRecords. @@ -230,10 +312,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 @@ -269,7 +354,7 @@ def list_answer_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_answer_records" not in self._stubs: - self._stubs["list_answer_records"] = self.grpc_channel.unary_unary( + self._stubs["list_answer_records"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.AnswerRecords/ListAnswerRecords", request_serializer=answer_record.ListAnswerRecordsRequest.serialize, response_deserializer=answer_record.ListAnswerRecordsResponse.deserialize, @@ -298,7 +383,7 @@ def update_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_answer_record" not in self._stubs: - self._stubs["update_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["update_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.AnswerRecords/UpdateAnswerRecord", request_serializer=gcd_answer_record.UpdateAnswerRecordRequest.serialize, response_deserializer=gcd_answer_record.AnswerRecord.deserialize, @@ -351,7 +436,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: @@ -367,7 +452,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -384,7 +469,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -403,7 +488,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -422,7 +507,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, @@ -439,7 +524,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-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py index 96620ea69732..b9598bf7bd94 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/answer_records/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 @@ -40,6 +40,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, @@ -88,8 +96,10 @@ def post_update_answer_record(self, response): def pre_list_answer_records( self, request: answer_record.ListAnswerRecordsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[answer_record.ListAnswerRecordsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + answer_record.ListAnswerRecordsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_answer_records Override in a subclass to manipulate the request or metadata @@ -111,8 +121,11 @@ def post_list_answer_records( def pre_update_answer_record( self, request: gcd_answer_record.UpdateAnswerRecordRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_answer_record.UpdateAnswerRecordRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_answer_record.UpdateAnswerRecordRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_answer_record Override in a subclass to manipulate the request or metadata @@ -134,8 +147,10 @@ def post_update_answer_record( 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 @@ -157,8 +172,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 @@ -180,8 +197,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -201,8 +220,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -224,8 +245,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -366,7 +389,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]]] = (), ) -> answer_record.ListAnswerRecordsResponse: r"""Call the list answer records method over HTTP. @@ -377,8 +400,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: ~.answer_record.ListAnswerRecordsResponse: @@ -390,6 +415,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListAnswerRecords._get_http_options() ) + request, metadata = self._interceptor.pre_list_answer_records( request, metadata ) @@ -402,6 +428,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 = 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.dialogflow_v2.AnswerRecordsClient.ListAnswerRecords", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListAnswerRecords", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListAnswerRecords._get_response( self._host, @@ -422,7 +475,31 @@ def __call__( pb_resp = answer_record.ListAnswerRecordsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_answer_records(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = answer_record.ListAnswerRecordsResponse.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.dialogflow_v2.AnswerRecordsClient.list_answer_records", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListAnswerRecords", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnswerRecord( @@ -460,7 +537,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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Call the update answer record method over HTTP. @@ -471,8 +548,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: ~.gcd_answer_record.AnswerRecord: @@ -504,15 +583,17 @@ def __call__( are returned to the customers. 2. The customer uses the [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name] - to call the [UpdateAnswerRecord][] method to send - feedback about a specific answer that they believe is - wrong. + to call the + [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord] + method to send feedback about a specific answer that + they believe is wrong. """ http_options = ( _BaseAnswerRecordsRestTransport._BaseUpdateAnswerRecord._get_http_options() ) + request, metadata = self._interceptor.pre_update_answer_record( request, metadata ) @@ -529,6 +610,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 = 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.dialogflow_v2.AnswerRecordsClient.UpdateAnswerRecord", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "UpdateAnswerRecord", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._UpdateAnswerRecord._get_response( self._host, @@ -550,7 +658,29 @@ def __call__( pb_resp = gcd_answer_record.AnswerRecord.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_answer_record(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_answer_record.AnswerRecord.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.dialogflow_v2.AnswerRecordsClient.update_answer_record", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "UpdateAnswerRecord", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -612,7 +742,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. @@ -622,8 +752,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. @@ -632,6 +764,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -644,6 +777,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.dialogflow_v2.AnswerRecordsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._GetLocation._get_response( self._host, @@ -663,6 +823,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.dialogflow_v2.AnswerRecordsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -703,7 +884,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. @@ -713,8 +894,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. @@ -723,6 +906,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -733,6 +917,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.dialogflow_v2.AnswerRecordsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListLocations._get_response( self._host, @@ -752,6 +963,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.dialogflow_v2.AnswerRecordsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -792,7 +1024,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -802,13 +1034,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 = ( _BaseAnswerRecordsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -821,6 +1056,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.dialogflow_v2.AnswerRecordsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._CancelOperation._get_response( self._host, @@ -876,7 +1138,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -886,8 +1148,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: operations_pb2.Operation: Response from GetOperation method. @@ -896,6 +1160,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -906,6 +1171,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.dialogflow_v2.AnswerRecordsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._GetOperation._get_response( self._host, @@ -925,6 +1217,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.AnswerRecordsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -965,7 +1278,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -975,8 +1288,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -985,6 +1300,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -995,6 +1311,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.dialogflow_v2.AnswerRecordsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListOperations._get_response( self._host, @@ -1014,6 +1357,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.AnswerRecordsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.AnswerRecords", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/async_client.py index 6c4ed8d22542..e501adb09dda 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ContextsTransport from .transports.grpc_asyncio import ContextsGrpcAsyncIOTransport +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 ContextsAsyncClient: """Service for managing [Contexts][google.cloud.dialogflow.v2.Context].""" @@ -252,6 +262,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.dialogflow_v2.ContextsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "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.dialogflow.v2.Contexts", + "credentialsType": None, + }, + ) + async def list_contexts( self, request: Optional[Union[context.ListContextsRequest, dict]] = None, @@ -259,7 +291,7 @@ async def list_contexts( 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.ListContextsAsyncPager: r"""Returns the list of all contexts in the specified session. @@ -309,8 +341,10 @@ async def sample_list_contexts(): 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.dialogflow_v2.services.contexts.pagers.ListContextsAsyncPager: @@ -385,7 +419,7 @@ async def get_context( 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]]] = (), ) -> context.Context: r"""Retrieves the specified context. @@ -434,8 +468,10 @@ async def sample_get_context(): 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.dialogflow_v2.types.Context: @@ -514,7 +550,7 @@ async def create_context( context: Optional[gcd_context.Context] = 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]]] = (), ) -> gcd_context.Context: r"""Creates a context. @@ -574,8 +610,10 @@ async def sample_create_context(): 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.dialogflow_v2.types.Context: @@ -656,7 +694,7 @@ async def update_context( 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]]] = (), ) -> gcd_context.Context: r"""Updates the specified context. @@ -708,8 +746,10 @@ async def sample_update_context(): 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.dialogflow_v2.types.Context: @@ -791,7 +831,7 @@ async def delete_context( 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 the specified context. @@ -837,8 +877,10 @@ async def sample_delete_context(): 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 delete_all_contexts( 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]]] = (), ) -> None: r"""Deletes all active contexts in the specified session. @@ -936,8 +978,10 @@ async def sample_delete_all_contexts(): 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 @@ -988,7 +1032,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -999,8 +1043,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1041,7 +1087,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1052,8 +1098,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1094,7 +1142,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1109,8 +1157,10 @@ async def cancel_operation( 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: None """ @@ -1147,7 +1197,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. @@ -1158,8 +1208,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. @@ -1200,7 +1252,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. @@ -1211,8 +1263,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-dialogflow/google/cloud/dialogflow_v2/services/contexts/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/client.py index 23588a58a03a..5139b72d4d72 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -582,6 +592,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( @@ -644,6 +658,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.dialogflow_v2.ContextsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "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.dialogflow.v2.Contexts", + "credentialsType": None, + }, + ) + def list_contexts( self, request: Optional[Union[context.ListContextsRequest, dict]] = None, @@ -651,7 +688,7 @@ def list_contexts( 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.ListContextsPager: r"""Returns the list of all contexts in the specified session. @@ -701,8 +738,10 @@ def sample_list_contexts(): 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.dialogflow_v2.services.contexts.pagers.ListContextsPager: @@ -774,7 +813,7 @@ def get_context( 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]]] = (), ) -> context.Context: r"""Retrieves the specified context. @@ -823,8 +862,10 @@ def sample_get_context(): 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.dialogflow_v2.types.Context: @@ -900,7 +941,7 @@ def create_context( context: Optional[gcd_context.Context] = 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]]] = (), ) -> gcd_context.Context: r"""Creates a context. @@ -960,8 +1001,10 @@ def sample_create_context(): 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.dialogflow_v2.types.Context: @@ -1039,7 +1082,7 @@ def update_context( 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]]] = (), ) -> gcd_context.Context: r"""Updates the specified context. @@ -1091,8 +1134,10 @@ def sample_update_context(): 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.dialogflow_v2.types.Context: @@ -1171,7 +1216,7 @@ def delete_context( 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 the specified context. @@ -1217,8 +1262,10 @@ def sample_delete_context(): 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 @@ -1267,7 +1314,7 @@ def delete_all_contexts( 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]]] = (), ) -> None: r"""Deletes all active contexts in the specified session. @@ -1313,8 +1360,10 @@ def sample_delete_all_contexts(): 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 @@ -1375,7 +1424,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1386,8 +1435,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1428,7 +1479,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1439,8 +1490,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1481,7 +1534,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1496,8 +1549,10 @@ def cancel_operation( 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: None """ @@ -1534,7 +1589,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. @@ -1545,8 +1600,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. @@ -1587,7 +1644,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. @@ -1598,8 +1655,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-dialogflow/google/cloud/dialogflow_v2/services/contexts/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/pagers.py index e93b04a93082..c449b5060664 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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 = context.ListContextsRequest(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 = context.ListContextsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py index 91faa555bdad..d01da09470c9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import context from google.cloud.dialogflow_v2.types import context as gcd_context from .base import DEFAULT_CLIENT_INFO, ContextsTransport +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.dialogflow.v2.Contexts", + "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.dialogflow.v2.Contexts", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ContextsGrpcTransport(ContextsTransport): """gRPC backend transport for Contexts. @@ -183,7 +264,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 @@ -258,7 +344,7 @@ def list_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_contexts" not in self._stubs: - self._stubs["list_contexts"] = self.grpc_channel.unary_unary( + self._stubs["list_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/ListContexts", request_serializer=context.ListContextsRequest.serialize, response_deserializer=context.ListContextsResponse.deserialize, @@ -282,7 +368,7 @@ def get_context(self) -> Callable[[context.GetContextRequest], context.Context]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_context" not in self._stubs: - self._stubs["get_context"] = self.grpc_channel.unary_unary( + self._stubs["get_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/GetContext", request_serializer=context.GetContextRequest.serialize, response_deserializer=context.Context.deserialize, @@ -311,7 +397,7 @@ def create_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_context" not in self._stubs: - self._stubs["create_context"] = self.grpc_channel.unary_unary( + self._stubs["create_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/CreateContext", request_serializer=gcd_context.CreateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -337,7 +423,7 @@ def update_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_context" not in self._stubs: - self._stubs["update_context"] = self.grpc_channel.unary_unary( + self._stubs["update_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/UpdateContext", request_serializer=gcd_context.UpdateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -363,7 +449,7 @@ def delete_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_context" not in self._stubs: - self._stubs["delete_context"] = self.grpc_channel.unary_unary( + self._stubs["delete_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/DeleteContext", request_serializer=context.DeleteContextRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -389,7 +475,7 @@ def delete_all_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_all_contexts" not in self._stubs: - self._stubs["delete_all_contexts"] = self.grpc_channel.unary_unary( + self._stubs["delete_all_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/DeleteAllContexts", request_serializer=context.DeleteAllContextsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -397,7 +483,7 @@ def delete_all_contexts( return self._stubs["delete_all_contexts"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -409,7 +495,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -426,7 +512,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -445,7 +531,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -464,7 +550,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, @@ -481,7 +567,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-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py index 4821916a1be5..0e10407284d9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import context from google.cloud.dialogflow_v2.types import context as gcd_context @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, ContextsTransport from .grpc import ContextsGrpcTransport +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.dialogflow.v2.Contexts", + "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.dialogflow.v2.Contexts", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ContextsGrpcAsyncIOTransport(ContextsTransport): """gRPC AsyncIO backend transport for Contexts. @@ -230,10 +312,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 @@ -268,7 +353,7 @@ def list_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_contexts" not in self._stubs: - self._stubs["list_contexts"] = self.grpc_channel.unary_unary( + self._stubs["list_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/ListContexts", request_serializer=context.ListContextsRequest.serialize, response_deserializer=context.ListContextsResponse.deserialize, @@ -294,7 +379,7 @@ def get_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_context" not in self._stubs: - self._stubs["get_context"] = self.grpc_channel.unary_unary( + self._stubs["get_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/GetContext", request_serializer=context.GetContextRequest.serialize, response_deserializer=context.Context.deserialize, @@ -323,7 +408,7 @@ def create_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_context" not in self._stubs: - self._stubs["create_context"] = self.grpc_channel.unary_unary( + self._stubs["create_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/CreateContext", request_serializer=gcd_context.CreateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -349,7 +434,7 @@ def update_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_context" not in self._stubs: - self._stubs["update_context"] = self.grpc_channel.unary_unary( + self._stubs["update_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/UpdateContext", request_serializer=gcd_context.UpdateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -375,7 +460,7 @@ def delete_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_context" not in self._stubs: - self._stubs["delete_context"] = self.grpc_channel.unary_unary( + self._stubs["delete_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/DeleteContext", request_serializer=context.DeleteContextRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -401,7 +486,7 @@ def delete_all_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_all_contexts" not in self._stubs: - self._stubs["delete_all_contexts"] = self.grpc_channel.unary_unary( + self._stubs["delete_all_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Contexts/DeleteAllContexts", request_serializer=context.DeleteAllContextsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -474,7 +559,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: @@ -490,7 +575,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -507,7 +592,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -526,7 +611,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -545,7 +630,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, @@ -562,7 +647,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-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/rest.py index a0e4f81a1593..9d7803ecae3c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/contexts/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 @@ -41,6 +41,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, @@ -113,8 +121,10 @@ def post_update_context(self, response): def pre_create_context( self, request: gcd_context.CreateContextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_context.CreateContextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_context.CreateContextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_context Override in a subclass to manipulate the request or metadata @@ -134,8 +144,10 @@ def post_create_context(self, response: gcd_context.Context) -> gcd_context.Cont def pre_delete_all_contexts( self, request: context.DeleteAllContextsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[context.DeleteAllContextsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + context.DeleteAllContextsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_all_contexts Override in a subclass to manipulate the request or metadata @@ -144,8 +156,10 @@ def pre_delete_all_contexts( return request, metadata def pre_delete_context( - self, request: context.DeleteContextRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.DeleteContextRequest, Sequence[Tuple[str, str]]]: + self, + request: context.DeleteContextRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.DeleteContextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_context Override in a subclass to manipulate the request or metadata @@ -154,8 +168,10 @@ def pre_delete_context( return request, metadata def pre_get_context( - self, request: context.GetContextRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.GetContextRequest, Sequence[Tuple[str, str]]]: + self, + request: context.GetContextRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.GetContextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_context Override in a subclass to manipulate the request or metadata @@ -173,8 +189,10 @@ def post_get_context(self, response: context.Context) -> context.Context: return response def pre_list_contexts( - self, request: context.ListContextsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.ListContextsRequest, Sequence[Tuple[str, str]]]: + self, + request: context.ListContextsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.ListContextsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_contexts Override in a subclass to manipulate the request or metadata @@ -196,8 +214,10 @@ def post_list_contexts( def pre_update_context( self, request: gcd_context.UpdateContextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_context.UpdateContextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_context.UpdateContextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_context Override in a subclass to manipulate the request or metadata @@ -217,8 +237,10 @@ def post_update_context(self, response: gcd_context.Context) -> gcd_context.Cont 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 @@ -240,8 +262,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 @@ -263,8 +287,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -284,8 +310,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -307,8 +335,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -449,7 +479,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]]] = (), ) -> gcd_context.Context: r"""Call the create context method over HTTP. @@ -460,8 +490,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: ~.gcd_context.Context: @@ -490,6 +522,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseCreateContext._get_http_options() ) + request, metadata = self._interceptor.pre_create_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseCreateContext._get_transcoded_request( @@ -508,6 +541,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.dialogflow_v2.ContextsClient.CreateContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "CreateContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._CreateContext._get_response( self._host, @@ -529,7 +589,29 @@ def __call__( pb_resp = gcd_context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_context.Context.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.dialogflow_v2.ContextsClient.create_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "CreateContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAllContexts( @@ -566,7 +648,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 all contexts method over HTTP. @@ -577,13 +659,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 = ( _BaseContextsRestTransport._BaseDeleteAllContexts._get_http_options() ) + request, metadata = self._interceptor.pre_delete_all_contexts( request, metadata ) @@ -596,6 +681,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.dialogflow_v2.ContextsClient.DeleteAllContexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "DeleteAllContexts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._DeleteAllContexts._get_response( self._host, @@ -645,7 +757,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 context method over HTTP. @@ -656,13 +768,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 = ( _BaseContextsRestTransport._BaseDeleteContext._get_http_options() ) + request, metadata = self._interceptor.pre_delete_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseDeleteContext._get_transcoded_request( @@ -677,6 +792,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.dialogflow_v2.ContextsClient.DeleteContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "DeleteContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._DeleteContext._get_response( self._host, @@ -724,7 +866,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]]] = (), ) -> context.Context: r"""Call the get context method over HTTP. @@ -735,8 +877,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: ~.context.Context: @@ -765,6 +909,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetContext._get_http_options() ) + request, metadata = self._interceptor.pre_get_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetContext._get_transcoded_request( @@ -779,6 +924,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.dialogflow_v2.ContextsClient.GetContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetContext._get_response( self._host, @@ -799,7 +971,29 @@ def __call__( pb_resp = context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = context.Context.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.dialogflow_v2.ContextsClient.get_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListContexts(_BaseContextsRestTransport._BaseListContexts, ContextsRestStub): @@ -834,7 +1028,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]]] = (), ) -> context.ListContextsResponse: r"""Call the list contexts method over HTTP. @@ -845,8 +1039,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: ~.context.ListContextsResponse: @@ -858,6 +1054,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListContexts._get_http_options() ) + request, metadata = self._interceptor.pre_list_contexts(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListContexts._get_transcoded_request( @@ -872,6 +1069,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.dialogflow_v2.ContextsClient.ListContexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListContexts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListContexts._get_response( self._host, @@ -892,7 +1116,29 @@ def __call__( pb_resp = context.ListContextsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_contexts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = context.ListContextsResponse.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.dialogflow_v2.ContextsClient.list_contexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListContexts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateContext( @@ -930,7 +1176,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]]] = (), ) -> gcd_context.Context: r"""Call the update context method over HTTP. @@ -941,8 +1187,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: ~.gcd_context.Context: @@ -971,6 +1219,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseUpdateContext._get_http_options() ) + request, metadata = self._interceptor.pre_update_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseUpdateContext._get_transcoded_request( @@ -989,6 +1238,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.dialogflow_v2.ContextsClient.UpdateContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "UpdateContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._UpdateContext._get_response( self._host, @@ -1010,7 +1286,29 @@ def __call__( pb_resp = gcd_context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_context.Context.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.dialogflow_v2.ContextsClient.update_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "UpdateContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1095,7 +1393,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. @@ -1105,8 +1403,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. @@ -1115,6 +1415,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1129,6 +1430,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.dialogflow_v2.ContextsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetLocation._get_response( self._host, @@ -1148,6 +1476,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.dialogflow_v2.ContextsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1188,7 +1537,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. @@ -1198,8 +1547,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. @@ -1208,6 +1559,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListLocations._get_transcoded_request( @@ -1222,6 +1574,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.dialogflow_v2.ContextsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListLocations._get_response( self._host, @@ -1241,6 +1620,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.dialogflow_v2.ContextsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1281,7 +1681,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1291,13 +1691,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 = ( _BaseContextsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1314,6 +1717,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.dialogflow_v2.ContextsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._CancelOperation._get_response( self._host, @@ -1367,7 +1797,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1377,8 +1807,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: operations_pb2.Operation: Response from GetOperation method. @@ -1387,6 +1819,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1401,6 +1834,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.dialogflow_v2.ContextsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetOperation._get_response( self._host, @@ -1420,6 +1880,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ContextsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1460,7 +1941,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1470,8 +1951,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1480,6 +1963,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListOperations._get_transcoded_request( @@ -1494,6 +1978,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.dialogflow_v2.ContextsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListOperations._get_response( self._host, @@ -1513,6 +2024,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ContextsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Contexts", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py index 390b0235f1e0..5d06a472cb1b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ConversationDatasetsTransport from .transports.grpc_asyncio import ConversationDatasetsGrpcAsyncIOTransport +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 ConversationDatasetsAsyncClient: """Conversation datasets. @@ -276,6 +286,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.dialogflow_v2.ConversationDatasetsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "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.dialogflow.v2.ConversationDatasets", + "credentialsType": None, + }, + ) + async def create_conversation_dataset( self, request: Optional[ @@ -288,7 +320,7 @@ async def create_conversation_dataset( ] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new conversation dataset. @@ -358,8 +390,10 @@ async def sample_create_conversation_dataset(): 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.api_core.operation_async.AsyncOperation: @@ -439,7 +473,7 @@ async def get_conversation_dataset( 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]]] = (), ) -> conversation_dataset.ConversationDataset: r"""Retrieves the specified conversation dataset. @@ -483,8 +517,10 @@ async def sample_get_conversation_dataset(): 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.dialogflow_v2.types.ConversationDataset: @@ -552,7 +588,7 @@ async def list_conversation_datasets( 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.ListConversationDatasetsAsyncPager: r"""Returns the list of all conversation datasets in the specified project and location. @@ -599,8 +635,10 @@ async def sample_list_conversation_datasets(): 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.dialogflow_v2.services.conversation_datasets.pagers.ListConversationDatasetsAsyncPager: @@ -679,7 +717,7 @@ async def delete_conversation_dataset( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified conversation dataset. @@ -737,8 +775,10 @@ async def sample_delete_conversation_dataset(): 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.api_core.operation_async.AsyncOperation: @@ -820,7 +860,7 @@ async def import_conversation_data( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Import data into the specified conversation dataset. Note that it is not allowed to import data to a conversation dataset that @@ -877,8 +917,10 @@ async def sample_import_conversation_data(): 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.api_core.operation_async.AsyncOperation: @@ -935,7 +977,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -946,8 +988,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -988,7 +1032,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -999,8 +1043,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1041,7 +1087,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1056,8 +1102,10 @@ async def cancel_operation( 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: None """ @@ -1094,7 +1142,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. @@ -1105,8 +1153,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. @@ -1147,7 +1197,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. @@ -1158,8 +1208,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/client.py index dcf6ae69a923..27c1cf586101 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -596,6 +606,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( @@ -662,6 +676,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.dialogflow_v2.ConversationDatasetsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "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.dialogflow.v2.ConversationDatasets", + "credentialsType": None, + }, + ) + def create_conversation_dataset( self, request: Optional[ @@ -674,7 +711,7 @@ def create_conversation_dataset( ] = 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]]] = (), ) -> operation.Operation: r"""Creates a new conversation dataset. @@ -744,8 +781,10 @@ def sample_create_conversation_dataset(): 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.api_core.operation.Operation: @@ -824,7 +863,7 @@ def get_conversation_dataset( 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]]] = (), ) -> conversation_dataset.ConversationDataset: r"""Retrieves the specified conversation dataset. @@ -868,8 +907,10 @@ def sample_get_conversation_dataset(): 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.dialogflow_v2.types.ConversationDataset: @@ -934,7 +975,7 @@ def list_conversation_datasets( 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.ListConversationDatasetsPager: r"""Returns the list of all conversation datasets in the specified project and location. @@ -981,8 +1022,10 @@ def sample_list_conversation_datasets(): 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.dialogflow_v2.services.conversation_datasets.pagers.ListConversationDatasetsPager: @@ -1060,7 +1103,7 @@ def delete_conversation_dataset( 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]]] = (), ) -> operation.Operation: r"""Deletes the specified conversation dataset. @@ -1118,8 +1161,10 @@ def sample_delete_conversation_dataset(): 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.api_core.operation.Operation: @@ -1200,7 +1245,7 @@ def import_conversation_data( *, 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]]] = (), ) -> operation.Operation: r"""Import data into the specified conversation dataset. Note that it is not allowed to import data to a conversation dataset that @@ -1257,8 +1302,10 @@ def sample_import_conversation_data(): 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.api_core.operation.Operation: @@ -1326,7 +1373,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1337,8 +1384,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1379,7 +1428,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1390,8 +1439,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1432,7 +1483,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1447,8 +1498,10 @@ def cancel_operation( 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: None """ @@ -1485,7 +1538,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. @@ -1496,8 +1549,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. @@ -1538,7 +1593,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. @@ -1549,8 +1604,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/pagers.py index 249fa23d7fbe..95d542614b3a 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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 = conversation_dataset.ListConversationDatasetsRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = conversation_dataset.ListConversationDatasetsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py index 88b7509c96bb..7c906963d050 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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 @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_dataset as gcd_conversation_dataset, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ConversationDatasetsTransport +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.dialogflow.v2.ConversationDatasets", + "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.dialogflow.v2.ConversationDatasets", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationDatasetsGrpcTransport(ConversationDatasetsTransport): """gRPC backend transport for ConversationDatasets. @@ -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 @@ -252,7 +338,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -289,7 +377,9 @@ def create_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_dataset" not in self._stubs: - self._stubs["create_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/CreateConversationDataset", request_serializer=gcd_conversation_dataset.CreateConversationDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -318,7 +408,7 @@ def get_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_dataset" not in self._stubs: - self._stubs["get_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_dataset"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/GetConversationDataset", request_serializer=conversation_dataset.GetConversationDatasetRequest.serialize, response_deserializer=conversation_dataset.ConversationDataset.deserialize, @@ -348,7 +438,9 @@ def list_conversation_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_datasets" not in self._stubs: - self._stubs["list_conversation_datasets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_datasets" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/ListConversationDatasets", request_serializer=conversation_dataset.ListConversationDatasetsRequest.serialize, response_deserializer=conversation_dataset.ListConversationDatasetsResponse.deserialize, @@ -387,7 +479,9 @@ def delete_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_dataset" not in self._stubs: - self._stubs["delete_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/DeleteConversationDataset", request_serializer=conversation_dataset.DeleteConversationDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +521,7 @@ def import_conversation_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_conversation_data" not in self._stubs: - self._stubs["import_conversation_data"] = self.grpc_channel.unary_unary( + self._stubs["import_conversation_data"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/ImportConversationData", request_serializer=conversation_dataset.ImportConversationDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -435,7 +529,7 @@ def import_conversation_data( return self._stubs["import_conversation_data"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -447,7 +541,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -464,7 +558,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -483,7 +577,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -502,7 +596,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, @@ -519,7 +613,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py index 2b4c74ae90d7..3bb7ab1597e0 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_dataset as gcd_conversation_dataset, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationDatasetsTransport from .grpc import ConversationDatasetsGrpcTransport +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.dialogflow.v2.ConversationDatasets", + "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.dialogflow.v2.ConversationDatasets", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationDatasetsGrpcAsyncIOTransport(ConversationDatasetsTransport): """gRPC AsyncIO backend transport for ConversationDatasets. @@ -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 @@ -261,7 +346,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -299,7 +384,9 @@ def create_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_dataset" not in self._stubs: - self._stubs["create_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/CreateConversationDataset", request_serializer=gcd_conversation_dataset.CreateConversationDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -328,7 +415,7 @@ def get_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_dataset" not in self._stubs: - self._stubs["get_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_dataset"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/GetConversationDataset", request_serializer=conversation_dataset.GetConversationDatasetRequest.serialize, response_deserializer=conversation_dataset.ConversationDataset.deserialize, @@ -358,7 +445,9 @@ def list_conversation_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_datasets" not in self._stubs: - self._stubs["list_conversation_datasets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_datasets" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/ListConversationDatasets", request_serializer=conversation_dataset.ListConversationDatasetsRequest.serialize, response_deserializer=conversation_dataset.ListConversationDatasetsResponse.deserialize, @@ -397,7 +486,9 @@ def delete_conversation_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_dataset" not in self._stubs: - self._stubs["delete_conversation_dataset"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_dataset" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/DeleteConversationDataset", request_serializer=conversation_dataset.DeleteConversationDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -438,7 +529,7 @@ def import_conversation_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_conversation_data" not in self._stubs: - self._stubs["import_conversation_data"] = self.grpc_channel.unary_unary( + self._stubs["import_conversation_data"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationDatasets/ImportConversationData", request_serializer=conversation_dataset.ImportConversationDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -506,7 +597,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: @@ -522,7 +613,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -539,7 +630,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -558,7 +649,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -577,7 +668,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, @@ -594,7 +685,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py index ee51b878e81c..db0063361e1f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_datasets/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 @@ -42,6 +42,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, @@ -114,10 +122,10 @@ def post_list_conversation_datasets(self, response): def pre_create_conversation_dataset( self, request: gcd_conversation_dataset.CreateConversationDatasetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_dataset.CreateConversationDatasetRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_conversation_dataset @@ -140,9 +148,10 @@ def post_create_conversation_dataset( def pre_delete_conversation_dataset( self, request: conversation_dataset.DeleteConversationDatasetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_dataset.DeleteConversationDatasetRequest, Sequence[Tuple[str, str]] + conversation_dataset.DeleteConversationDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_conversation_dataset @@ -165,9 +174,10 @@ def post_delete_conversation_dataset( def pre_get_conversation_dataset( self, request: conversation_dataset.GetConversationDatasetRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_dataset.GetConversationDatasetRequest, Sequence[Tuple[str, str]] + conversation_dataset.GetConversationDatasetRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_conversation_dataset @@ -190,9 +200,10 @@ def post_get_conversation_dataset( def pre_import_conversation_data( self, request: conversation_dataset.ImportConversationDataRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_dataset.ImportConversationDataRequest, Sequence[Tuple[str, str]] + conversation_dataset.ImportConversationDataRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for import_conversation_data @@ -215,9 +226,10 @@ def post_import_conversation_data( def pre_list_conversation_datasets( self, request: conversation_dataset.ListConversationDatasetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_dataset.ListConversationDatasetsRequest, Sequence[Tuple[str, str]] + conversation_dataset.ListConversationDatasetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_conversation_datasets @@ -240,8 +252,10 @@ def post_list_conversation_datasets( 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 @@ -263,8 +277,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 @@ -286,8 +302,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -307,8 +325,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -330,8 +350,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -535,7 +557,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create conversation dataset method over HTTP. @@ -547,8 +569,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: ~.operations_pb2.Operation: @@ -561,6 +585,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseCreateConversationDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation_dataset( request, metadata ) @@ -577,6 +602,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.dialogflow_v2.ConversationDatasetsClient.CreateConversationDataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "CreateConversationDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._CreateConversationDataset._get_response( self._host, @@ -596,7 +648,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation_dataset(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.dialogflow_v2.ConversationDatasetsClient.create_conversation_dataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "CreateConversationDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConversationDataset( @@ -634,7 +708,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete conversation dataset method over HTTP. @@ -646,8 +720,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: ~.operations_pb2.Operation: @@ -660,6 +736,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseDeleteConversationDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversation_dataset( request, metadata ) @@ -672,6 +749,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.dialogflow_v2.ConversationDatasetsClient.DeleteConversationDataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "DeleteConversationDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._DeleteConversationDataset._get_response( self._host, @@ -690,7 +794,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_conversation_dataset(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.dialogflow_v2.ConversationDatasetsClient.delete_conversation_dataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "DeleteConversationDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversationDataset( @@ -728,7 +854,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]]] = (), ) -> conversation_dataset.ConversationDataset: r"""Call the get conversation dataset method over HTTP. @@ -739,8 +865,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: ~.conversation_dataset.ConversationDataset: @@ -757,6 +885,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseGetConversationDataset._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation_dataset( request, metadata ) @@ -769,6 +898,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 = 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.dialogflow_v2.ConversationDatasetsClient.GetConversationDataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetConversationDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationDatasetsRestTransport._GetConversationDataset._get_response( @@ -791,7 +947,31 @@ def __call__( pb_resp = conversation_dataset.ConversationDataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation_dataset.ConversationDataset.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.dialogflow_v2.ConversationDatasetsClient.get_conversation_dataset", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetConversationDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportConversationData( @@ -830,7 +1010,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import conversation data method over HTTP. @@ -841,8 +1021,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: ~.operations_pb2.Operation: @@ -855,6 +1037,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseImportConversationData._get_http_options() ) + request, metadata = self._interceptor.pre_import_conversation_data( request, metadata ) @@ -871,6 +1054,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.dialogflow_v2.ConversationDatasetsClient.ImportConversationData", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ImportConversationData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationDatasetsRestTransport._ImportConversationData._get_response( @@ -892,7 +1102,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_conversation_data(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.dialogflow_v2.ConversationDatasetsClient.import_conversation_data", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ImportConversationData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversationDatasets( @@ -930,7 +1162,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]]] = (), ) -> conversation_dataset.ListConversationDatasetsResponse: r"""Call the list conversation datasets method over HTTP. @@ -942,8 +1174,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: ~.conversation_dataset.ListConversationDatasetsResponse: @@ -955,6 +1189,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseListConversationDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversation_datasets( request, metadata ) @@ -967,6 +1202,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 = 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.dialogflow_v2.ConversationDatasetsClient.ListConversationDatasets", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListConversationDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._ListConversationDatasets._get_response( self._host, @@ -987,7 +1249,33 @@ def __call__( pb_resp = conversation_dataset.ListConversationDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversation_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation_dataset.ListConversationDatasetsResponse.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.dialogflow_v2.ConversationDatasetsClient.list_conversation_datasets", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListConversationDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1083,7 +1371,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. @@ -1093,8 +1381,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. @@ -1103,6 +1393,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationDatasetsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1113,6 +1404,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.dialogflow_v2.ConversationDatasetsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._GetLocation._get_response( self._host, @@ -1132,6 +1450,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.dialogflow_v2.ConversationDatasetsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1173,7 +1512,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. @@ -1183,8 +1522,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. @@ -1193,6 +1534,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationDatasetsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1203,6 +1545,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.dialogflow_v2.ConversationDatasetsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._ListLocations._get_response( self._host, @@ -1222,6 +1591,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.dialogflow_v2.ConversationDatasetsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1263,7 +1653,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1273,13 +1663,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 = ( _BaseConversationDatasetsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1292,6 +1685,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.dialogflow_v2.ConversationDatasetsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._CancelOperation._get_response( self._host, @@ -1348,7 +1768,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1358,8 +1778,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: operations_pb2.Operation: Response from GetOperation method. @@ -1368,6 +1790,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationDatasetsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1378,6 +1801,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.dialogflow_v2.ConversationDatasetsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._GetOperation._get_response( self._host, @@ -1397,6 +1847,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ConversationDatasetsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1438,7 +1909,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1448,8 +1919,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1458,6 +1931,7 @@ def __call__( http_options = ( _BaseConversationDatasetsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationDatasetsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1468,6 +1942,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.dialogflow_v2.ConversationDatasetsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationDatasetsRestTransport._ListOperations._get_response( self._host, @@ -1487,6 +1988,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ConversationDatasetsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationDatasets", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/async_client.py index 72d523fc2d23..938d21ef46e6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ConversationModelsTransport from .transports.grpc_asyncio import ConversationModelsGrpcAsyncIOTransport +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 ConversationModelsAsyncClient: """Manages a collection of models for human agent assistant.""" @@ -286,6 +296,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.dialogflow_v2.ConversationModelsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "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.dialogflow.v2.ConversationModels", + "credentialsType": None, + }, + ) + async def create_conversation_model( self, request: Optional[ @@ -296,7 +328,7 @@ async def create_conversation_model( conversation_model: Optional[gcd_conversation_model.ConversationModel] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a model. @@ -365,8 +397,10 @@ async def sample_create_conversation_model(): 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.api_core.operation_async.AsyncOperation: @@ -444,7 +478,7 @@ async def get_conversation_model( 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]]] = (), ) -> conversation_model.ConversationModel: r"""Gets conversation model. @@ -488,8 +522,10 @@ async def sample_get_conversation_model(): 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.dialogflow_v2.types.ConversationModel: @@ -550,7 +586,7 @@ async def list_conversation_models( 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.ListConversationModelsAsyncPager: r"""Lists conversation models. @@ -595,8 +631,10 @@ async def sample_list_conversation_models(): 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.dialogflow_v2.services.conversation_models.pagers.ListConversationModelsAsyncPager: @@ -673,7 +711,7 @@ async def delete_conversation_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a model. @@ -731,8 +769,10 @@ async def sample_delete_conversation_model(): 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.api_core.operation_async.AsyncOperation: @@ -812,7 +852,7 @@ async def deploy_conversation_model( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a model. If a model is already deployed, deploying it has no effect. A model can only serve prediction requests after @@ -866,8 +906,10 @@ async def sample_deploy_conversation_model(): 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.api_core.operation_async.AsyncOperation: @@ -933,7 +975,7 @@ async def undeploy_conversation_model( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys a model. If the model is not deployed this method has no effect. If the model is currently being used: @@ -988,8 +1030,10 @@ async def sample_undeploy_conversation_model(): 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.api_core.operation_async.AsyncOperation: @@ -1056,7 +1100,7 @@ async def get_conversation_model_evaluation( 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]]] = (), ) -> conversation_model.ConversationModelEvaluation: r"""Gets an evaluation of conversation model. @@ -1101,8 +1145,10 @@ async def sample_get_conversation_model_evaluation(): 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.dialogflow_v2.types.ConversationModelEvaluation: @@ -1167,7 +1213,7 @@ async def list_conversation_model_evaluations( 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.ListConversationModelEvaluationsAsyncPager: r"""Lists evaluations of a conversation model. @@ -1212,8 +1258,10 @@ async def sample_list_conversation_model_evaluations(): 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.dialogflow_v2.services.conversation_models.pagers.ListConversationModelEvaluationsAsyncPager: @@ -1297,7 +1345,7 @@ async def create_conversation_model_evaluation( ] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates evaluation of a conversation model. @@ -1352,8 +1400,10 @@ async def sample_create_conversation_model_evaluation(): 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.api_core.operation_async.AsyncOperation: @@ -1430,7 +1480,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1441,8 +1491,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1483,7 +1535,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1494,8 +1546,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1536,7 +1590,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1551,8 +1605,10 @@ async def cancel_operation( 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: None """ @@ -1589,7 +1645,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. @@ -1600,8 +1656,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. @@ -1642,7 +1700,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. @@ -1653,8 +1711,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/client.py index dcc671d4c569..071de039a4c5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -658,6 +668,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( @@ -724,6 +738,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.dialogflow_v2.ConversationModelsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "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.dialogflow.v2.ConversationModels", + "credentialsType": None, + }, + ) + def create_conversation_model( self, request: Optional[ @@ -734,7 +771,7 @@ def create_conversation_model( conversation_model: Optional[gcd_conversation_model.ConversationModel] = 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]]] = (), ) -> operation.Operation: r"""Creates a model. @@ -803,8 +840,10 @@ def sample_create_conversation_model(): 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.api_core.operation.Operation: @@ -881,7 +920,7 @@ def get_conversation_model( 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]]] = (), ) -> conversation_model.ConversationModel: r"""Gets conversation model. @@ -925,8 +964,10 @@ def sample_get_conversation_model(): 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.dialogflow_v2.types.ConversationModel: @@ -984,7 +1025,7 @@ def list_conversation_models( 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.ListConversationModelsPager: r"""Lists conversation models. @@ -1029,8 +1070,10 @@ def sample_list_conversation_models(): 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.dialogflow_v2.services.conversation_models.pagers.ListConversationModelsPager: @@ -1104,7 +1147,7 @@ def delete_conversation_model( 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]]] = (), ) -> operation.Operation: r"""Deletes a model. @@ -1162,8 +1205,10 @@ def sample_delete_conversation_model(): 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.api_core.operation.Operation: @@ -1242,7 +1287,7 @@ def deploy_conversation_model( *, 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]]] = (), ) -> operation.Operation: r"""Deploys a model. If a model is already deployed, deploying it has no effect. A model can only serve prediction requests after @@ -1296,8 +1341,10 @@ def sample_deploy_conversation_model(): 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.api_core.operation.Operation: @@ -1363,7 +1410,7 @@ def undeploy_conversation_model( *, 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]]] = (), ) -> operation.Operation: r"""Undeploys a model. If the model is not deployed this method has no effect. If the model is currently being used: @@ -1418,8 +1465,10 @@ def sample_undeploy_conversation_model(): 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.api_core.operation.Operation: @@ -1486,7 +1535,7 @@ def get_conversation_model_evaluation( 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]]] = (), ) -> conversation_model.ConversationModelEvaluation: r"""Gets an evaluation of conversation model. @@ -1531,8 +1580,10 @@ def sample_get_conversation_model_evaluation(): 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.dialogflow_v2.types.ConversationModelEvaluation: @@ -1596,7 +1647,7 @@ def list_conversation_model_evaluations( 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.ListConversationModelEvaluationsPager: r"""Lists evaluations of a conversation model. @@ -1641,8 +1692,10 @@ def sample_list_conversation_model_evaluations(): 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.dialogflow_v2.services.conversation_models.pagers.ListConversationModelEvaluationsPager: @@ -1725,7 +1778,7 @@ def create_conversation_model_evaluation( ] = 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]]] = (), ) -> operation.Operation: r"""Creates evaluation of a conversation model. @@ -1780,8 +1833,10 @@ def sample_create_conversation_model_evaluation(): 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.api_core.operation.Operation: @@ -1870,7 +1925,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1881,8 +1936,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1923,7 +1980,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1934,8 +1991,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1976,7 +2035,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1991,8 +2050,10 @@ def cancel_operation( 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: None """ @@ -2029,7 +2090,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. @@ -2040,8 +2101,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. @@ -2082,7 +2145,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. @@ -2093,8 +2156,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/pagers.py index b7e5ba589726..2e8f1c3969ec 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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 = conversation_model.ListConversationModelsRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = conversation_model.ListConversationModelsRequest(request) @@ -225,7 +229,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. @@ -239,8 +243,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 = conversation_model.ListConversationModelEvaluationsRequest( @@ -305,7 +311,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. @@ -319,8 +325,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 = conversation_model.ListConversationModelEvaluationsRequest( diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc.py index f8392b9bfd8d..969173f59abe 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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 @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_model as gcd_conversation_model, @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, ConversationModelsTransport +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.dialogflow.v2.ConversationModels", + "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.dialogflow.v2.ConversationModels", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationModelsGrpcTransport(ConversationModelsTransport): """gRPC backend transport for ConversationModels. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -286,7 +374,7 @@ def create_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_model" not in self._stubs: - self._stubs["create_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/CreateConversationModel", request_serializer=gcd_conversation_model.CreateConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -315,7 +403,7 @@ def get_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_model" not in self._stubs: - self._stubs["get_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/GetConversationModel", request_serializer=conversation_model.GetConversationModelRequest.serialize, response_deserializer=conversation_model.ConversationModel.deserialize, @@ -344,7 +432,7 @@ def list_conversation_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_models" not in self._stubs: - self._stubs["list_conversation_models"] = self.grpc_channel.unary_unary( + self._stubs["list_conversation_models"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/ListConversationModels", request_serializer=conversation_model.ListConversationModelsRequest.serialize, response_deserializer=conversation_model.ListConversationModelsResponse.deserialize, @@ -382,7 +470,7 @@ def delete_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_model" not in self._stubs: - self._stubs["delete_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/DeleteConversationModel", request_serializer=conversation_model.DeleteConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +511,7 @@ def deploy_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_conversation_model" not in self._stubs: - self._stubs["deploy_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/DeployConversationModel", request_serializer=conversation_model.DeployConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -465,7 +553,9 @@ def undeploy_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_conversation_model" not in self._stubs: - self._stubs["undeploy_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs[ + "undeploy_conversation_model" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/UndeployConversationModel", request_serializer=conversation_model.UndeployConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -497,7 +587,7 @@ def get_conversation_model_evaluation( if "get_conversation_model_evaluation" not in self._stubs: self._stubs[ "get_conversation_model_evaluation" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/GetConversationModelEvaluation", request_serializer=conversation_model.GetConversationModelEvaluationRequest.serialize, response_deserializer=conversation_model.ConversationModelEvaluation.deserialize, @@ -529,7 +619,7 @@ def list_conversation_model_evaluations( if "list_conversation_model_evaluations" not in self._stubs: self._stubs[ "list_conversation_model_evaluations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/ListConversationModelEvaluations", request_serializer=conversation_model.ListConversationModelEvaluationsRequest.serialize, response_deserializer=conversation_model.ListConversationModelEvaluationsResponse.deserialize, @@ -561,7 +651,7 @@ def create_conversation_model_evaluation( if "create_conversation_model_evaluation" not in self._stubs: self._stubs[ "create_conversation_model_evaluation" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/CreateConversationModelEvaluation", request_serializer=conversation_model.CreateConversationModelEvaluationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -569,7 +659,7 @@ def create_conversation_model_evaluation( return self._stubs["create_conversation_model_evaluation"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -581,7 +671,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -598,7 +688,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -617,7 +707,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -636,7 +726,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, @@ -653,7 +743,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc_asyncio.py index 401f60521e0a..5193b2e11200 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_model as gcd_conversation_model, @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationModelsTransport from .grpc import ConversationModelsGrpcTransport +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.dialogflow.v2.ConversationModels", + "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.dialogflow.v2.ConversationModels", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationModelsGrpcAsyncIOTransport(ConversationModelsTransport): """gRPC AsyncIO backend transport for ConversationModels. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -296,7 +381,7 @@ def create_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_model" not in self._stubs: - self._stubs["create_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/CreateConversationModel", request_serializer=gcd_conversation_model.CreateConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -325,7 +410,7 @@ def get_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_model" not in self._stubs: - self._stubs["get_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/GetConversationModel", request_serializer=conversation_model.GetConversationModelRequest.serialize, response_deserializer=conversation_model.ConversationModel.deserialize, @@ -354,7 +439,7 @@ def list_conversation_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_models" not in self._stubs: - self._stubs["list_conversation_models"] = self.grpc_channel.unary_unary( + self._stubs["list_conversation_models"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/ListConversationModels", request_serializer=conversation_model.ListConversationModelsRequest.serialize, response_deserializer=conversation_model.ListConversationModelsResponse.deserialize, @@ -393,7 +478,7 @@ def delete_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_model" not in self._stubs: - self._stubs["delete_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/DeleteConversationModel", request_serializer=conversation_model.DeleteConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -435,7 +520,7 @@ def deploy_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_conversation_model" not in self._stubs: - self._stubs["deploy_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_conversation_model"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/DeployConversationModel", request_serializer=conversation_model.DeployConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -478,7 +563,9 @@ def undeploy_conversation_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_conversation_model" not in self._stubs: - self._stubs["undeploy_conversation_model"] = self.grpc_channel.unary_unary( + self._stubs[ + "undeploy_conversation_model" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/UndeployConversationModel", request_serializer=conversation_model.UndeployConversationModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -510,7 +597,7 @@ def get_conversation_model_evaluation( if "get_conversation_model_evaluation" not in self._stubs: self._stubs[ "get_conversation_model_evaluation" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/GetConversationModelEvaluation", request_serializer=conversation_model.GetConversationModelEvaluationRequest.serialize, response_deserializer=conversation_model.ConversationModelEvaluation.deserialize, @@ -542,7 +629,7 @@ def list_conversation_model_evaluations( if "list_conversation_model_evaluations" not in self._stubs: self._stubs[ "list_conversation_model_evaluations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/ListConversationModelEvaluations", request_serializer=conversation_model.ListConversationModelEvaluationsRequest.serialize, response_deserializer=conversation_model.ListConversationModelEvaluationsResponse.deserialize, @@ -574,7 +661,7 @@ def create_conversation_model_evaluation( if "create_conversation_model_evaluation" not in self._stubs: self._stubs[ "create_conversation_model_evaluation" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationModels/CreateConversationModelEvaluation", request_serializer=conversation_model.CreateConversationModelEvaluationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -662,7 +749,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: @@ -678,7 +765,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -695,7 +782,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -714,7 +801,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -733,7 +820,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, @@ -750,7 +837,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py index 23be6104c571..15e4ae8e846b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_models/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 @@ -42,6 +42,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, @@ -146,9 +154,10 @@ def post_undeploy_conversation_model(self, response): def pre_create_conversation_model( self, request: gcd_conversation_model.CreateConversationModelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_conversation_model.CreateConversationModelRequest, Sequence[Tuple[str, str]] + gcd_conversation_model.CreateConversationModelRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_conversation_model @@ -171,10 +180,10 @@ def post_create_conversation_model( def pre_create_conversation_model_evaluation( self, request: conversation_model.CreateConversationModelEvaluationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ conversation_model.CreateConversationModelEvaluationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_conversation_model_evaluation @@ -197,9 +206,10 @@ def post_create_conversation_model_evaluation( def pre_delete_conversation_model( self, request: conversation_model.DeleteConversationModelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_model.DeleteConversationModelRequest, Sequence[Tuple[str, str]] + conversation_model.DeleteConversationModelRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_conversation_model @@ -222,9 +232,10 @@ def post_delete_conversation_model( def pre_deploy_conversation_model( self, request: conversation_model.DeployConversationModelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_model.DeployConversationModelRequest, Sequence[Tuple[str, str]] + conversation_model.DeployConversationModelRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for deploy_conversation_model @@ -247,9 +258,10 @@ def post_deploy_conversation_model( def pre_get_conversation_model( self, request: conversation_model.GetConversationModelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_model.GetConversationModelRequest, Sequence[Tuple[str, str]] + conversation_model.GetConversationModelRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_conversation_model @@ -272,10 +284,10 @@ def post_get_conversation_model( def pre_get_conversation_model_evaluation( self, request: conversation_model.GetConversationModelEvaluationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ conversation_model.GetConversationModelEvaluationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_conversation_model_evaluation @@ -298,10 +310,10 @@ def post_get_conversation_model_evaluation( def pre_list_conversation_model_evaluations( self, request: conversation_model.ListConversationModelEvaluationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ conversation_model.ListConversationModelEvaluationsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_conversation_model_evaluations @@ -324,9 +336,10 @@ def post_list_conversation_model_evaluations( def pre_list_conversation_models( self, request: conversation_model.ListConversationModelsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_model.ListConversationModelsRequest, Sequence[Tuple[str, str]] + conversation_model.ListConversationModelsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_conversation_models @@ -349,9 +362,10 @@ def post_list_conversation_models( def pre_undeploy_conversation_model( self, request: conversation_model.UndeployConversationModelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_model.UndeployConversationModelRequest, Sequence[Tuple[str, str]] + conversation_model.UndeployConversationModelRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for undeploy_conversation_model @@ -374,8 +388,10 @@ def post_undeploy_conversation_model( 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 @@ -397,8 +413,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 @@ -420,8 +438,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -441,8 +461,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -464,8 +486,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -666,7 +690,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create conversation model method over HTTP. @@ -677,8 +701,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: ~.operations_pb2.Operation: @@ -691,6 +717,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseCreateConversationModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation_model( request, metadata ) @@ -707,6 +734,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.dialogflow_v2.ConversationModelsClient.CreateConversationModel", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "CreateConversationModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationModelsRestTransport._CreateConversationModel._get_response( @@ -728,7 +782,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation_model(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.dialogflow_v2.ConversationModelsClient.create_conversation_model", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "CreateConversationModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversationModelEvaluation( @@ -769,7 +845,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create conversation model evaluation method over HTTP. @@ -781,8 +857,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: ~.operations_pb2.Operation: @@ -795,6 +873,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseCreateConversationModelEvaluation._get_http_options() ) + ( request, metadata, @@ -814,6 +893,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.dialogflow_v2.ConversationModelsClient.CreateConversationModelEvaluation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "CreateConversationModelEvaluation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._CreateConversationModelEvaluation._get_response( self._host, @@ -833,7 +939,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation_model_evaluation(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.dialogflow_v2.ConversationModelsClient.create_conversation_model_evaluation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "CreateConversationModelEvaluation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConversationModel( @@ -871,7 +999,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete conversation model method over HTTP. @@ -882,8 +1010,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: ~.operations_pb2.Operation: @@ -896,6 +1026,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseDeleteConversationModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversation_model( request, metadata ) @@ -908,6 +1039,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.dialogflow_v2.ConversationModelsClient.DeleteConversationModel", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "DeleteConversationModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationModelsRestTransport._DeleteConversationModel._get_response( @@ -928,7 +1086,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_conversation_model(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.dialogflow_v2.ConversationModelsClient.delete_conversation_model", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "DeleteConversationModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployConversationModel( @@ -967,7 +1147,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]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy conversation model method over HTTP. @@ -978,8 +1158,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: ~.operations_pb2.Operation: @@ -992,6 +1174,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseDeployConversationModel._get_http_options() ) + request, metadata = self._interceptor.pre_deploy_conversation_model( request, metadata ) @@ -1008,6 +1191,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.dialogflow_v2.ConversationModelsClient.DeployConversationModel", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "DeployConversationModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationModelsRestTransport._DeployConversationModel._get_response( @@ -1029,7 +1239,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_conversation_model(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.dialogflow_v2.ConversationModelsClient.deploy_conversation_model", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "DeployConversationModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversationModel( @@ -1067,7 +1299,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]]] = (), ) -> conversation_model.ConversationModel: r"""Call the get conversation model method over HTTP. @@ -1078,8 +1310,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: ~.conversation_model.ConversationModel: @@ -1089,6 +1323,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseGetConversationModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation_model( request, metadata ) @@ -1101,6 +1336,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 = 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.dialogflow_v2.ConversationModelsClient.GetConversationModel", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetConversationModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationModelsRestTransport._GetConversationModel._get_response( @@ -1123,7 +1385,31 @@ def __call__( pb_resp = conversation_model.ConversationModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation_model.ConversationModel.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.dialogflow_v2.ConversationModelsClient.get_conversation_model", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetConversationModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversationModelEvaluation( @@ -1163,7 +1449,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]]] = (), ) -> conversation_model.ConversationModelEvaluation: r"""Call the get conversation model evaluation method over HTTP. @@ -1175,8 +1461,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: ~.conversation_model.ConversationModelEvaluation: @@ -1188,6 +1476,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseGetConversationModelEvaluation._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation_model_evaluation( request, metadata ) @@ -1200,6 +1489,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 = 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.dialogflow_v2.ConversationModelsClient.GetConversationModelEvaluation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetConversationModelEvaluation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._GetConversationModelEvaluation._get_response( self._host, @@ -1220,7 +1536,31 @@ def __call__( pb_resp = conversation_model.ConversationModelEvaluation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation_model_evaluation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation_model.ConversationModelEvaluation.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.dialogflow_v2.ConversationModelsClient.get_conversation_model_evaluation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetConversationModelEvaluation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversationModelEvaluations( @@ -1260,7 +1600,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]]] = (), ) -> conversation_model.ListConversationModelEvaluationsResponse: r"""Call the list conversation model evaluations method over HTTP. @@ -1272,8 +1612,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: ~.conversation_model.ListConversationModelEvaluationsResponse: @@ -1285,6 +1627,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseListConversationModelEvaluations._get_http_options() ) + ( request, metadata, @@ -1300,6 +1643,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 = 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.dialogflow_v2.ConversationModelsClient.ListConversationModelEvaluations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListConversationModelEvaluations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._ListConversationModelEvaluations._get_response( self._host, @@ -1322,7 +1692,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversation_model_evaluations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation_model.ListConversationModelEvaluationsResponse.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.dialogflow_v2.ConversationModelsClient.list_conversation_model_evaluations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListConversationModelEvaluations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversationModels( @@ -1360,7 +1754,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]]] = (), ) -> conversation_model.ListConversationModelsResponse: r"""Call the list conversation models method over HTTP. @@ -1371,8 +1765,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: ~.conversation_model.ListConversationModelsResponse: @@ -1384,6 +1780,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseListConversationModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversation_models( request, metadata ) @@ -1396,6 +1793,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 = 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.dialogflow_v2.ConversationModelsClient.ListConversationModels", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListConversationModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationModelsRestTransport._ListConversationModels._get_response( @@ -1418,7 +1842,33 @@ def __call__( pb_resp = conversation_model.ListConversationModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversation_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation_model.ListConversationModelsResponse.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.dialogflow_v2.ConversationModelsClient.list_conversation_models", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListConversationModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployConversationModel( @@ -1457,7 +1907,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]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy conversation model method over HTTP. @@ -1469,8 +1919,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: ~.operations_pb2.Operation: @@ -1483,6 +1935,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseUndeployConversationModel._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_conversation_model( request, metadata ) @@ -1499,6 +1952,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.dialogflow_v2.ConversationModelsClient.UndeployConversationModel", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "UndeployConversationModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._UndeployConversationModel._get_response( self._host, @@ -1518,7 +1998,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_conversation_model(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.dialogflow_v2.ConversationModelsClient.undeploy_conversation_model", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "UndeployConversationModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1656,7 +2158,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. @@ -1666,8 +2168,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. @@ -1676,6 +2180,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationModelsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1686,6 +2191,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.dialogflow_v2.ConversationModelsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._GetLocation._get_response( self._host, @@ -1705,6 +2237,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.dialogflow_v2.ConversationModelsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1746,7 +2299,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. @@ -1756,8 +2309,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. @@ -1766,6 +2321,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationModelsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1776,6 +2332,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.dialogflow_v2.ConversationModelsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._ListLocations._get_response( self._host, @@ -1795,6 +2378,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.dialogflow_v2.ConversationModelsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1836,7 +2440,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1846,13 +2450,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 = ( _BaseConversationModelsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1865,6 +2472,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.dialogflow_v2.ConversationModelsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._CancelOperation._get_response( self._host, @@ -1921,7 +2555,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1931,8 +2565,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: operations_pb2.Operation: Response from GetOperation method. @@ -1941,6 +2577,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationModelsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1951,6 +2588,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.dialogflow_v2.ConversationModelsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._GetOperation._get_response( self._host, @@ -1970,6 +2634,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ConversationModelsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2011,7 +2696,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2021,8 +2706,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2031,6 +2718,7 @@ def __call__( http_options = ( _BaseConversationModelsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationModelsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2041,6 +2729,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.dialogflow_v2.ConversationModelsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationModelsRestTransport._ListOperations._get_response( self._host, @@ -2060,6 +2775,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ConversationModelsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationModels", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py index 8f5af066f4bb..614548326711 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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, ConversationProfilesTransport from .transports.grpc_asyncio import ConversationProfilesGrpcAsyncIOTransport +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 ConversationProfilesAsyncClient: """Service for managing @@ -302,6 +312,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.dialogflow_v2.ConversationProfilesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "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.dialogflow.v2.ConversationProfiles", + "credentialsType": None, + }, + ) + async def list_conversation_profiles( self, request: Optional[ @@ -311,7 +343,7 @@ async def list_conversation_profiles( 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.ListConversationProfilesAsyncPager: r"""Returns the list of all conversation profiles in the specified project. @@ -358,8 +390,10 @@ async def sample_list_conversation_profiles(): 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.dialogflow_v2.services.conversation_profiles.pagers.ListConversationProfilesAsyncPager: @@ -438,7 +472,7 @@ async def get_conversation_profile( 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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Retrieves the specified conversation profile. @@ -483,8 +517,10 @@ async def sample_get_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -550,13 +586,14 @@ async def create_conversation_profile( ] = 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Creates a conversation profile in the specified project. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -612,8 +649,10 @@ async def sample_create_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -683,13 +722,14 @@ async def update_conversation_profile( 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Updates the specified conversation profile. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -743,8 +783,10 @@ async def sample_update_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -813,7 +855,7 @@ async def delete_conversation_profile( 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 the specified conversation profile. @@ -858,8 +900,10 @@ async def sample_delete_conversation_profile(): 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 @@ -919,7 +963,7 @@ async def set_suggestion_feature_config( ] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds or updates a suggestion feature in a conversation profile. If the conversation profile contains the type of suggestion @@ -976,7 +1020,7 @@ async def sample_set_suggestion_feature_config(): Args: request (Optional[Union[google.cloud.dialogflow_v2.types.SetSuggestionFeatureConfigRequest, dict]]): The request object. The request message for - [ConversationProfiles.SetSuggestionFeature][]. + [ConversationProfiles.SetSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.SetSuggestionFeatureConfig]. conversation_profile (:class:`str`): Required. The Conversation Profile to add or update the suggestion feature config. Format: @@ -1003,8 +1047,10 @@ async def sample_set_suggestion_feature_config(): 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.api_core.operation_async.AsyncOperation: @@ -1095,7 +1141,7 @@ async def clear_suggestion_feature_config( ] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Clears a suggestion feature from a conversation profile for the given participant role. @@ -1145,7 +1191,7 @@ async def sample_clear_suggestion_feature_config(): Args: request (Optional[Union[google.cloud.dialogflow_v2.types.ClearSuggestionFeatureConfigRequest, dict]]): The request object. The request message for - [ConversationProfiles.ClearFeature][]. + [ConversationProfiles.ClearSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.ClearSuggestionFeatureConfig]. conversation_profile (:class:`str`): Required. The Conversation Profile to add or update the suggestion feature config. Format: @@ -1172,8 +1218,10 @@ async def sample_clear_suggestion_feature_config(): 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.api_core.operation_async.AsyncOperation: @@ -1257,7 +1305,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1268,8 +1316,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1310,7 +1360,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1321,8 +1371,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1363,7 +1415,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1378,8 +1430,10 @@ async def cancel_operation( 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: None """ @@ -1416,7 +1470,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. @@ -1427,8 +1481,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. @@ -1469,7 +1525,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. @@ -1480,8 +1536,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/client.py index 96696555a321..93f4d954e3d2 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -738,6 +748,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( @@ -804,6 +818,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.dialogflow_v2.ConversationProfilesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "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.dialogflow.v2.ConversationProfiles", + "credentialsType": None, + }, + ) + def list_conversation_profiles( self, request: Optional[ @@ -813,7 +850,7 @@ def list_conversation_profiles( 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.ListConversationProfilesPager: r"""Returns the list of all conversation profiles in the specified project. @@ -860,8 +897,10 @@ def sample_list_conversation_profiles(): 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.dialogflow_v2.services.conversation_profiles.pagers.ListConversationProfilesPager: @@ -939,7 +978,7 @@ def get_conversation_profile( 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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Retrieves the specified conversation profile. @@ -984,8 +1023,10 @@ def sample_get_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -1048,13 +1089,14 @@ def create_conversation_profile( ] = 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Creates a conversation profile in the specified project. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -1110,8 +1152,10 @@ def sample_create_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -1180,13 +1224,14 @@ def update_conversation_profile( 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Updates the specified conversation profile. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -1240,8 +1285,10 @@ def sample_update_conversation_profile(): 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.dialogflow_v2.types.ConversationProfile: @@ -1309,7 +1356,7 @@ def delete_conversation_profile( 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 the specified conversation profile. @@ -1354,8 +1401,10 @@ def sample_delete_conversation_profile(): 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 @@ -1414,7 +1463,7 @@ def set_suggestion_feature_config( ] = 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]]] = (), ) -> operation.Operation: r"""Adds or updates a suggestion feature in a conversation profile. If the conversation profile contains the type of suggestion @@ -1471,7 +1520,7 @@ def sample_set_suggestion_feature_config(): Args: request (Union[google.cloud.dialogflow_v2.types.SetSuggestionFeatureConfigRequest, dict]): The request object. The request message for - [ConversationProfiles.SetSuggestionFeature][]. + [ConversationProfiles.SetSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.SetSuggestionFeatureConfig]. conversation_profile (str): Required. The Conversation Profile to add or update the suggestion feature config. Format: @@ -1498,8 +1547,10 @@ def sample_set_suggestion_feature_config(): 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.api_core.operation.Operation: @@ -1589,7 +1640,7 @@ def clear_suggestion_feature_config( ] = 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]]] = (), ) -> operation.Operation: r"""Clears a suggestion feature from a conversation profile for the given participant role. @@ -1639,7 +1690,7 @@ def sample_clear_suggestion_feature_config(): Args: request (Union[google.cloud.dialogflow_v2.types.ClearSuggestionFeatureConfigRequest, dict]): The request object. The request message for - [ConversationProfiles.ClearFeature][]. + [ConversationProfiles.ClearSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.ClearSuggestionFeatureConfig]. conversation_profile (str): Required. The Conversation Profile to add or update the suggestion feature config. Format: @@ -1666,8 +1717,10 @@ def sample_clear_suggestion_feature_config(): 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.api_core.operation.Operation: @@ -1763,7 +1816,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1774,8 +1827,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1816,7 +1871,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1827,8 +1882,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1869,7 +1926,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1884,8 +1941,10 @@ def cancel_operation( 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: None """ @@ -1922,7 +1981,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. @@ -1933,8 +1992,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. @@ -1975,7 +2036,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. @@ -1986,8 +2047,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/pagers.py index 06d4feab15c1..d8924904bb8d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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 = conversation_profile.ListConversationProfilesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = conversation_profile.ListConversationProfilesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py index 5749f0293622..703883fa8e04 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_profile as gcd_conversation_profile, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ConversationProfilesTransport +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.dialogflow.v2.ConversationProfiles", + "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.dialogflow.v2.ConversationProfiles", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationProfilesGrpcTransport(ConversationProfilesTransport): """gRPC backend transport for ConversationProfiles. @@ -187,7 +268,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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,9 @@ def list_conversation_profiles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_profiles" not in self._stubs: - self._stubs["list_conversation_profiles"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_profiles" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/ListConversationProfiles", request_serializer=conversation_profile.ListConversationProfilesRequest.serialize, response_deserializer=conversation_profile.ListConversationProfilesResponse.deserialize, @@ -308,7 +398,7 @@ def get_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_profile" not in self._stubs: - self._stubs["get_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_profile"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/GetConversationProfile", request_serializer=conversation_profile.GetConversationProfileRequest.serialize, response_deserializer=conversation_profile.ConversationProfile.deserialize, @@ -326,9 +416,10 @@ def create_conversation_profile( Creates a conversation profile in the specified project. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -343,7 +434,9 @@ def create_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_profile" not in self._stubs: - self._stubs["create_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/CreateConversationProfile", request_serializer=gcd_conversation_profile.CreateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -361,9 +454,10 @@ def update_conversation_profile( Updates the specified conversation profile. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -378,7 +472,9 @@ def update_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversation_profile" not in self._stubs: - self._stubs["update_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/UpdateConversationProfile", request_serializer=gcd_conversation_profile.UpdateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -406,7 +502,9 @@ def delete_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_profile" not in self._stubs: - self._stubs["delete_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/DeleteConversationProfile", request_serializer=conversation_profile.DeleteConversationProfileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -456,7 +554,7 @@ def set_suggestion_feature_config( if "set_suggestion_feature_config" not in self._stubs: self._stubs[ "set_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/SetSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.SetSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -499,7 +597,7 @@ def clear_suggestion_feature_config( if "clear_suggestion_feature_config" not in self._stubs: self._stubs[ "clear_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/ClearSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.ClearSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +605,7 @@ def clear_suggestion_feature_config( return self._stubs["clear_suggestion_feature_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -519,7 +617,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -536,7 +634,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -555,7 +653,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -574,7 +672,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, @@ -591,7 +689,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py index a47ef5c22065..bf671b1a794d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( conversation_profile as gcd_conversation_profile, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationProfilesTransport from .grpc import ConversationProfilesGrpcTransport +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.dialogflow.v2.ConversationProfiles", + "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.dialogflow.v2.ConversationProfiles", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationProfilesGrpcAsyncIOTransport(ConversationProfilesTransport): """gRPC AsyncIO backend transport for ConversationProfiles. @@ -234,10 +316,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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,9 @@ def list_conversation_profiles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_profiles" not in self._stubs: - self._stubs["list_conversation_profiles"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_profiles" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/ListConversationProfiles", request_serializer=conversation_profile.ListConversationProfilesRequest.serialize, response_deserializer=conversation_profile.ListConversationProfilesResponse.deserialize, @@ -318,7 +405,7 @@ def get_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_profile" not in self._stubs: - self._stubs["get_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_profile"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/GetConversationProfile", request_serializer=conversation_profile.GetConversationProfileRequest.serialize, response_deserializer=conversation_profile.ConversationProfile.deserialize, @@ -336,9 +423,10 @@ def create_conversation_profile( Creates a conversation profile in the specified project. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -353,7 +441,9 @@ def create_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_profile" not in self._stubs: - self._stubs["create_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/CreateConversationProfile", request_serializer=gcd_conversation_profile.CreateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -371,9 +461,10 @@ def update_conversation_profile( Updates the specified conversation profile. - [ConversationProfile.CreateTime][] and - [ConversationProfile.UpdateTime][] aren't populated in the - response. You can retrieve them via + [ConversationProfile.create_time][google.cloud.dialogflow.v2.ConversationProfile.create_time] + and + [ConversationProfile.update_time][google.cloud.dialogflow.v2.ConversationProfile.update_time] + aren't populated in the response. You can retrieve them via [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] API. @@ -388,7 +479,9 @@ def update_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversation_profile" not in self._stubs: - self._stubs["update_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/UpdateConversationProfile", request_serializer=gcd_conversation_profile.UpdateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -417,7 +510,9 @@ def delete_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_profile" not in self._stubs: - self._stubs["delete_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/DeleteConversationProfile", request_serializer=conversation_profile.DeleteConversationProfileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -467,7 +562,7 @@ def set_suggestion_feature_config( if "set_suggestion_feature_config" not in self._stubs: self._stubs[ "set_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/SetSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.SetSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -510,7 +605,7 @@ def clear_suggestion_feature_config( if "clear_suggestion_feature_config" not in self._stubs: self._stubs[ "clear_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.ConversationProfiles/ClearSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.ClearSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -588,7 +683,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: @@ -604,7 +699,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -621,7 +716,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -640,7 +735,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -659,7 +754,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, @@ -676,7 +771,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-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py index 7f5b3b7aa018..a467afdb1c2c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversation_profiles/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 @@ -43,6 +43,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, @@ -127,10 +135,10 @@ def post_update_conversation_profile(self, response): def pre_clear_suggestion_feature_config( self, request: gcd_conversation_profile.ClearSuggestionFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.ClearSuggestionFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for clear_suggestion_feature_config @@ -153,10 +161,10 @@ def post_clear_suggestion_feature_config( def pre_create_conversation_profile( self, request: gcd_conversation_profile.CreateConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.CreateConversationProfileRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_conversation_profile @@ -179,9 +187,10 @@ def post_create_conversation_profile( def pre_delete_conversation_profile( self, request: conversation_profile.DeleteConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.DeleteConversationProfileRequest, Sequence[Tuple[str, str]] + conversation_profile.DeleteConversationProfileRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_conversation_profile @@ -193,9 +202,10 @@ def pre_delete_conversation_profile( def pre_get_conversation_profile( self, request: conversation_profile.GetConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.GetConversationProfileRequest, Sequence[Tuple[str, str]] + conversation_profile.GetConversationProfileRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_conversation_profile @@ -218,9 +228,10 @@ def post_get_conversation_profile( def pre_list_conversation_profiles( self, request: conversation_profile.ListConversationProfilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.ListConversationProfilesRequest, Sequence[Tuple[str, str]] + conversation_profile.ListConversationProfilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_conversation_profiles @@ -243,10 +254,10 @@ def post_list_conversation_profiles( def pre_set_suggestion_feature_config( self, request: gcd_conversation_profile.SetSuggestionFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.SetSuggestionFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_suggestion_feature_config @@ -269,10 +280,10 @@ def post_set_suggestion_feature_config( def pre_update_conversation_profile( self, request: gcd_conversation_profile.UpdateConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.UpdateConversationProfileRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_conversation_profile @@ -295,8 +306,10 @@ def post_update_conversation_profile( 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 @@ -318,8 +331,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 @@ -341,8 +356,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -362,8 +379,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -385,8 +404,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -590,7 +611,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]]] = (), ) -> operations_pb2.Operation: r"""Call the clear suggestion feature config method over HTTP. @@ -598,12 +619,14 @@ def __call__( Args: request (~.gcd_conversation_profile.ClearSuggestionFeatureConfigRequest): The request object. The request message for - [ConversationProfiles.ClearFeature][]. + [ConversationProfiles.ClearSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.ClearSuggestionFeatureConfig]. 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: ~.operations_pb2.Operation: @@ -616,6 +639,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseClearSuggestionFeatureConfig._get_http_options() ) + request, metadata = self._interceptor.pre_clear_suggestion_feature_config( request, metadata ) @@ -632,6 +656,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.dialogflow_v2.ConversationProfilesClient.ClearSuggestionFeatureConfig", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ClearSuggestionFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ClearSuggestionFeatureConfig._get_response( self._host, @@ -651,7 +702,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clear_suggestion_feature_config(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.dialogflow_v2.ConversationProfilesClient.clear_suggestion_feature_config", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ClearSuggestionFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversationProfile( @@ -690,7 +763,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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Call the create conversation profile method over HTTP. @@ -702,8 +775,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: ~.gcd_conversation_profile.ConversationProfile: @@ -715,6 +790,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseCreateConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation_profile( request, metadata ) @@ -731,6 +807,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 = 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.dialogflow_v2.ConversationProfilesClient.CreateConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "CreateConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._CreateConversationProfile._get_response( self._host, @@ -752,7 +855,31 @@ def __call__( pb_resp = gcd_conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation_profile.ConversationProfile.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.dialogflow_v2.ConversationProfilesClient.create_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "CreateConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConversationProfile( @@ -790,7 +917,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 conversation profile method over HTTP. @@ -805,13 +932,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 = ( _BaseConversationProfilesRestTransport._BaseDeleteConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversation_profile( request, metadata ) @@ -824,6 +954,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.dialogflow_v2.ConversationProfilesClient.DeleteConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "DeleteConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._DeleteConversationProfile._get_response( self._host, @@ -874,7 +1031,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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Call the get conversation profile method over HTTP. @@ -885,8 +1042,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: ~.conversation_profile.ConversationProfile: @@ -898,6 +1057,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation_profile( request, metadata ) @@ -910,6 +1070,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 = 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.dialogflow_v2.ConversationProfilesClient.GetConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationProfilesRestTransport._GetConversationProfile._get_response( @@ -932,7 +1119,31 @@ def __call__( pb_resp = conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation_profile.ConversationProfile.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.dialogflow_v2.ConversationProfilesClient.get_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversationProfiles( @@ -970,7 +1181,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]]] = (), ) -> conversation_profile.ListConversationProfilesResponse: r"""Call the list conversation profiles method over HTTP. @@ -982,8 +1193,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: ~.conversation_profile.ListConversationProfilesResponse: @@ -995,6 +1208,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListConversationProfiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversation_profiles( request, metadata ) @@ -1007,6 +1221,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 = 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.dialogflow_v2.ConversationProfilesClient.ListConversationProfiles", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListConversationProfiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListConversationProfiles._get_response( self._host, @@ -1027,7 +1268,33 @@ def __call__( pb_resp = conversation_profile.ListConversationProfilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversation_profiles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation_profile.ListConversationProfilesResponse.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.dialogflow_v2.ConversationProfilesClient.list_conversation_profiles", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListConversationProfiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSuggestionFeatureConfig( @@ -1066,7 +1333,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]]] = (), ) -> operations_pb2.Operation: r"""Call the set suggestion feature config method over HTTP. @@ -1074,12 +1341,14 @@ def __call__( Args: request (~.gcd_conversation_profile.SetSuggestionFeatureConfigRequest): The request object. The request message for - [ConversationProfiles.SetSuggestionFeature][]. + [ConversationProfiles.SetSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.SetSuggestionFeatureConfig]. 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: ~.operations_pb2.Operation: @@ -1092,6 +1361,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseSetSuggestionFeatureConfig._get_http_options() ) + request, metadata = self._interceptor.pre_set_suggestion_feature_config( request, metadata ) @@ -1108,6 +1378,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.dialogflow_v2.ConversationProfilesClient.SetSuggestionFeatureConfig", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "SetSuggestionFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._SetSuggestionFeatureConfig._get_response( self._host, @@ -1127,7 +1424,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_suggestion_feature_config(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.dialogflow_v2.ConversationProfilesClient.set_suggestion_feature_config", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "SetSuggestionFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConversationProfile( @@ -1166,7 +1485,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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Call the update conversation profile method over HTTP. @@ -1178,8 +1497,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: ~.gcd_conversation_profile.ConversationProfile: @@ -1191,6 +1512,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseUpdateConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_update_conversation_profile( request, metadata ) @@ -1207,6 +1529,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 = 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.dialogflow_v2.ConversationProfilesClient.UpdateConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "UpdateConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._UpdateConversationProfile._get_response( self._host, @@ -1228,7 +1577,31 @@ def __call__( pb_resp = gcd_conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation_profile.ConversationProfile.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.dialogflow_v2.ConversationProfilesClient.update_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "UpdateConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1346,7 +1719,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. @@ -1356,8 +1729,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. @@ -1366,6 +1741,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1376,6 +1752,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.dialogflow_v2.ConversationProfilesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._GetLocation._get_response( self._host, @@ -1395,6 +1798,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.dialogflow_v2.ConversationProfilesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1436,7 +1860,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. @@ -1446,8 +1870,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. @@ -1456,6 +1882,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1466,6 +1893,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.dialogflow_v2.ConversationProfilesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListLocations._get_response( self._host, @@ -1485,6 +1939,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.dialogflow_v2.ConversationProfilesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1526,7 +2001,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1536,13 +2011,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 = ( _BaseConversationProfilesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1555,6 +2033,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.dialogflow_v2.ConversationProfilesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._CancelOperation._get_response( self._host, @@ -1611,7 +2116,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1621,8 +2126,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: operations_pb2.Operation: Response from GetOperation method. @@ -1631,6 +2138,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1641,6 +2149,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.dialogflow_v2.ConversationProfilesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._GetOperation._get_response( self._host, @@ -1660,6 +2195,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ConversationProfilesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1701,7 +2257,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1711,8 +2267,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1721,6 +2279,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1731,6 +2290,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.dialogflow_v2.ConversationProfilesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListOperations._get_response( self._host, @@ -1750,6 +2336,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ConversationProfilesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.ConversationProfiles", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/async_client.py index 0e28e8ba8824..1c8f2bbe6e28 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ConversationsTransport from .transports.grpc_asyncio import ConversationsGrpcAsyncIOTransport +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 ConversationsAsyncClient: """Service for managing @@ -298,6 +308,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.dialogflow_v2.ConversationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "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.dialogflow.v2.Conversations", + "credentialsType": None, + }, + ) + async def create_conversation( self, request: Optional[ @@ -308,7 +340,7 @@ async def create_conversation( conversation: Optional[gcd_conversation.Conversation] = 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]]] = (), ) -> gcd_conversation.Conversation: r"""Creates a new conversation. Conversations are auto-completed after 24 hours. @@ -382,8 +414,10 @@ async def sample_create_conversation(): 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.dialogflow_v2.types.Conversation: @@ -451,7 +485,7 @@ async def list_conversations( 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.ListConversationsAsyncPager: r"""Returns the list of all conversations in the specified project. @@ -498,8 +532,10 @@ async def sample_list_conversations(): 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.dialogflow_v2.services.conversations.pagers.ListConversationsAsyncPager: @@ -574,7 +610,7 @@ async def get_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Retrieves the specific conversation. @@ -618,8 +654,10 @@ async def sample_get_conversation(): 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.dialogflow_v2.types.Conversation: @@ -685,7 +723,7 @@ async def complete_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Completes the specified conversation. Finished conversations are purged from the database after 30 @@ -732,8 +770,10 @@ async def sample_complete_conversation(): 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.dialogflow_v2.types.Conversation: @@ -799,7 +839,7 @@ async def list_messages( 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.ListMessagesAsyncPager: r"""Lists messages that belong to a given conversation. ``messages`` are ordered by ``create_time`` in descending order. To fetch @@ -849,8 +889,10 @@ async def sample_list_messages(): 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.dialogflow_v2.services.conversations.pagers.ListMessagesAsyncPager: @@ -927,7 +969,7 @@ async def suggest_conversation_summary( conversation: 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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Suggests summary for a conversation based on specific historical messages. The range of the messages to be @@ -974,8 +1016,10 @@ async def sample_suggest_conversation_summary(): 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.dialogflow_v2.types.SuggestConversationSummaryResponse: @@ -1039,7 +1083,7 @@ async def generate_stateless_summary( *, 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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Generates and returns a summary for a conversation that does not have a resource created for it. @@ -1085,8 +1129,10 @@ async def sample_generate_stateless_summary(): 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.dialogflow_v2.types.GenerateStatelessSummaryResponse: @@ -1141,7 +1187,7 @@ async def generate_stateless_suggestion( *, 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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Generates and returns a suggestion for a conversation that does not have a resource created for it. @@ -1179,8 +1225,10 @@ async def sample_generate_stateless_suggestion(): 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.dialogflow_v2.types.GenerateStatelessSuggestionResponse: @@ -1226,7 +1274,7 @@ async def search_knowledge( *, 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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Get answers for the given query based on knowledge documents. @@ -1271,8 +1319,10 @@ async def sample_search_knowledge(): 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.dialogflow_v2.types.SearchKnowledgeResponse: @@ -1318,7 +1368,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1329,8 +1379,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1371,7 +1423,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1382,8 +1434,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1424,7 +1478,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1439,8 +1493,10 @@ async def cancel_operation( 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: None """ @@ -1477,7 +1533,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. @@ -1488,8 +1544,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. @@ -1530,7 +1588,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. @@ -1541,8 +1599,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-dialogflow/google/cloud/dialogflow_v2/services/conversations/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/client.py index 1b77eda78a2b..17fa73983973 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -812,6 +822,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( @@ -877,6 +891,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.dialogflow_v2.ConversationsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "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.dialogflow.v2.Conversations", + "credentialsType": None, + }, + ) + def create_conversation( self, request: Optional[ @@ -887,7 +924,7 @@ def create_conversation( conversation: Optional[gcd_conversation.Conversation] = 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]]] = (), ) -> gcd_conversation.Conversation: r"""Creates a new conversation. Conversations are auto-completed after 24 hours. @@ -961,8 +998,10 @@ def sample_create_conversation(): 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.dialogflow_v2.types.Conversation: @@ -1027,7 +1066,7 @@ def list_conversations( 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.ListConversationsPager: r"""Returns the list of all conversations in the specified project. @@ -1074,8 +1113,10 @@ def sample_list_conversations(): 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.dialogflow_v2.services.conversations.pagers.ListConversationsPager: @@ -1147,7 +1188,7 @@ def get_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Retrieves the specific conversation. @@ -1191,8 +1232,10 @@ def sample_get_conversation(): 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.dialogflow_v2.types.Conversation: @@ -1255,7 +1298,7 @@ def complete_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Completes the specified conversation. Finished conversations are purged from the database after 30 @@ -1302,8 +1345,10 @@ def sample_complete_conversation(): 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.dialogflow_v2.types.Conversation: @@ -1366,7 +1411,7 @@ def list_messages( 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.ListMessagesPager: r"""Lists messages that belong to a given conversation. ``messages`` are ordered by ``create_time`` in descending order. To fetch @@ -1416,8 +1461,10 @@ def sample_list_messages(): 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.dialogflow_v2.services.conversations.pagers.ListMessagesPager: @@ -1491,7 +1538,7 @@ def suggest_conversation_summary( conversation: 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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Suggests summary for a conversation based on specific historical messages. The range of the messages to be @@ -1538,8 +1585,10 @@ def sample_suggest_conversation_summary(): 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.dialogflow_v2.types.SuggestConversationSummaryResponse: @@ -1602,7 +1651,7 @@ def generate_stateless_summary( *, 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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Generates and returns a summary for a conversation that does not have a resource created for it. @@ -1648,8 +1697,10 @@ def sample_generate_stateless_summary(): 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.dialogflow_v2.types.GenerateStatelessSummaryResponse: @@ -1704,7 +1755,7 @@ def generate_stateless_suggestion( *, 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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Generates and returns a suggestion for a conversation that does not have a resource created for it. @@ -1742,8 +1793,10 @@ def sample_generate_stateless_suggestion(): 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.dialogflow_v2.types.GenerateStatelessSuggestionResponse: @@ -1789,7 +1842,7 @@ def search_knowledge( *, 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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Get answers for the given query based on knowledge documents. @@ -1834,8 +1887,10 @@ def sample_search_knowledge(): 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.dialogflow_v2.types.SearchKnowledgeResponse: @@ -1892,7 +1947,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1903,8 +1958,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1945,7 +2002,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1956,8 +2013,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1998,7 +2057,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2013,8 +2072,10 @@ def cancel_operation( 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: None """ @@ -2051,7 +2112,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. @@ -2062,8 +2123,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. @@ -2104,7 +2167,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. @@ -2115,8 +2178,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-dialogflow/google/cloud/dialogflow_v2/services/conversations/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/pagers.py index 19b8713d5fa9..55e38151b25f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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 = conversation.ListConversationsRequest(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 = conversation.ListConversationsRequest(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 = conversation.ListMessagesRequest(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 = conversation.ListMessagesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py index ec8fc5f6cf00..3ea58fd3f053 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import conversation from google.cloud.dialogflow_v2.types import conversation as gcd_conversation from .base import DEFAULT_CLIENT_INFO, ConversationsTransport +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.dialogflow.v2.Conversations", + "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.dialogflow.v2.Conversations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationsGrpcTransport(ConversationsTransport): """gRPC backend transport for Conversations. @@ -183,7 +264,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 @@ -279,7 +365,7 @@ def create_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation" not in self._stubs: - self._stubs["create_conversation"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/CreateConversation", request_serializer=gcd_conversation.CreateConversationRequest.serialize, response_deserializer=gcd_conversation.Conversation.deserialize, @@ -308,7 +394,7 @@ def list_conversations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversations" not in self._stubs: - self._stubs["list_conversations"] = self.grpc_channel.unary_unary( + self._stubs["list_conversations"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/ListConversations", request_serializer=conversation.ListConversationsRequest.serialize, response_deserializer=conversation.ListConversationsResponse.deserialize, @@ -334,7 +420,7 @@ def get_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation" not in self._stubs: - self._stubs["get_conversation"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GetConversation", request_serializer=conversation.GetConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -364,7 +450,7 @@ def complete_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_conversation" not in self._stubs: - self._stubs["complete_conversation"] = self.grpc_channel.unary_unary( + self._stubs["complete_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/CompleteConversation", request_serializer=conversation.CompleteConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -396,7 +482,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/ListMessages", request_serializer=conversation.ListMessagesRequest.serialize, response_deserializer=conversation.ListMessagesResponse.deserialize, @@ -427,7 +513,9 @@ def suggest_conversation_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_conversation_summary" not in self._stubs: - self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "suggest_conversation_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/SuggestConversationSummary", request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize, response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize, @@ -457,7 +545,9 @@ def generate_stateless_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stateless_summary" not in self._stubs: - self._stubs["generate_stateless_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_stateless_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GenerateStatelessSummary", request_serializer=conversation.GenerateStatelessSummaryRequest.serialize, response_deserializer=conversation.GenerateStatelessSummaryResponse.deserialize, @@ -489,7 +579,7 @@ def generate_stateless_suggestion( if "generate_stateless_suggestion" not in self._stubs: self._stubs[ "generate_stateless_suggestion" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GenerateStatelessSuggestion", request_serializer=conversation.GenerateStatelessSuggestionRequest.serialize, response_deserializer=conversation.GenerateStatelessSuggestionResponse.deserialize, @@ -518,7 +608,7 @@ def search_knowledge( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_knowledge" not in self._stubs: - self._stubs["search_knowledge"] = self.grpc_channel.unary_unary( + self._stubs["search_knowledge"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/SearchKnowledge", request_serializer=conversation.SearchKnowledgeRequest.serialize, response_deserializer=conversation.SearchKnowledgeResponse.deserialize, @@ -526,7 +616,7 @@ def search_knowledge( return self._stubs["search_knowledge"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -538,7 +628,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -555,7 +645,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +664,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -593,7 +683,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, @@ -610,7 +700,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-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py index f60fd7a838ba..69c819701b35 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import conversation from google.cloud.dialogflow_v2.types import conversation as gcd_conversation @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationsTransport from .grpc import ConversationsGrpcTransport +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.dialogflow.v2.Conversations", + "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.dialogflow.v2.Conversations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationsGrpcAsyncIOTransport(ConversationsTransport): """gRPC AsyncIO backend transport for Conversations. @@ -230,10 +312,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 @@ -288,7 +373,7 @@ def create_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation" not in self._stubs: - self._stubs["create_conversation"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/CreateConversation", request_serializer=gcd_conversation.CreateConversationRequest.serialize, response_deserializer=gcd_conversation.Conversation.deserialize, @@ -318,7 +403,7 @@ def list_conversations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversations" not in self._stubs: - self._stubs["list_conversations"] = self.grpc_channel.unary_unary( + self._stubs["list_conversations"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/ListConversations", request_serializer=conversation.ListConversationsRequest.serialize, response_deserializer=conversation.ListConversationsResponse.deserialize, @@ -346,7 +431,7 @@ def get_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation" not in self._stubs: - self._stubs["get_conversation"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GetConversation", request_serializer=conversation.GetConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -376,7 +461,7 @@ def complete_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_conversation" not in self._stubs: - self._stubs["complete_conversation"] = self.grpc_channel.unary_unary( + self._stubs["complete_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/CompleteConversation", request_serializer=conversation.CompleteConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -408,7 +493,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/ListMessages", request_serializer=conversation.ListMessagesRequest.serialize, response_deserializer=conversation.ListMessagesResponse.deserialize, @@ -439,7 +524,9 @@ def suggest_conversation_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_conversation_summary" not in self._stubs: - self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "suggest_conversation_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/SuggestConversationSummary", request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize, response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize, @@ -469,7 +556,9 @@ def generate_stateless_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stateless_summary" not in self._stubs: - self._stubs["generate_stateless_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_stateless_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GenerateStatelessSummary", request_serializer=conversation.GenerateStatelessSummaryRequest.serialize, response_deserializer=conversation.GenerateStatelessSummaryResponse.deserialize, @@ -501,7 +590,7 @@ def generate_stateless_suggestion( if "generate_stateless_suggestion" not in self._stubs: self._stubs[ "generate_stateless_suggestion" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/GenerateStatelessSuggestion", request_serializer=conversation.GenerateStatelessSuggestionRequest.serialize, response_deserializer=conversation.GenerateStatelessSuggestionResponse.deserialize, @@ -531,7 +620,7 @@ def search_knowledge( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_knowledge" not in self._stubs: - self._stubs["search_knowledge"] = self.grpc_channel.unary_unary( + self._stubs["search_knowledge"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Conversations/SearchKnowledge", request_serializer=conversation.SearchKnowledgeRequest.serialize, response_deserializer=conversation.SearchKnowledgeResponse.deserialize, @@ -619,7 +708,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: @@ -635,7 +724,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -652,7 +741,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -671,7 +760,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -690,7 +779,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, @@ -707,7 +796,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-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/rest.py index 09c30d6218eb..dedf7d20919f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/conversations/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 @@ -40,6 +40,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, @@ -144,8 +152,11 @@ def post_suggest_conversation_summary(self, response): def pre_complete_conversation( self, request: conversation.CompleteConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.CompleteConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.CompleteConversationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for complete_conversation Override in a subclass to manipulate the request or metadata @@ -167,8 +178,11 @@ def post_complete_conversation( def pre_create_conversation( self, request: gcd_conversation.CreateConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_conversation.CreateConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_conversation.CreateConversationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_conversation Override in a subclass to manipulate the request or metadata @@ -190,9 +204,10 @@ def post_create_conversation( def pre_generate_stateless_suggestion( self, request: conversation.GenerateStatelessSuggestionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation.GenerateStatelessSuggestionRequest, Sequence[Tuple[str, str]] + conversation.GenerateStatelessSuggestionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stateless_suggestion @@ -215,8 +230,11 @@ def post_generate_stateless_suggestion( def pre_generate_stateless_summary( self, request: conversation.GenerateStatelessSummaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.GenerateStatelessSummaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.GenerateStatelessSummaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_stateless_summary Override in a subclass to manipulate the request or metadata @@ -238,8 +256,10 @@ def post_generate_stateless_summary( def pre_get_conversation( self, request: conversation.GetConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.GetConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.GetConversationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_conversation Override in a subclass to manipulate the request or metadata @@ -261,8 +281,10 @@ def post_get_conversation( def pre_list_conversations( self, request: conversation.ListConversationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.ListConversationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.ListConversationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_conversations Override in a subclass to manipulate the request or metadata @@ -284,8 +306,10 @@ def post_list_conversations( def pre_list_messages( self, request: conversation.ListMessagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.ListMessagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.ListMessagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_messages Override in a subclass to manipulate the request or metadata @@ -307,8 +331,10 @@ def post_list_messages( def pre_search_knowledge( self, request: conversation.SearchKnowledgeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.SearchKnowledgeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.SearchKnowledgeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_knowledge Override in a subclass to manipulate the request or metadata @@ -330,9 +356,10 @@ def post_search_knowledge( def pre_suggest_conversation_summary( self, request: gcd_conversation.SuggestConversationSummaryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_conversation.SuggestConversationSummaryRequest, Sequence[Tuple[str, str]] + gcd_conversation.SuggestConversationSummaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for suggest_conversation_summary @@ -355,8 +382,10 @@ def post_suggest_conversation_summary( 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 @@ -378,8 +407,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 @@ -401,8 +432,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -422,8 +455,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -445,8 +480,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -588,7 +625,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]]] = (), ) -> conversation.Conversation: r"""Call the complete conversation method over HTTP. @@ -599,8 +636,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: ~.conversation.Conversation: @@ -617,6 +656,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseCompleteConversation._get_http_options() ) + request, metadata = self._interceptor.pre_complete_conversation( request, metadata ) @@ -633,6 +673,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 = 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.dialogflow_v2.ConversationsClient.CompleteConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "CompleteConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CompleteConversation._get_response( self._host, @@ -654,7 +721,29 @@ def __call__( pb_resp = conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.Conversation.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.dialogflow_v2.ConversationsClient.complete_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "CompleteConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversation( @@ -692,7 +781,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]]] = (), ) -> gcd_conversation.Conversation: r"""Call the create conversation method over HTTP. @@ -703,8 +792,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: ~.gcd_conversation.Conversation: @@ -721,6 +812,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseCreateConversation._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation( request, metadata ) @@ -737,6 +829,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 = 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.dialogflow_v2.ConversationsClient.CreateConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "CreateConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CreateConversation._get_response( self._host, @@ -758,7 +877,29 @@ def __call__( pb_resp = gcd_conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_conversation.Conversation.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.dialogflow_v2.ConversationsClient.create_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "CreateConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStatelessSuggestion( @@ -797,7 +938,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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Call the generate stateless suggestion method over HTTP. @@ -809,8 +950,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: ~.conversation.GenerateStatelessSuggestionResponse: @@ -822,6 +965,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGenerateStatelessSuggestion._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stateless_suggestion( request, metadata ) @@ -838,6 +982,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 = 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.dialogflow_v2.ConversationsClient.GenerateStatelessSuggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GenerateStatelessSuggestion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._GenerateStatelessSuggestion._get_response( @@ -861,7 +1032,33 @@ def __call__( pb_resp = conversation.GenerateStatelessSuggestionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stateless_suggestion(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation.GenerateStatelessSuggestionResponse.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.dialogflow_v2.ConversationsClient.generate_stateless_suggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GenerateStatelessSuggestion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStatelessSummary( @@ -900,7 +1097,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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Call the generate stateless summary method over HTTP. @@ -912,8 +1109,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: ~.conversation.GenerateStatelessSummaryResponse: @@ -925,6 +1124,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGenerateStatelessSummary._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stateless_summary( request, metadata ) @@ -941,6 +1141,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 = 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.dialogflow_v2.ConversationsClient.GenerateStatelessSummary", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GenerateStatelessSummary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._GenerateStatelessSummary._get_response( @@ -964,7 +1191,31 @@ def __call__( pb_resp = conversation.GenerateStatelessSummaryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stateless_summary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation.GenerateStatelessSummaryResponse.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.dialogflow_v2.ConversationsClient.generate_stateless_summary", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GenerateStatelessSummary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversation( @@ -1001,7 +1252,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]]] = (), ) -> conversation.Conversation: r"""Call the get conversation method over HTTP. @@ -1012,8 +1263,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: ~.conversation.Conversation: @@ -1030,6 +1283,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetConversation._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation( request, metadata ) @@ -1042,6 +1296,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 = 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.dialogflow_v2.ConversationsClient.GetConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetConversation._get_response( self._host, @@ -1062,7 +1343,29 @@ def __call__( pb_resp = conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.Conversation.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.dialogflow_v2.ConversationsClient.get_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversations( @@ -1099,7 +1402,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]]] = (), ) -> conversation.ListConversationsResponse: r"""Call the list conversations method over HTTP. @@ -1110,8 +1413,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: ~.conversation.ListConversationsResponse: @@ -1123,6 +1428,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListConversations._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversations( request, metadata ) @@ -1135,6 +1441,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 = 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.dialogflow_v2.ConversationsClient.ListConversations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListConversations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListConversations._get_response( self._host, @@ -1155,7 +1488,31 @@ def __call__( pb_resp = conversation.ListConversationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.ListConversationsResponse.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.dialogflow_v2.ConversationsClient.list_conversations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListConversations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMessages( @@ -1192,7 +1549,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]]] = (), ) -> conversation.ListMessagesResponse: r"""Call the list messages method over HTTP. @@ -1203,8 +1560,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: ~.conversation.ListMessagesResponse: @@ -1216,6 +1575,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListMessages._get_http_options() ) + request, metadata = self._interceptor.pre_list_messages(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListMessages._get_transcoded_request( http_options, request @@ -1226,6 +1586,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 = 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.dialogflow_v2.ConversationsClient.ListMessages", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListMessages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListMessages._get_response( self._host, @@ -1246,7 +1633,31 @@ def __call__( pb_resp = conversation.ListMessagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_messages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.ListMessagesResponse.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.dialogflow_v2.ConversationsClient.list_messages", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListMessages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchKnowledge( @@ -1284,7 +1695,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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Call the search knowledge method over HTTP. @@ -1295,8 +1706,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: ~.conversation.SearchKnowledgeResponse: @@ -1308,6 +1721,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseSearchKnowledge._get_http_options() ) + request, metadata = self._interceptor.pre_search_knowledge( request, metadata ) @@ -1324,6 +1738,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 = 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.dialogflow_v2.ConversationsClient.SearchKnowledge", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "SearchKnowledge", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._SearchKnowledge._get_response( self._host, @@ -1345,7 +1786,31 @@ def __call__( pb_resp = conversation.SearchKnowledgeResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_knowledge(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.SearchKnowledgeResponse.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.dialogflow_v2.ConversationsClient.search_knowledge", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "SearchKnowledge", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestConversationSummary( @@ -1384,7 +1849,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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Call the suggest conversation summary method over HTTP. @@ -1396,8 +1861,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: ~.gcd_conversation.SuggestConversationSummaryResponse: @@ -1409,6 +1876,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseSuggestConversationSummary._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_conversation_summary( request, metadata ) @@ -1425,6 +1893,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 = 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.dialogflow_v2.ConversationsClient.SuggestConversationSummary", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "SuggestConversationSummary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._SuggestConversationSummary._get_response( @@ -1448,7 +1943,33 @@ def __call__( pb_resp = gcd_conversation.SuggestConversationSummaryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_conversation_summary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation.SuggestConversationSummaryResponse.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.dialogflow_v2.ConversationsClient.suggest_conversation_summary", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "SuggestConversationSummary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1580,7 +2101,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. @@ -1590,8 +2111,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. @@ -1600,6 +2123,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1612,6 +2136,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.dialogflow_v2.ConversationsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetLocation._get_response( self._host, @@ -1631,6 +2182,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.dialogflow_v2.ConversationsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1671,7 +2243,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. @@ -1681,8 +2253,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. @@ -1691,6 +2265,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1701,6 +2276,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.dialogflow_v2.ConversationsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListLocations._get_response( self._host, @@ -1720,6 +2322,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.dialogflow_v2.ConversationsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1760,7 +2383,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1770,13 +2393,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 = ( _BaseConversationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1789,6 +2415,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.dialogflow_v2.ConversationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CancelOperation._get_response( self._host, @@ -1844,7 +2497,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1854,8 +2507,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: operations_pb2.Operation: Response from GetOperation method. @@ -1864,6 +2519,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1874,6 +2530,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.dialogflow_v2.ConversationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetOperation._get_response( self._host, @@ -1893,6 +2576,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ConversationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1933,7 +2637,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1943,8 +2647,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1953,6 +2659,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1963,6 +2670,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.dialogflow_v2.ConversationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListOperations._get_response( self._host, @@ -1982,6 +2716,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ConversationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Conversations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/async_client.py index 82e7fb1f51e4..e54527c5bb6b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DocumentsTransport from .transports.grpc_asyncio import DocumentsGrpcAsyncIOTransport +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 DocumentsAsyncClient: """Service for managing knowledge @@ -258,6 +268,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.dialogflow_v2.DocumentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "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.dialogflow.v2.Documents", + "credentialsType": None, + }, + ) + async def list_documents( self, request: Optional[Union[document.ListDocumentsRequest, dict]] = None, @@ -265,7 +297,7 @@ async def list_documents( 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.ListDocumentsAsyncPager: r"""Returns the list of all documents of the knowledge base. @@ -312,8 +344,10 @@ async def sample_list_documents(): 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.dialogflow_v2.services.documents.pagers.ListDocumentsAsyncPager: @@ -388,7 +422,7 @@ async def get_document( 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]]] = (), ) -> document.Document: r"""Retrieves the specified document. @@ -432,8 +466,10 @@ async def sample_get_document(): 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.dialogflow_v2.types.Document: @@ -502,7 +538,7 @@ async def create_document( document: Optional[gcd_document.Document] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new document. @@ -572,8 +608,10 @@ async def sample_create_document(): 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.api_core.operation_async.AsyncOperation: @@ -652,7 +690,7 @@ async def import_documents( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you @@ -714,8 +752,10 @@ async def sample_import_documents(): 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.api_core.operation_async.AsyncOperation: @@ -772,7 +812,7 @@ async def delete_document( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified document. @@ -830,8 +870,10 @@ async def sample_delete_document(): 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.api_core.operation_async.AsyncOperation: @@ -911,7 +953,7 @@ async def update_document( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified document. @@ -980,8 +1022,10 @@ async def sample_update_document(): 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.api_core.operation_async.AsyncOperation: @@ -1064,7 +1108,7 @@ async def reload_document( content_uri: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the @@ -1139,8 +1183,10 @@ async def sample_reload_document(): 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.api_core.operation_async.AsyncOperation: @@ -1219,7 +1265,7 @@ async def export_document( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports a smart messaging candidate document into the specified destination. @@ -1270,8 +1316,10 @@ async def sample_export_document(): 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.api_core.operation_async.AsyncOperation: @@ -1334,7 +1382,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1345,8 +1393,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1387,7 +1437,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1398,8 +1448,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1440,7 +1492,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1455,8 +1507,10 @@ async def cancel_operation( 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: None """ @@ -1493,7 +1547,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. @@ -1504,8 +1558,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. @@ -1546,7 +1602,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. @@ -1557,8 +1613,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-dialogflow/google/cloud/dialogflow_v2/services/documents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/client.py index dd134e33c832..b8aa3313dbd6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -586,6 +596,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( @@ -648,6 +662,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.dialogflow_v2.DocumentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "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.dialogflow.v2.Documents", + "credentialsType": None, + }, + ) + def list_documents( self, request: Optional[Union[document.ListDocumentsRequest, dict]] = None, @@ -655,7 +692,7 @@ def list_documents( 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.ListDocumentsPager: r"""Returns the list of all documents of the knowledge base. @@ -702,8 +739,10 @@ def sample_list_documents(): 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.dialogflow_v2.services.documents.pagers.ListDocumentsPager: @@ -775,7 +814,7 @@ def get_document( 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]]] = (), ) -> document.Document: r"""Retrieves the specified document. @@ -819,8 +858,10 @@ def sample_get_document(): 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.dialogflow_v2.types.Document: @@ -886,7 +927,7 @@ def create_document( document: Optional[gcd_document.Document] = 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]]] = (), ) -> operation.Operation: r"""Creates a new document. @@ -956,8 +997,10 @@ def sample_create_document(): 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.api_core.operation.Operation: @@ -1033,7 +1076,7 @@ def import_documents( *, 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]]] = (), ) -> operation.Operation: r"""Creates documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you @@ -1095,8 +1138,10 @@ def sample_import_documents(): 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.api_core.operation.Operation: @@ -1151,7 +1196,7 @@ def delete_document( 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]]] = (), ) -> operation.Operation: r"""Deletes the specified document. @@ -1209,8 +1254,10 @@ def sample_delete_document(): 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.api_core.operation.Operation: @@ -1287,7 +1334,7 @@ def update_document( 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]]] = (), ) -> operation.Operation: r"""Updates the specified document. @@ -1356,8 +1403,10 @@ def sample_update_document(): 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.api_core.operation.Operation: @@ -1437,7 +1486,7 @@ def reload_document( content_uri: 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]]] = (), ) -> operation.Operation: r"""Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the @@ -1512,8 +1561,10 @@ def sample_reload_document(): 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.api_core.operation.Operation: @@ -1589,7 +1640,7 @@ def export_document( *, 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]]] = (), ) -> operation.Operation: r"""Exports a smart messaging candidate document into the specified destination. @@ -1640,8 +1691,10 @@ def sample_export_document(): 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.api_core.operation.Operation: @@ -1715,7 +1768,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1726,8 +1779,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1768,7 +1823,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1779,8 +1834,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1821,7 +1878,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1836,8 +1893,10 @@ def cancel_operation( 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: None """ @@ -1874,7 +1933,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. @@ -1885,8 +1944,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. @@ -1927,7 +1988,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. @@ -1938,8 +1999,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-dialogflow/google/cloud/dialogflow_v2/services/documents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/pagers.py index f0ddbf2f8b1c..b876c31b1076 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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 = document.ListDocumentsRequest(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 = document.ListDocumentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc.py index eb5b825a68fb..091b678053f2 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import document from google.cloud.dialogflow_v2.types import document as gcd_document from .base import DEFAULT_CLIENT_INFO, DocumentsTransport +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.dialogflow.v2.Documents", + "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.dialogflow.v2.Documents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DocumentsGrpcTransport(DocumentsTransport): """gRPC backend transport for Documents. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ListDocuments", request_serializer=document.ListDocumentsRequest.serialize, response_deserializer=document.ListDocumentsResponse.deserialize, @@ -299,7 +387,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/GetDocument", request_serializer=document.GetDocumentRequest.serialize, response_deserializer=document.Document.deserialize, @@ -334,7 +422,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/CreateDocument", request_serializer=gcd_document.CreateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +460,7 @@ def import_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_documents" not in self._stubs: - self._stubs["import_documents"] = self.grpc_channel.unary_unary( + self._stubs["import_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ImportDocuments", request_serializer=document.ImportDocumentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/DeleteDocument", request_serializer=document.DeleteDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -443,7 +531,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/UpdateDocument", request_serializer=gcd_document.UpdateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +573,7 @@ def reload_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reload_document" not in self._stubs: - self._stubs["reload_document"] = self.grpc_channel.unary_unary( + self._stubs["reload_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ReloadDocument", request_serializer=document.ReloadDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -521,7 +609,7 @@ def export_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_document" not in self._stubs: - self._stubs["export_document"] = self.grpc_channel.unary_unary( + self._stubs["export_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ExportDocument", request_serializer=document.ExportDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -529,7 +617,7 @@ def export_document( return self._stubs["export_document"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -541,7 +629,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -558,7 +646,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -577,7 +665,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -596,7 +684,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, @@ -613,7 +701,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-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py index be1b840f16f5..06f81dd92039 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import document from google.cloud.dialogflow_v2.types import document as gcd_document @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, DocumentsTransport from .grpc import DocumentsGrpcTransport +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.dialogflow.v2.Documents", + "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.dialogflow.v2.Documents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DocumentsGrpcAsyncIOTransport(DocumentsTransport): """gRPC AsyncIO backend transport for Documents. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ListDocuments", request_serializer=document.ListDocumentsRequest.serialize, response_deserializer=document.ListDocumentsResponse.deserialize, @@ -311,7 +396,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/GetDocument", request_serializer=document.GetDocumentRequest.serialize, response_deserializer=document.Document.deserialize, @@ -348,7 +433,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/CreateDocument", request_serializer=gcd_document.CreateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -388,7 +473,7 @@ def import_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_documents" not in self._stubs: - self._stubs["import_documents"] = self.grpc_channel.unary_unary( + self._stubs["import_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ImportDocuments", request_serializer=document.ImportDocumentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -426,7 +511,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/DeleteDocument", request_serializer=document.DeleteDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +548,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/UpdateDocument", request_serializer=gcd_document.UpdateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +592,7 @@ def reload_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reload_document" not in self._stubs: - self._stubs["reload_document"] = self.grpc_channel.unary_unary( + self._stubs["reload_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ReloadDocument", request_serializer=document.ReloadDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def export_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_document" not in self._stubs: - self._stubs["export_document"] = self.grpc_channel.unary_unary( + self._stubs["export_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Documents/ExportDocument", request_serializer=document.ExportDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -628,7 +713,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: @@ -644,7 +729,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -661,7 +746,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -680,7 +765,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -699,7 +784,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, @@ -716,7 +801,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-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/rest.py index ce74b2b41971..62f13c0eb9a0 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/documents/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 @@ -40,6 +40,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, @@ -136,8 +144,10 @@ def post_update_document(self, response): def pre_create_document( self, request: gcd_document.CreateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_document.CreateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_document.CreateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_document Override in a subclass to manipulate the request or metadata @@ -159,8 +169,8 @@ def post_create_document( def pre_delete_document( self, request: document.DeleteDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.DeleteDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.DeleteDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_document Override in a subclass to manipulate the request or metadata @@ -182,8 +192,8 @@ def post_delete_document( def pre_export_document( self, request: document.ExportDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ExportDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.ExportDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_document Override in a subclass to manipulate the request or metadata @@ -203,8 +213,10 @@ def post_export_document( return response def pre_get_document( - self, request: document.GetDocumentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[document.GetDocumentRequest, Sequence[Tuple[str, str]]]: + self, + request: document.GetDocumentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.GetDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_document Override in a subclass to manipulate the request or metadata @@ -224,8 +236,10 @@ def post_get_document(self, response: document.Document) -> document.Document: def pre_import_documents( self, request: document.ImportDocumentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ImportDocumentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + document.ImportDocumentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_documents Override in a subclass to manipulate the request or metadata @@ -247,8 +261,8 @@ def post_import_documents( def pre_list_documents( self, request: document.ListDocumentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ListDocumentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.ListDocumentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_documents Override in a subclass to manipulate the request or metadata @@ -270,8 +284,8 @@ def post_list_documents( def pre_reload_document( self, request: document.ReloadDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ReloadDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.ReloadDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reload_document Override in a subclass to manipulate the request or metadata @@ -293,8 +307,10 @@ def post_reload_document( def pre_update_document( self, request: gcd_document.UpdateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_document.UpdateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_document.UpdateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_document Override in a subclass to manipulate the request or metadata @@ -316,8 +332,10 @@ def post_update_document( 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 @@ -339,8 +357,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 @@ -362,8 +382,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -383,8 +405,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -406,8 +430,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -608,7 +634,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create document method over HTTP. @@ -619,8 +645,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: ~.operations_pb2.Operation: @@ -633,6 +661,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseCreateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_create_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseCreateDocument._get_transcoded_request( @@ -653,6 +682,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.dialogflow_v2.DocumentsClient.CreateDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "CreateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._CreateDocument._get_response( self._host, @@ -672,7 +728,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_document(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.dialogflow_v2.DocumentsClient.create_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "CreateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDocument( @@ -709,7 +787,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete document method over HTTP. @@ -720,8 +798,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: ~.operations_pb2.Operation: @@ -734,6 +814,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseDeleteDocument._get_http_options() ) + request, metadata = self._interceptor.pre_delete_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseDeleteDocument._get_transcoded_request( @@ -748,6 +829,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.dialogflow_v2.DocumentsClient.DeleteDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "DeleteDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._DeleteDocument._get_response( self._host, @@ -766,7 +874,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_document(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.dialogflow_v2.DocumentsClient.delete_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "DeleteDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportDocument( @@ -804,7 +934,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export document method over HTTP. @@ -815,8 +945,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: ~.operations_pb2.Operation: @@ -829,6 +961,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseExportDocument._get_http_options() ) + request, metadata = self._interceptor.pre_export_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseExportDocument._get_transcoded_request( @@ -849,6 +982,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.dialogflow_v2.DocumentsClient.ExportDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ExportDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ExportDocument._get_response( self._host, @@ -868,7 +1028,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_document(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.dialogflow_v2.DocumentsClient.export_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ExportDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDocument(_BaseDocumentsRestTransport._BaseGetDocument, DocumentsRestStub): @@ -903,7 +1085,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]]] = (), ) -> document.Document: r"""Call the get document method over HTTP. @@ -914,8 +1096,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: ~.document.Document: @@ -934,6 +1118,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetDocument._get_http_options() ) + request, metadata = self._interceptor.pre_get_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetDocument._get_transcoded_request( @@ -948,6 +1133,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.dialogflow_v2.DocumentsClient.GetDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetDocument._get_response( self._host, @@ -968,7 +1180,29 @@ def __call__( pb_resp = document.Document.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = document.Document.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.dialogflow_v2.DocumentsClient.get_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportDocuments( @@ -1006,7 +1240,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import documents method over HTTP. @@ -1017,8 +1251,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: ~.operations_pb2.Operation: @@ -1031,6 +1267,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseImportDocuments._get_http_options() ) + request, metadata = self._interceptor.pre_import_documents( request, metadata ) @@ -1051,6 +1288,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.dialogflow_v2.DocumentsClient.ImportDocuments", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ImportDocuments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ImportDocuments._get_response( self._host, @@ -1070,7 +1334,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_documents(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.dialogflow_v2.DocumentsClient.import_documents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ImportDocuments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDocuments( @@ -1107,7 +1393,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]]] = (), ) -> document.ListDocumentsResponse: r"""Call the list documents method over HTTP. @@ -1118,8 +1404,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: ~.document.ListDocumentsResponse: @@ -1131,6 +1419,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListDocuments._get_http_options() ) + request, metadata = self._interceptor.pre_list_documents(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListDocuments._get_transcoded_request( @@ -1145,6 +1434,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.dialogflow_v2.DocumentsClient.ListDocuments", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListDocuments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListDocuments._get_response( self._host, @@ -1165,7 +1481,29 @@ def __call__( pb_resp = document.ListDocumentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_documents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = document.ListDocumentsResponse.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.dialogflow_v2.DocumentsClient.list_documents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListDocuments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReloadDocument( @@ -1203,7 +1541,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]]] = (), ) -> operations_pb2.Operation: r"""Call the reload document method over HTTP. @@ -1214,8 +1552,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: ~.operations_pb2.Operation: @@ -1228,6 +1568,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseReloadDocument._get_http_options() ) + request, metadata = self._interceptor.pre_reload_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseReloadDocument._get_transcoded_request( @@ -1248,6 +1589,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.dialogflow_v2.DocumentsClient.ReloadDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ReloadDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ReloadDocument._get_response( self._host, @@ -1267,7 +1635,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reload_document(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.dialogflow_v2.DocumentsClient.reload_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ReloadDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDocument( @@ -1305,7 +1695,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update document method over HTTP. @@ -1316,8 +1706,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: ~.operations_pb2.Operation: @@ -1330,6 +1722,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseUpdateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_update_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseUpdateDocument._get_transcoded_request( @@ -1350,6 +1743,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.dialogflow_v2.DocumentsClient.UpdateDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "UpdateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._UpdateDocument._get_response( self._host, @@ -1369,7 +1789,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_document(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.dialogflow_v2.DocumentsClient.update_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "UpdateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1472,7 +1914,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. @@ -1482,8 +1924,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. @@ -1492,6 +1936,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1506,6 +1951,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.dialogflow_v2.DocumentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetLocation._get_response( self._host, @@ -1525,6 +1997,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.dialogflow_v2.DocumentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1565,7 +2058,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. @@ -1575,8 +2068,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. @@ -1585,6 +2080,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1599,6 +2095,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.dialogflow_v2.DocumentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListLocations._get_response( self._host, @@ -1618,6 +2141,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.dialogflow_v2.DocumentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1658,7 +2202,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1668,13 +2212,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 = ( _BaseDocumentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1689,6 +2236,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.dialogflow_v2.DocumentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._CancelOperation._get_response( self._host, @@ -1744,7 +2318,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1754,8 +2328,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: operations_pb2.Operation: Response from GetOperation method. @@ -1764,6 +2340,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1778,6 +2355,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.dialogflow_v2.DocumentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetOperation._get_response( self._host, @@ -1797,6 +2401,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.DocumentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1837,7 +2462,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1847,8 +2472,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1857,6 +2484,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1871,6 +2499,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.dialogflow_v2.DocumentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListOperations._get_response( self._host, @@ -1890,6 +2545,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.DocumentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Documents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/async_client.py index a22d467c6412..a64eac78ceba 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport from .transports.grpc_asyncio import EncryptionSpecServiceGrpcAsyncIOTransport +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 EncryptionSpecServiceAsyncClient: """Manages encryption spec settings for Dialogflow and Agent @@ -271,6 +281,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.dialogflow_v2.EncryptionSpecServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "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.dialogflow.v2.EncryptionSpecService", + "credentialsType": None, + }, + ) + async def get_encryption_spec( self, request: Optional[Union[encryption_spec.GetEncryptionSpecRequest, dict]] = None, @@ -278,7 +310,7 @@ async def get_encryption_spec( 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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Gets location-level encryption key specification. @@ -322,8 +354,10 @@ async def sample_get_encryption_spec(): 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.dialogflow_v2.types.EncryptionSpec: @@ -387,7 +421,7 @@ async def initialize_encryption_spec( encryption_spec: Optional[gcd_encryption_spec.EncryptionSpec] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Initializes a location-level encryption key specification. An error will be thrown if the location @@ -448,8 +482,10 @@ async def sample_initialize_encryption_spec(): 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.api_core.operation_async.AsyncOperation: @@ -523,7 +559,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -534,8 +570,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -576,7 +614,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -587,8 +625,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -629,7 +669,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -644,8 +684,10 @@ async def cancel_operation( 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: None """ @@ -682,7 +724,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. @@ -693,8 +735,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. @@ -735,7 +779,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. @@ -746,8 +790,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-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/client.py index d6ffafae5a17..108046c38a84 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -589,6 +599,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( @@ -655,6 +669,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.dialogflow_v2.EncryptionSpecServiceClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "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.dialogflow.v2.EncryptionSpecService", + "credentialsType": None, + }, + ) + def get_encryption_spec( self, request: Optional[Union[encryption_spec.GetEncryptionSpecRequest, dict]] = None, @@ -662,7 +699,7 @@ def get_encryption_spec( 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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Gets location-level encryption key specification. @@ -706,8 +743,10 @@ def sample_get_encryption_spec(): 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.dialogflow_v2.types.EncryptionSpec: @@ -768,7 +807,7 @@ def initialize_encryption_spec( encryption_spec: Optional[gcd_encryption_spec.EncryptionSpec] = 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]]] = (), ) -> operation.Operation: r"""Initializes a location-level encryption key specification. An error will be thrown if the location @@ -829,8 +868,10 @@ def sample_initialize_encryption_spec(): 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.api_core.operation.Operation: @@ -916,7 +957,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -927,8 +968,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -969,7 +1012,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -980,8 +1023,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1022,7 +1067,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1037,8 +1082,10 @@ def cancel_operation( 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: None """ @@ -1075,7 +1122,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. @@ -1086,8 +1133,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. @@ -1128,7 +1177,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. @@ -1139,8 +1188,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-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc.py index 4d8ce880ba0a..2e5c1910c7fd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import encryption_spec as gcd_encryption_spec from google.cloud.dialogflow_v2.types import encryption_spec from .base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport +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.dialogflow.v2.EncryptionSpecService", + "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.dialogflow.v2.EncryptionSpecService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EncryptionSpecServiceGrpcTransport(EncryptionSpecServiceTransport): """gRPC backend transport for EncryptionSpecService. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def get_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_encryption_spec" not in self._stubs: - self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_encryption_spec"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EncryptionSpecService/GetEncryptionSpec", request_serializer=encryption_spec.GetEncryptionSpecRequest.serialize, response_deserializer=encryption_spec.EncryptionSpec.deserialize, @@ -308,7 +396,9 @@ def initialize_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "initialize_encryption_spec" not in self._stubs: - self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs[ + "initialize_encryption_spec" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EncryptionSpecService/InitializeEncryptionSpec", request_serializer=gcd_encryption_spec.InitializeEncryptionSpecRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +406,7 @@ def initialize_encryption_spec( return self._stubs["initialize_encryption_spec"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -328,7 +418,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -345,7 +435,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -364,7 +454,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -383,7 +473,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, @@ -400,7 +490,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-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc_asyncio.py index 8c2ef25bc417..cd4278edd3b5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import encryption_spec as gcd_encryption_spec from google.cloud.dialogflow_v2.types import encryption_spec @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport from .grpc import EncryptionSpecServiceGrpcTransport +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.dialogflow.v2.EncryptionSpecService", + "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.dialogflow.v2.EncryptionSpecService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EncryptionSpecServiceGrpcAsyncIOTransport(EncryptionSpecServiceTransport): """gRPC AsyncIO backend transport for EncryptionSpecService. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_encryption_spec" not in self._stubs: - self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_encryption_spec"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EncryptionSpecService/GetEncryptionSpec", request_serializer=encryption_spec.GetEncryptionSpecRequest.serialize, response_deserializer=encryption_spec.EncryptionSpec.deserialize, @@ -320,7 +405,9 @@ def initialize_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "initialize_encryption_spec" not in self._stubs: - self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs[ + "initialize_encryption_spec" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EncryptionSpecService/InitializeEncryptionSpec", request_serializer=gcd_encryption_spec.InitializeEncryptionSpecRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,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: @@ -389,7 +476,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -406,7 +493,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -425,7 +512,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -444,7 +531,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, @@ -461,7 +548,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-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/rest.py index 3ba0a6ea01f3..7f490c22127e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/encryption_spec_service/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 @@ -40,6 +40,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, @@ -88,8 +96,11 @@ def post_initialize_encryption_spec(self, response): def pre_get_encryption_spec( self, request: encryption_spec.GetEncryptionSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[encryption_spec.GetEncryptionSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + encryption_spec.GetEncryptionSpecRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_encryption_spec Override in a subclass to manipulate the request or metadata @@ -111,9 +122,10 @@ def post_get_encryption_spec( def pre_initialize_encryption_spec( self, request: gcd_encryption_spec.InitializeEncryptionSpecRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_encryption_spec.InitializeEncryptionSpecRequest, Sequence[Tuple[str, str]] + gcd_encryption_spec.InitializeEncryptionSpecRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for initialize_encryption_spec @@ -136,8 +148,10 @@ def post_initialize_encryption_spec( 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 @@ -159,8 +173,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 @@ -182,8 +198,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -203,8 +221,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -226,8 +246,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -428,7 +450,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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Call the get encryption spec method over HTTP. @@ -439,8 +461,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: ~.encryption_spec.EncryptionSpec: @@ -453,6 +477,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetEncryptionSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_encryption_spec( request, metadata ) @@ -465,6 +490,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 = 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.dialogflow_v2.EncryptionSpecServiceClient.GetEncryptionSpec", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetEncryptionSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EncryptionSpecServiceRestTransport._GetEncryptionSpec._get_response( @@ -487,7 +539,29 @@ def __call__( pb_resp = encryption_spec.EncryptionSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_encryption_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = encryption_spec.EncryptionSpec.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.dialogflow_v2.EncryptionSpecServiceClient.get_encryption_spec", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetEncryptionSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InitializeEncryptionSpec( @@ -526,7 +600,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]]] = (), ) -> operations_pb2.Operation: r"""Call the initialize encryption spec method over HTTP. @@ -538,8 +612,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: ~.operations_pb2.Operation: @@ -552,6 +628,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseInitializeEncryptionSpec._get_http_options() ) + request, metadata = self._interceptor.pre_initialize_encryption_spec( request, metadata ) @@ -568,6 +645,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.dialogflow_v2.EncryptionSpecServiceClient.InitializeEncryptionSpec", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "InitializeEncryptionSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._InitializeEncryptionSpec._get_response( self._host, @@ -587,7 +691,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_initialize_encryption_spec(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.dialogflow_v2.EncryptionSpecServiceClient.initialize_encryption_spec", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "InitializeEncryptionSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -649,7 +775,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. @@ -659,8 +785,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. @@ -669,6 +797,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -679,6 +808,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.dialogflow_v2.EncryptionSpecServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._GetLocation._get_response( self._host, @@ -698,6 +854,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.dialogflow_v2.EncryptionSpecServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -739,7 +916,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. @@ -749,8 +926,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. @@ -759,6 +938,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -769,6 +949,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.dialogflow_v2.EncryptionSpecServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._ListLocations._get_response( self._host, @@ -788,6 +995,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.dialogflow_v2.EncryptionSpecServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -829,7 +1057,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -839,13 +1067,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 = ( _BaseEncryptionSpecServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -858,6 +1089,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.dialogflow_v2.EncryptionSpecServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EncryptionSpecServiceRestTransport._CancelOperation._get_response( @@ -916,7 +1174,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -926,8 +1184,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: operations_pb2.Operation: Response from GetOperation method. @@ -936,6 +1196,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -946,6 +1207,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.dialogflow_v2.EncryptionSpecServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._GetOperation._get_response( self._host, @@ -965,6 +1253,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.EncryptionSpecServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1006,7 +1315,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1016,8 +1325,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1026,6 +1337,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1036,6 +1348,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.dialogflow_v2.EncryptionSpecServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._ListOperations._get_response( self._host, @@ -1055,6 +1394,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.EncryptionSpecServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EncryptionSpecService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/async_client.py index d35d0b541bce..0d62e1fd7e4c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EntityTypesTransport from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport +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 EntityTypesAsyncClient: """Service for managing @@ -260,6 +270,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.dialogflow_v2.EntityTypesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "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.dialogflow.v2.EntityTypes", + "credentialsType": None, + }, + ) + async def list_entity_types( self, request: Optional[Union[entity_type.ListEntityTypesRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_entity_types( language_code: 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.ListEntityTypesAsyncPager: r"""Returns the list of all entity types in the specified agent. @@ -324,8 +356,10 @@ async def sample_list_entity_types(): 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.dialogflow_v2.services.entity_types.pagers.ListEntityTypesAsyncPager: @@ -403,7 +437,7 @@ async def get_entity_type( language_code: 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]]] = (), ) -> entity_type.EntityType: r"""Retrieves the specified entity type. @@ -457,8 +491,10 @@ async def sample_get_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -536,7 +572,7 @@ async def create_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Creates an entity type in the specified agent. @@ -604,8 +640,10 @@ async def sample_create_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -684,7 +722,7 @@ async def update_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Updates the specified entity type. @@ -744,8 +782,10 @@ async def sample_update_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -823,7 +863,7 @@ async def delete_entity_type( 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 the specified entity type. @@ -868,8 +908,10 @@ async def sample_delete_entity_type(): 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 @@ -922,7 +964,7 @@ async def batch_update_entity_types( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates/Creates multiple entity types in the specified agent. @@ -978,8 +1020,10 @@ async def sample_batch_update_entity_types(): 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.api_core.operation_async.AsyncOperation: @@ -1039,7 +1083,7 @@ async def batch_delete_entity_types( entity_type_names: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes entity types in the specified agent. @@ -1109,8 +1153,10 @@ async def sample_batch_delete_entity_types(): 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.api_core.operation_async.AsyncOperation: @@ -1193,7 +1239,7 @@ async def batch_create_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates multiple new entities in the specified entity type. @@ -1276,8 +1322,10 @@ async def sample_batch_create_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1362,7 +1410,7 @@ async def batch_update_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates or creates multiple entities in the specified entity type. This method does not affect entities in the entity type @@ -1449,8 +1497,10 @@ async def sample_batch_update_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1535,7 +1585,7 @@ async def batch_delete_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes entities in the specified entity type. @@ -1617,8 +1667,10 @@ async def sample_batch_delete_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1700,7 +1752,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1711,8 +1763,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1753,7 +1807,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1764,8 +1818,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1806,7 +1862,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1821,8 +1877,10 @@ async def cancel_operation( 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: None """ @@ -1859,7 +1917,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. @@ -1870,8 +1928,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. @@ -1912,7 +1972,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. @@ -1923,8 +1983,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-dialogflow/google/cloud/dialogflow_v2/services/entity_types/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/client.py index c807dec85452..ae8a23635e11 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -583,6 +593,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( @@ -645,6 +659,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.dialogflow_v2.EntityTypesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "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.dialogflow.v2.EntityTypes", + "credentialsType": None, + }, + ) + def list_entity_types( self, request: Optional[Union[entity_type.ListEntityTypesRequest, dict]] = None, @@ -653,7 +690,7 @@ def list_entity_types( language_code: 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.ListEntityTypesPager: r"""Returns the list of all entity types in the specified agent. @@ -709,8 +746,10 @@ def sample_list_entity_types(): 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.dialogflow_v2.services.entity_types.pagers.ListEntityTypesPager: @@ -785,7 +824,7 @@ def get_entity_type( language_code: 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]]] = (), ) -> entity_type.EntityType: r"""Retrieves the specified entity type. @@ -839,8 +878,10 @@ def sample_get_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -915,7 +956,7 @@ def create_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Creates an entity type in the specified agent. @@ -983,8 +1024,10 @@ def sample_create_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -1060,7 +1103,7 @@ def update_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Updates the specified entity type. @@ -1120,8 +1163,10 @@ def sample_update_entity_type(): 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.dialogflow_v2.types.EntityType: @@ -1196,7 +1241,7 @@ def delete_entity_type( 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 the specified entity type. @@ -1241,8 +1286,10 @@ def sample_delete_entity_type(): 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 @@ -1292,7 +1339,7 @@ def batch_update_entity_types( *, 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]]] = (), ) -> operation.Operation: r"""Updates/Creates multiple entity types in the specified agent. @@ -1348,8 +1395,10 @@ def sample_batch_update_entity_types(): 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.api_core.operation.Operation: @@ -1409,7 +1458,7 @@ def batch_delete_entity_types( entity_type_names: 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]]] = (), ) -> operation.Operation: r"""Deletes entity types in the specified agent. @@ -1479,8 +1528,10 @@ def sample_batch_delete_entity_types(): 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.api_core.operation.Operation: @@ -1562,7 +1613,7 @@ def batch_create_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Creates multiple new entities in the specified entity type. @@ -1645,8 +1696,10 @@ def sample_batch_create_entities(): 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.api_core.operation.Operation: @@ -1728,7 +1781,7 @@ def batch_update_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Updates or creates multiple entities in the specified entity type. This method does not affect entities in the entity type @@ -1815,8 +1868,10 @@ def sample_batch_update_entities(): 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.api_core.operation.Operation: @@ -1898,7 +1953,7 @@ def batch_delete_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Deletes entities in the specified entity type. @@ -1980,8 +2035,10 @@ def sample_batch_delete_entities(): 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.api_core.operation.Operation: @@ -2073,7 +2130,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2084,8 +2141,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2126,7 +2185,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2137,8 +2196,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2179,7 +2240,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2194,8 +2255,10 @@ def cancel_operation( 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: None """ @@ -2232,7 +2295,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. @@ -2243,8 +2306,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. @@ -2285,7 +2350,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. @@ -2296,8 +2361,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-dialogflow/google/cloud/dialogflow_v2/services/entity_types/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/pagers.py index 454172b8cf56..6085c02256c7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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 = entity_type.ListEntityTypesRequest(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 = entity_type.ListEntityTypesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py index b343e8e45496..88dd71b2e7e9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import entity_type from google.cloud.dialogflow_v2.types import entity_type as gcd_entity_type from .base import DEFAULT_CLIENT_INFO, EntityTypesTransport +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.dialogflow.v2.EntityTypes", + "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.dialogflow.v2.EntityTypes", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EntityTypesGrpcTransport(EntityTypesTransport): """gRPC backend transport for EntityTypes. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def list_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entity_types" not in self._stubs: - self._stubs["list_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/ListEntityTypes", request_serializer=entity_type.ListEntityTypesRequest.serialize, response_deserializer=entity_type.ListEntityTypesResponse.deserialize, @@ -302,7 +390,7 @@ def get_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entity_type" not in self._stubs: - self._stubs["get_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/GetEntityType", request_serializer=entity_type.GetEntityTypeRequest.serialize, response_deserializer=entity_type.EntityType.deserialize, @@ -334,7 +422,7 @@ def create_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entity_type" not in self._stubs: - self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["create_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/CreateEntityType", request_serializer=gcd_entity_type.CreateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -366,7 +454,7 @@ def update_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entity_type" not in self._stubs: - self._stubs["update_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["update_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/UpdateEntityType", request_serializer=gcd_entity_type.UpdateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -396,7 +484,7 @@ def delete_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entity_type" not in self._stubs: - self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["delete_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/DeleteEntityType", request_serializer=entity_type.DeleteEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -438,7 +526,7 @@ def batch_update_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entity_types" not in self._stubs: - self._stubs["batch_update_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntityTypes", request_serializer=entity_type.BatchUpdateEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -480,7 +568,7 @@ def batch_delete_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entity_types" not in self._stubs: - self._stubs["batch_delete_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntityTypes", request_serializer=entity_type.BatchDeleteEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def batch_create_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_entities" not in self._stubs: - self._stubs["batch_create_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchCreateEntities", request_serializer=entity_type.BatchCreateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -562,7 +650,7 @@ def batch_update_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entities" not in self._stubs: - self._stubs["batch_update_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntities", request_serializer=entity_type.BatchUpdateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +690,7 @@ def batch_delete_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entities" not in self._stubs: - self._stubs["batch_delete_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntities", request_serializer=entity_type.BatchDeleteEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +698,7 @@ def batch_delete_entities( return self._stubs["batch_delete_entities"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -622,7 +710,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -639,7 +727,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -658,7 +746,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -677,7 +765,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, @@ -694,7 +782,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-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py index 7c3f4edeee0a..46bfe375588e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import entity_type from google.cloud.dialogflow_v2.types import entity_type as gcd_entity_type @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, EntityTypesTransport from .grpc import EntityTypesGrpcTransport +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.dialogflow.v2.EntityTypes", + "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.dialogflow.v2.EntityTypes", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EntityTypesGrpcAsyncIOTransport(EntityTypesTransport): """gRPC AsyncIO backend transport for EntityTypes. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def list_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entity_types" not in self._stubs: - self._stubs["list_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/ListEntityTypes", request_serializer=entity_type.ListEntityTypesRequest.serialize, response_deserializer=entity_type.ListEntityTypesResponse.deserialize, @@ -315,7 +400,7 @@ def get_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entity_type" not in self._stubs: - self._stubs["get_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/GetEntityType", request_serializer=entity_type.GetEntityTypeRequest.serialize, response_deserializer=entity_type.EntityType.deserialize, @@ -347,7 +432,7 @@ def create_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entity_type" not in self._stubs: - self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["create_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/CreateEntityType", request_serializer=gcd_entity_type.CreateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -379,7 +464,7 @@ def update_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entity_type" not in self._stubs: - self._stubs["update_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["update_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/UpdateEntityType", request_serializer=gcd_entity_type.UpdateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -409,7 +494,7 @@ def delete_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entity_type" not in self._stubs: - self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["delete_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/DeleteEntityType", request_serializer=entity_type.DeleteEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -451,7 +536,7 @@ def batch_update_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entity_types" not in self._stubs: - self._stubs["batch_update_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntityTypes", request_serializer=entity_type.BatchUpdateEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +578,7 @@ def batch_delete_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entity_types" not in self._stubs: - self._stubs["batch_delete_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntityTypes", request_serializer=entity_type.BatchDeleteEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +620,7 @@ def batch_create_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_entities" not in self._stubs: - self._stubs["batch_create_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchCreateEntities", request_serializer=entity_type.BatchCreateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -579,7 +664,7 @@ def batch_update_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entities" not in self._stubs: - self._stubs["batch_update_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntities", request_serializer=entity_type.BatchUpdateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -621,7 +706,7 @@ def batch_delete_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entities" not in self._stubs: - self._stubs["batch_delete_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntities", request_serializer=entity_type.BatchDeleteEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -714,7 +799,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: @@ -730,7 +815,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -747,7 +832,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -766,7 +851,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -785,7 +870,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, @@ -802,7 +887,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-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py index 7f7fb3dfeef8..b8a46a27b693 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/entity_types/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 @@ -41,6 +41,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, @@ -149,8 +157,10 @@ def post_update_entity_type(self, response): def pre_batch_create_entities( self, request: entity_type.BatchCreateEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchCreateEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchCreateEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_entities Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_batch_create_entities( def pre_batch_delete_entities( self, request: entity_type.BatchDeleteEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchDeleteEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchDeleteEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_entities Override in a subclass to manipulate the request or metadata @@ -195,8 +207,11 @@ def post_batch_delete_entities( def pre_batch_delete_entity_types( self, request: entity_type.BatchDeleteEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchDeleteEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchDeleteEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_delete_entity_types Override in a subclass to manipulate the request or metadata @@ -218,8 +233,10 @@ def post_batch_delete_entity_types( def pre_batch_update_entities( self, request: entity_type.BatchUpdateEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchUpdateEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchUpdateEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_entities Override in a subclass to manipulate the request or metadata @@ -241,8 +258,11 @@ def post_batch_update_entities( def pre_batch_update_entity_types( self, request: entity_type.BatchUpdateEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchUpdateEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchUpdateEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_update_entity_types Override in a subclass to manipulate the request or metadata @@ -264,8 +284,10 @@ def post_batch_update_entity_types( def pre_create_entity_type( self, request: gcd_entity_type.CreateEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_entity_type.CreateEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_entity_type.CreateEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_entity_type Override in a subclass to manipulate the request or metadata @@ -287,8 +309,10 @@ def post_create_entity_type( def pre_delete_entity_type( self, request: entity_type.DeleteEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.DeleteEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.DeleteEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_entity_type Override in a subclass to manipulate the request or metadata @@ -299,8 +323,10 @@ def pre_delete_entity_type( def pre_get_entity_type( self, request: entity_type.GetEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.GetEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.GetEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_entity_type Override in a subclass to manipulate the request or metadata @@ -322,8 +348,10 @@ def post_get_entity_type( def pre_list_entity_types( self, request: entity_type.ListEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.ListEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.ListEntityTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_entity_types Override in a subclass to manipulate the request or metadata @@ -345,8 +373,10 @@ def post_list_entity_types( def pre_update_entity_type( self, request: gcd_entity_type.UpdateEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_entity_type.UpdateEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_entity_type.UpdateEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_entity_type Override in a subclass to manipulate the request or metadata @@ -368,8 +398,10 @@ def post_update_entity_type( 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 @@ -391,8 +423,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 @@ -414,8 +448,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -435,8 +471,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -458,8 +496,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -660,7 +700,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create entities method over HTTP. @@ -671,8 +711,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: ~.operations_pb2.Operation: @@ -685,6 +727,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchCreateEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_entities( request, metadata ) @@ -701,6 +744,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.dialogflow_v2.EntityTypesClient.BatchCreateEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchCreateEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchCreateEntities._get_response( self._host, @@ -720,7 +790,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_entities(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.dialogflow_v2.EntityTypesClient.batch_create_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchCreateEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteEntities( @@ -758,7 +850,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete entities method over HTTP. @@ -769,8 +861,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: ~.operations_pb2.Operation: @@ -783,6 +877,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchDeleteEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_entities( request, metadata ) @@ -799,6 +894,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.dialogflow_v2.EntityTypesClient.BatchDeleteEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchDeleteEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchDeleteEntities._get_response( self._host, @@ -818,7 +940,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_entities(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.dialogflow_v2.EntityTypesClient.batch_delete_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchDeleteEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteEntityTypes( @@ -856,7 +1000,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete entity types method over HTTP. @@ -867,8 +1011,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: ~.operations_pb2.Operation: @@ -881,6 +1027,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchDeleteEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_entity_types( request, metadata ) @@ -897,6 +1044,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.dialogflow_v2.EntityTypesClient.BatchDeleteEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchDeleteEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchDeleteEntityTypes._get_response( self._host, @@ -916,7 +1090,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_entity_types(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.dialogflow_v2.EntityTypesClient.batch_delete_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchDeleteEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateEntities( @@ -954,7 +1150,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update entities method over HTTP. @@ -965,8 +1161,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: ~.operations_pb2.Operation: @@ -979,6 +1177,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchUpdateEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_entities( request, metadata ) @@ -995,6 +1194,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.dialogflow_v2.EntityTypesClient.BatchUpdateEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchUpdateEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchUpdateEntities._get_response( self._host, @@ -1014,7 +1240,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_entities(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.dialogflow_v2.EntityTypesClient.batch_update_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchUpdateEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateEntityTypes( @@ -1052,7 +1300,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update entity types method over HTTP. @@ -1063,8 +1311,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: ~.operations_pb2.Operation: @@ -1077,6 +1327,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchUpdateEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_entity_types( request, metadata ) @@ -1093,6 +1344,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.dialogflow_v2.EntityTypesClient.BatchUpdateEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchUpdateEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchUpdateEntityTypes._get_response( self._host, @@ -1112,7 +1390,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_entity_types(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.dialogflow_v2.EntityTypesClient.batch_update_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "BatchUpdateEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEntityType( @@ -1150,7 +1450,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]]] = (), ) -> gcd_entity_type.EntityType: r"""Call the create entity type method over HTTP. @@ -1161,8 +1461,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: ~.gcd_entity_type.EntityType: @@ -1187,6 +1489,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseCreateEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_create_entity_type( request, metadata ) @@ -1203,6 +1506,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 = 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.dialogflow_v2.EntityTypesClient.CreateEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "CreateEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._CreateEntityType._get_response( self._host, @@ -1224,7 +1554,29 @@ def __call__( pb_resp = gcd_entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_entity_type.EntityType.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.dialogflow_v2.EntityTypesClient.create_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "CreateEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEntityType( @@ -1261,7 +1613,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 entity type method over HTTP. @@ -1272,13 +1624,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 = ( _BaseEntityTypesRestTransport._BaseDeleteEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_delete_entity_type( request, metadata ) @@ -1291,6 +1646,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.dialogflow_v2.EntityTypesClient.DeleteEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "DeleteEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._DeleteEntityType._get_response( self._host, @@ -1340,7 +1722,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]]] = (), ) -> entity_type.EntityType: r"""Call the get entity type method over HTTP. @@ -1351,8 +1733,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: ~.entity_type.EntityType: @@ -1377,6 +1761,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_get_entity_type(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseGetEntityType._get_transcoded_request( http_options, request @@ -1389,6 +1774,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.dialogflow_v2.EntityTypesClient.GetEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetEntityType._get_response( self._host, @@ -1409,7 +1821,29 @@ def __call__( pb_resp = entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_type.EntityType.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.dialogflow_v2.EntityTypesClient.get_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEntityTypes( @@ -1446,7 +1880,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]]] = (), ) -> entity_type.ListEntityTypesResponse: r"""Call the list entity types method over HTTP. @@ -1457,8 +1891,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: ~.entity_type.ListEntityTypesResponse: @@ -1470,6 +1906,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_entity_types( request, metadata ) @@ -1482,6 +1919,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 = 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.dialogflow_v2.EntityTypesClient.ListEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListEntityTypes._get_response( self._host, @@ -1502,7 +1966,31 @@ def __call__( pb_resp = entity_type.ListEntityTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_entity_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_type.ListEntityTypesResponse.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.dialogflow_v2.EntityTypesClient.list_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEntityType( @@ -1540,7 +2028,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]]] = (), ) -> gcd_entity_type.EntityType: r"""Call the update entity type method over HTTP. @@ -1551,8 +2039,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: ~.gcd_entity_type.EntityType: @@ -1577,6 +2067,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseUpdateEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_update_entity_type( request, metadata ) @@ -1593,6 +2084,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 = 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.dialogflow_v2.EntityTypesClient.UpdateEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "UpdateEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._UpdateEntityType._get_response( self._host, @@ -1614,7 +2132,29 @@ def __call__( pb_resp = gcd_entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_entity_type.EntityType.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.dialogflow_v2.EntityTypesClient.update_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "UpdateEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1745,7 +2285,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. @@ -1755,8 +2295,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. @@ -1765,6 +2307,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseEntityTypesRestTransport._BaseGetLocation._get_transcoded_request( @@ -1779,6 +2322,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.dialogflow_v2.EntityTypesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetLocation._get_response( self._host, @@ -1798,6 +2368,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.dialogflow_v2.EntityTypesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1838,7 +2429,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. @@ -1848,8 +2439,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. @@ -1858,6 +2451,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1870,6 +2464,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.dialogflow_v2.EntityTypesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListLocations._get_response( self._host, @@ -1889,6 +2510,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.dialogflow_v2.EntityTypesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1929,7 +2571,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1939,13 +2581,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 = ( _BaseEntityTypesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1958,6 +2603,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.dialogflow_v2.EntityTypesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._CancelOperation._get_response( self._host, @@ -2013,7 +2685,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2023,8 +2695,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: operations_pb2.Operation: Response from GetOperation method. @@ -2033,6 +2707,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseEntityTypesRestTransport._BaseGetOperation._get_transcoded_request( @@ -2047,6 +2722,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.dialogflow_v2.EntityTypesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetOperation._get_response( self._host, @@ -2066,6 +2768,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.EntityTypesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2106,7 +2829,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2116,8 +2839,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2126,6 +2851,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2136,6 +2862,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.dialogflow_v2.EntityTypesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListOperations._get_response( self._host, @@ -2155,6 +2908,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.EntityTypesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.EntityTypes", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/async_client.py index 1c81ee8f279a..bde596504b9f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport +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 EnvironmentsAsyncClient: """Service for managing @@ -260,6 +270,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.dialogflow_v2.EnvironmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "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.dialogflow.v2.Environments", + "credentialsType": None, + }, + ) + async def list_environments( self, request: Optional[Union[environment.ListEnvironmentsRequest, dict]] = None, @@ -267,7 +299,7 @@ async def list_environments( 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.ListEnvironmentsAsyncPager: r"""Returns the list of all non-default environments of the specified agent. @@ -316,8 +348,10 @@ async def sample_list_environments(): 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.dialogflow_v2.services.environments.pagers.ListEnvironmentsAsyncPager: @@ -391,7 +425,7 @@ async def get_environment( *, 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]]] = (), ) -> environment.Environment: r"""Retrieves the specified agent environment. @@ -428,8 +462,10 @@ async def sample_get_environment(): 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.dialogflow_v2.types.Environment: @@ -494,7 +530,7 @@ async def create_environment( *, 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]]] = (), ) -> environment.Environment: r"""Creates an agent environment. @@ -532,8 +568,10 @@ async def sample_create_environment(): 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.dialogflow_v2.types.Environment: @@ -598,7 +636,7 @@ async def update_environment( *, 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]]] = (), ) -> environment.Environment: r"""Updates the specified agent environment. @@ -647,8 +685,10 @@ async def sample_update_environment(): 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.dialogflow_v2.types.Environment: @@ -715,7 +755,7 @@ async def delete_environment( *, 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 the specified agent environment. @@ -749,8 +789,10 @@ async def sample_delete_environment(): 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 @@ -787,7 +829,7 @@ async def get_environment_history( *, 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.GetEnvironmentHistoryAsyncPager: r"""Gets the history of the specified environment. @@ -825,8 +867,10 @@ async def sample_get_environment_history(): 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.dialogflow_v2.services.environments.pagers.GetEnvironmentHistoryAsyncPager: @@ -886,7 +930,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -897,8 +941,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -939,7 +985,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -950,8 +996,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -992,7 +1040,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1007,8 +1055,10 @@ async def cancel_operation( 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: None """ @@ -1045,7 +1095,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. @@ -1056,8 +1106,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. @@ -1098,7 +1150,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. @@ -1109,8 +1161,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-dialogflow/google/cloud/dialogflow_v2/services/environments/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/client.py index 1f41de4307e8..34436aa091e8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -613,6 +623,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( @@ -675,6 +689,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.dialogflow_v2.EnvironmentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "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.dialogflow.v2.Environments", + "credentialsType": None, + }, + ) + def list_environments( self, request: Optional[Union[environment.ListEnvironmentsRequest, dict]] = None, @@ -682,7 +719,7 @@ def list_environments( 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.ListEnvironmentsPager: r"""Returns the list of all non-default environments of the specified agent. @@ -731,8 +768,10 @@ def sample_list_environments(): 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.dialogflow_v2.services.environments.pagers.ListEnvironmentsPager: @@ -803,7 +842,7 @@ def get_environment( *, 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]]] = (), ) -> environment.Environment: r"""Retrieves the specified agent environment. @@ -840,8 +879,10 @@ def sample_get_environment(): 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.dialogflow_v2.types.Environment: @@ -904,7 +945,7 @@ def create_environment( *, 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]]] = (), ) -> environment.Environment: r"""Creates an agent environment. @@ -942,8 +983,10 @@ def sample_create_environment(): 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.dialogflow_v2.types.Environment: @@ -1006,7 +1049,7 @@ def update_environment( *, 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]]] = (), ) -> environment.Environment: r"""Updates the specified agent environment. @@ -1055,8 +1098,10 @@ def sample_update_environment(): 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.dialogflow_v2.types.Environment: @@ -1121,7 +1166,7 @@ def delete_environment( *, 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 the specified agent environment. @@ -1155,8 +1200,10 @@ def sample_delete_environment(): 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 @@ -1191,7 +1238,7 @@ def get_environment_history( *, 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.GetEnvironmentHistoryPager: r"""Gets the history of the specified environment. @@ -1229,8 +1276,10 @@ def sample_get_environment_history(): 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.dialogflow_v2.services.environments.pagers.GetEnvironmentHistoryPager: @@ -1301,7 +1350,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1312,8 +1361,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1354,7 +1405,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1365,8 +1416,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1407,7 +1460,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1422,8 +1475,10 @@ def cancel_operation( 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: None """ @@ -1460,7 +1515,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. @@ -1471,8 +1526,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. @@ -1513,7 +1570,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. @@ -1524,8 +1581,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-dialogflow/google/cloud/dialogflow_v2/services/environments/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/pagers.py index bc69af2eb590..9b387a3c8d95 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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 = environment.ListEnvironmentsRequest(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 = environment.ListEnvironmentsRequest(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 = environment.GetEnvironmentHistoryRequest(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 = environment.GetEnvironmentHistoryRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc.py index cd5d0667e770..eb2aeafc7f3b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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 @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import environment from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport +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.dialogflow.v2.Environments", + "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.dialogflow.v2.Environments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcTransport(EnvironmentsTransport): """gRPC backend transport for Environments. @@ -183,7 +264,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 @@ -260,7 +346,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/ListEnvironments", request_serializer=environment.ListEnvironmentsRequest.serialize, response_deserializer=environment.ListEnvironmentsResponse.deserialize, @@ -286,7 +372,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/GetEnvironment", request_serializer=environment.GetEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -312,7 +398,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/CreateEnvironment", request_serializer=environment.CreateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -351,7 +437,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/UpdateEnvironment", request_serializer=environment.UpdateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -377,7 +463,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/DeleteEnvironment", request_serializer=environment.DeleteEnvironmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -405,7 +491,7 @@ def get_environment_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment_history" not in self._stubs: - self._stubs["get_environment_history"] = self.grpc_channel.unary_unary( + self._stubs["get_environment_history"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/GetEnvironmentHistory", request_serializer=environment.GetEnvironmentHistoryRequest.serialize, response_deserializer=environment.EnvironmentHistory.deserialize, @@ -413,7 +499,7 @@ def get_environment_history( return self._stubs["get_environment_history"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -425,7 +511,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -442,7 +528,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +547,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -480,7 +566,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, @@ -497,7 +583,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-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py index 4d422059dbe3..d2e156558f79 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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 @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import environment from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .grpc import EnvironmentsGrpcTransport +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.dialogflow.v2.Environments", + "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.dialogflow.v2.Environments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport): """gRPC AsyncIO backend transport for Environments. @@ -230,10 +312,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 @@ -269,7 +354,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/ListEnvironments", request_serializer=environment.ListEnvironmentsRequest.serialize, response_deserializer=environment.ListEnvironmentsResponse.deserialize, @@ -297,7 +382,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/GetEnvironment", request_serializer=environment.GetEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -325,7 +410,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/CreateEnvironment", request_serializer=environment.CreateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -366,7 +451,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/UpdateEnvironment", request_serializer=environment.UpdateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -392,7 +477,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/DeleteEnvironment", request_serializer=environment.DeleteEnvironmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -421,7 +506,7 @@ def get_environment_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment_history" not in self._stubs: - self._stubs["get_environment_history"] = self.grpc_channel.unary_unary( + self._stubs["get_environment_history"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Environments/GetEnvironmentHistory", request_serializer=environment.GetEnvironmentHistoryRequest.serialize, response_deserializer=environment.EnvironmentHistory.deserialize, @@ -494,7 +579,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: @@ -510,7 +595,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -527,7 +612,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -546,7 +631,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -565,7 +650,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, @@ -582,7 +667,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-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/rest.py index 09efa68e3868..d87f8cb20668 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/environments/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 @@ -40,6 +40,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, @@ -116,8 +124,10 @@ def post_update_environment(self, response): def pre_create_environment( self, request: environment.CreateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.CreateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.CreateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_environment Override in a subclass to manipulate the request or metadata @@ -139,8 +149,10 @@ def post_create_environment( def pre_delete_environment( self, request: environment.DeleteEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.DeleteEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.DeleteEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_environment Override in a subclass to manipulate the request or metadata @@ -151,8 +163,10 @@ def pre_delete_environment( def pre_get_environment( self, request: environment.GetEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.GetEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_environment Override in a subclass to manipulate the request or metadata @@ -174,8 +188,11 @@ def post_get_environment( def pre_get_environment_history( self, request: environment.GetEnvironmentHistoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.GetEnvironmentHistoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.GetEnvironmentHistoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_environment_history Override in a subclass to manipulate the request or metadata @@ -197,8 +214,10 @@ def post_get_environment_history( def pre_list_environments( self, request: environment.ListEnvironmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.ListEnvironmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.ListEnvironmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_environments Override in a subclass to manipulate the request or metadata @@ -220,8 +239,10 @@ def post_list_environments( def pre_update_environment( self, request: environment.UpdateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.UpdateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.UpdateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_environment Override in a subclass to manipulate the request or metadata @@ -243,8 +264,10 @@ def post_update_environment( 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 @@ -266,8 +289,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 @@ -289,8 +314,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -310,8 +337,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -333,8 +362,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -476,7 +507,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]]] = (), ) -> environment.Environment: r"""Call the create environment method over HTTP. @@ -487,8 +518,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: ~.environment.Environment: @@ -517,6 +550,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_create_environment( request, metadata ) @@ -533,6 +567,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 = 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.dialogflow_v2.EnvironmentsClient.CreateEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "CreateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CreateEnvironment._get_response( self._host, @@ -554,7 +615,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2.EnvironmentsClient.create_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "CreateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEnvironment( @@ -591,7 +674,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 environment method over HTTP. @@ -602,13 +685,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_environment( request, metadata ) @@ -621,6 +707,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.dialogflow_v2.EnvironmentsClient.DeleteEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "DeleteEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteEnvironment._get_response( self._host, @@ -670,7 +783,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]]] = (), ) -> environment.Environment: r"""Call the get environment method over HTTP. @@ -681,8 +794,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: ~.environment.Environment: @@ -711,6 +826,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_transcoded_request( http_options, request @@ -721,6 +837,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 = 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.dialogflow_v2.EnvironmentsClient.GetEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironment._get_response( self._host, @@ -741,7 +884,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2.EnvironmentsClient.get_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnvironmentHistory( @@ -778,7 +943,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]]] = (), ) -> environment.EnvironmentHistory: r"""Call the get environment history method over HTTP. @@ -789,8 +954,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: ~.environment.EnvironmentHistory: @@ -802,6 +969,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironmentHistory._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment_history( request, metadata ) @@ -814,6 +982,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 = 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.dialogflow_v2.EnvironmentsClient.GetEnvironmentHistory", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetEnvironmentHistory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironmentHistory._get_response( self._host, @@ -834,7 +1029,29 @@ def __call__( pb_resp = environment.EnvironmentHistory.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment_history(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.EnvironmentHistory.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.dialogflow_v2.EnvironmentsClient.get_environment_history", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetEnvironmentHistory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEnvironments( @@ -871,7 +1088,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]]] = (), ) -> environment.ListEnvironmentsResponse: r"""Call the list environments method over HTTP. @@ -882,8 +1099,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: ~.environment.ListEnvironmentsResponse: @@ -895,6 +1114,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListEnvironments._get_http_options() ) + request, metadata = self._interceptor.pre_list_environments( request, metadata ) @@ -907,6 +1127,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 = 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.dialogflow_v2.EnvironmentsClient.ListEnvironments", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListEnvironments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListEnvironments._get_response( self._host, @@ -927,7 +1174,31 @@ def __call__( pb_resp = environment.ListEnvironmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_environments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.ListEnvironmentsResponse.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.dialogflow_v2.EnvironmentsClient.list_environments", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListEnvironments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEnvironment( @@ -965,7 +1236,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]]] = (), ) -> environment.Environment: r"""Call the update environment method over HTTP. @@ -976,8 +1247,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: ~.environment.Environment: @@ -1006,6 +1279,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_update_environment( request, metadata ) @@ -1022,6 +1296,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 = 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.dialogflow_v2.EnvironmentsClient.UpdateEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "UpdateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._UpdateEnvironment._get_response( self._host, @@ -1043,7 +1344,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2.EnvironmentsClient.update_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "UpdateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1136,7 +1459,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. @@ -1146,8 +1469,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. @@ -1156,6 +1481,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseEnvironmentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1170,6 +1496,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.dialogflow_v2.EnvironmentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetLocation._get_response( self._host, @@ -1189,6 +1542,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.dialogflow_v2.EnvironmentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1229,7 +1603,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. @@ -1239,8 +1613,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. @@ -1249,6 +1625,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1259,6 +1636,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.dialogflow_v2.EnvironmentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListLocations._get_response( self._host, @@ -1278,6 +1682,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.dialogflow_v2.EnvironmentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1318,7 +1743,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1328,13 +1753,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 = ( _BaseEnvironmentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1347,6 +1775,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.dialogflow_v2.EnvironmentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CancelOperation._get_response( self._host, @@ -1402,7 +1857,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1412,8 +1867,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: operations_pb2.Operation: Response from GetOperation method. @@ -1422,6 +1879,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1434,6 +1892,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.dialogflow_v2.EnvironmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetOperation._get_response( self._host, @@ -1453,6 +1938,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.EnvironmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1493,7 +1999,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1503,8 +2009,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1513,6 +2021,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1523,6 +2032,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.dialogflow_v2.EnvironmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListOperations._get_response( self._host, @@ -1542,6 +2078,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.EnvironmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Environments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/async_client.py index 08cc227c5202..4ba66df56558 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, FulfillmentsTransport from .transports.grpc_asyncio import FulfillmentsGrpcAsyncIOTransport +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 FulfillmentsAsyncClient: """Service for managing @@ -256,6 +266,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.dialogflow_v2.FulfillmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "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.dialogflow.v2.Fulfillments", + "credentialsType": None, + }, + ) + async def get_fulfillment( self, request: Optional[Union[fulfillment.GetFulfillmentRequest, dict]] = None, @@ -263,7 +295,7 @@ async def get_fulfillment( 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]]] = (), ) -> fulfillment.Fulfillment: r"""Retrieves the fulfillment. @@ -307,8 +339,10 @@ async def sample_get_fulfillment(): 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.dialogflow_v2.types.Fulfillment: @@ -380,7 +414,7 @@ async def update_fulfillment( 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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Updates the fulfillment. @@ -434,8 +468,10 @@ async def sample_update_fulfillment(): 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.dialogflow_v2.types.Fulfillment: @@ -509,7 +545,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -520,8 +556,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -562,7 +600,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -573,8 +611,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -615,7 +655,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -630,8 +670,10 @@ async def cancel_operation( 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: None """ @@ -668,7 +710,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. @@ -679,8 +721,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. @@ -721,7 +765,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. @@ -732,8 +776,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-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/client.py index c35606a4b198..29de5d0c1fbc 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -575,6 +585,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( @@ -637,6 +651,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.dialogflow_v2.FulfillmentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "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.dialogflow.v2.Fulfillments", + "credentialsType": None, + }, + ) + def get_fulfillment( self, request: Optional[Union[fulfillment.GetFulfillmentRequest, dict]] = None, @@ -644,7 +681,7 @@ def get_fulfillment( 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]]] = (), ) -> fulfillment.Fulfillment: r"""Retrieves the fulfillment. @@ -688,8 +725,10 @@ def sample_get_fulfillment(): 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.dialogflow_v2.types.Fulfillment: @@ -758,7 +797,7 @@ def update_fulfillment( 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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Updates the fulfillment. @@ -812,8 +851,10 @@ def sample_update_fulfillment(): 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.dialogflow_v2.types.Fulfillment: @@ -897,7 +938,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -908,8 +949,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -950,7 +993,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -961,8 +1004,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1003,7 +1048,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1018,8 +1063,10 @@ def cancel_operation( 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: None """ @@ -1056,7 +1103,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. @@ -1067,8 +1114,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. @@ -1109,7 +1158,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. @@ -1120,8 +1169,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-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py index f9be04de0896..9962799356b2 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import fulfillment from google.cloud.dialogflow_v2.types import fulfillment as gcd_fulfillment from .base import DEFAULT_CLIENT_INFO, FulfillmentsTransport +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.dialogflow.v2.Fulfillments", + "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.dialogflow.v2.Fulfillments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FulfillmentsGrpcTransport(FulfillmentsTransport): """gRPC backend transport for Fulfillments. @@ -183,7 +264,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 @@ -257,7 +343,7 @@ def get_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_fulfillment" not in self._stubs: - self._stubs["get_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["get_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Fulfillments/GetFulfillment", request_serializer=fulfillment.GetFulfillmentRequest.serialize, response_deserializer=fulfillment.Fulfillment.deserialize, @@ -285,7 +371,7 @@ def update_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_fulfillment" not in self._stubs: - self._stubs["update_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["update_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Fulfillments/UpdateFulfillment", request_serializer=gcd_fulfillment.UpdateFulfillmentRequest.serialize, response_deserializer=gcd_fulfillment.Fulfillment.deserialize, @@ -293,7 +379,7 @@ def update_fulfillment( return self._stubs["update_fulfillment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -305,7 +391,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -322,7 +408,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -341,7 +427,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -360,7 +446,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, @@ -377,7 +463,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-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py index 7ed1d41bb420..aae638469a0b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import fulfillment from google.cloud.dialogflow_v2.types import fulfillment as gcd_fulfillment @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, FulfillmentsTransport from .grpc import FulfillmentsGrpcTransport +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.dialogflow.v2.Fulfillments", + "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.dialogflow.v2.Fulfillments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FulfillmentsGrpcAsyncIOTransport(FulfillmentsTransport): """gRPC AsyncIO backend transport for Fulfillments. @@ -230,10 +312,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 @@ -267,7 +352,7 @@ def get_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_fulfillment" not in self._stubs: - self._stubs["get_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["get_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Fulfillments/GetFulfillment", request_serializer=fulfillment.GetFulfillmentRequest.serialize, response_deserializer=fulfillment.Fulfillment.deserialize, @@ -296,7 +381,7 @@ def update_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_fulfillment" not in self._stubs: - self._stubs["update_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["update_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Fulfillments/UpdateFulfillment", request_serializer=gcd_fulfillment.UpdateFulfillmentRequest.serialize, response_deserializer=gcd_fulfillment.Fulfillment.deserialize, @@ -349,7 +434,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: @@ -365,7 +450,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -382,7 +467,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +486,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -420,7 +505,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, @@ -437,7 +522,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-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py index adb48886fd7a..7abd8284ec17 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/fulfillments/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 @@ -40,6 +40,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, @@ -88,8 +96,10 @@ def post_update_fulfillment(self, response): def pre_get_fulfillment( self, request: fulfillment.GetFulfillmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[fulfillment.GetFulfillmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + fulfillment.GetFulfillmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_fulfillment Override in a subclass to manipulate the request or metadata @@ -111,8 +121,11 @@ def post_get_fulfillment( def pre_update_fulfillment( self, request: gcd_fulfillment.UpdateFulfillmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_fulfillment.UpdateFulfillmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_fulfillment.UpdateFulfillmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_fulfillment Override in a subclass to manipulate the request or metadata @@ -134,8 +147,10 @@ def post_update_fulfillment( 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 @@ -157,8 +172,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 @@ -180,8 +197,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -201,8 +220,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -224,8 +245,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -366,7 +389,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]]] = (), ) -> fulfillment.Fulfillment: r"""Call the get fulfillment method over HTTP. @@ -377,8 +400,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: ~.fulfillment.Fulfillment: @@ -400,6 +425,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetFulfillment._get_http_options() ) + request, metadata = self._interceptor.pre_get_fulfillment(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseGetFulfillment._get_transcoded_request( http_options, request @@ -410,6 +436,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 = 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.dialogflow_v2.FulfillmentsClient.GetFulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetFulfillment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetFulfillment._get_response( self._host, @@ -430,7 +483,29 @@ def __call__( pb_resp = fulfillment.Fulfillment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_fulfillment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = fulfillment.Fulfillment.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.dialogflow_v2.FulfillmentsClient.get_fulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetFulfillment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFulfillment( @@ -468,7 +543,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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Call the update fulfillment method over HTTP. @@ -479,8 +554,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: ~.gcd_fulfillment.Fulfillment: @@ -502,6 +579,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseUpdateFulfillment._get_http_options() ) + request, metadata = self._interceptor.pre_update_fulfillment( request, metadata ) @@ -518,6 +596,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 = 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.dialogflow_v2.FulfillmentsClient.UpdateFulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "UpdateFulfillment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._UpdateFulfillment._get_response( self._host, @@ -539,7 +644,29 @@ def __call__( pb_resp = gcd_fulfillment.Fulfillment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_fulfillment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_fulfillment.Fulfillment.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.dialogflow_v2.FulfillmentsClient.update_fulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "UpdateFulfillment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -598,7 +725,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. @@ -608,8 +735,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. @@ -618,6 +747,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseFulfillmentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -632,6 +762,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.dialogflow_v2.FulfillmentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetLocation._get_response( self._host, @@ -651,6 +808,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.dialogflow_v2.FulfillmentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -691,7 +869,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. @@ -701,8 +879,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. @@ -711,6 +891,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -721,6 +902,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.dialogflow_v2.FulfillmentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._ListLocations._get_response( self._host, @@ -740,6 +948,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.dialogflow_v2.FulfillmentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -780,7 +1009,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -790,13 +1019,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 = ( _BaseFulfillmentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -809,6 +1041,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.dialogflow_v2.FulfillmentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._CancelOperation._get_response( self._host, @@ -864,7 +1123,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -874,8 +1133,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: operations_pb2.Operation: Response from GetOperation method. @@ -884,6 +1145,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -896,6 +1158,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.dialogflow_v2.FulfillmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetOperation._get_response( self._host, @@ -915,6 +1204,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.FulfillmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -955,7 +1265,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -965,8 +1275,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -975,6 +1287,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -985,6 +1298,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.dialogflow_v2.FulfillmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._ListOperations._get_response( self._host, @@ -1004,6 +1344,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.FulfillmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Fulfillments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/async_client.py index 8dcf9d8a5cdd..7f23923a6163 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GeneratorsTransport from .transports.grpc_asyncio import GeneratorsGrpcAsyncIOTransport +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 GeneratorsAsyncClient: """Generator Service for LLM powered Agent Assist. This service @@ -259,6 +269,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.dialogflow_v2.GeneratorsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "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.dialogflow.v2.Generators", + "credentialsType": None, + }, + ) + async def create_generator( self, request: Optional[Union[gcd_generator.CreateGeneratorRequest, dict]] = None, @@ -268,7 +300,7 @@ async def create_generator( generator_id: 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]]] = (), ) -> gcd_generator.Generator: r"""Creates a generator. @@ -336,8 +368,10 @@ async def sample_create_generator(): 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.dialogflow_v2.types.Generator: @@ -400,7 +434,7 @@ async def get_generator( 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]]] = (), ) -> generator.Generator: r"""Retrieves a generator. @@ -444,8 +478,10 @@ async def sample_get_generator(): 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.dialogflow_v2.types.Generator: @@ -504,7 +540,7 @@ async def list_generators( 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.ListGeneratorsAsyncPager: r"""Lists generators. @@ -549,8 +585,10 @@ async def sample_list_generators(): 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.dialogflow_v2.services.generators.pagers.ListGeneratorsAsyncPager: @@ -625,7 +663,7 @@ async def delete_generator( 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 generator. @@ -665,8 +703,10 @@ async def sample_delete_generator(): 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 @@ -719,7 +759,7 @@ async def update_generator( 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]]] = (), ) -> gcd_generator.Generator: r"""Updates a generator. @@ -769,8 +809,10 @@ async def sample_update_generator(): 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.dialogflow_v2.types.Generator: @@ -832,7 +874,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -843,8 +885,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -885,7 +929,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -896,8 +940,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -938,7 +984,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -953,8 +999,10 @@ async def cancel_operation( 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: None """ @@ -991,7 +1039,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. @@ -1002,8 +1050,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. @@ -1044,7 +1094,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. @@ -1055,8 +1105,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-dialogflow/google/cloud/dialogflow_v2/services/generators/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/client.py index b48337d9995e..9adf9f1e6af2 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -587,6 +597,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( @@ -649,6 +663,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.dialogflow_v2.GeneratorsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "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.dialogflow.v2.Generators", + "credentialsType": None, + }, + ) + def create_generator( self, request: Optional[Union[gcd_generator.CreateGeneratorRequest, dict]] = None, @@ -658,7 +695,7 @@ def create_generator( generator_id: 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]]] = (), ) -> gcd_generator.Generator: r"""Creates a generator. @@ -726,8 +763,10 @@ def sample_create_generator(): 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.dialogflow_v2.types.Generator: @@ -787,7 +826,7 @@ def get_generator( 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]]] = (), ) -> generator.Generator: r"""Retrieves a generator. @@ -831,8 +870,10 @@ def sample_get_generator(): 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.dialogflow_v2.types.Generator: @@ -888,7 +929,7 @@ def list_generators( 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.ListGeneratorsPager: r"""Lists generators. @@ -933,8 +974,10 @@ def sample_list_generators(): 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.dialogflow_v2.services.generators.pagers.ListGeneratorsPager: @@ -1006,7 +1049,7 @@ def delete_generator( 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 generator. @@ -1046,8 +1089,10 @@ def sample_delete_generator(): 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 @@ -1097,7 +1142,7 @@ def update_generator( 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]]] = (), ) -> gcd_generator.Generator: r"""Updates a generator. @@ -1147,8 +1192,10 @@ def sample_update_generator(): 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.dialogflow_v2.types.Generator: @@ -1220,7 +1267,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1231,8 +1278,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1273,7 +1322,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1284,8 +1333,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1326,7 +1377,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1341,8 +1392,10 @@ def cancel_operation( 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: None """ @@ -1379,7 +1432,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. @@ -1390,8 +1443,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. @@ -1432,7 +1487,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. @@ -1443,8 +1498,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-dialogflow/google/cloud/dialogflow_v2/services/generators/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/pagers.py index 6478d508dc7b..66a1991e1f9e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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 = generator.ListGeneratorsRequest(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 = generator.ListGeneratorsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc.py index b5b69e4bfd5a..03f714d88601 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import generator from google.cloud.dialogflow_v2.types import generator as gcd_generator from .base import DEFAULT_CLIENT_INFO, GeneratorsTransport +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.dialogflow.v2.Generators", + "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.dialogflow.v2.Generators", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GeneratorsGrpcTransport(GeneratorsTransport): """gRPC backend transport for Generators. @@ -187,7 +268,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 @@ -261,7 +347,7 @@ def create_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_generator" not in self._stubs: - self._stubs["create_generator"] = self.grpc_channel.unary_unary( + self._stubs["create_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/CreateGenerator", request_serializer=gcd_generator.CreateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -287,7 +373,7 @@ def get_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_generator" not in self._stubs: - self._stubs["get_generator"] = self.grpc_channel.unary_unary( + self._stubs["get_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/GetGenerator", request_serializer=generator.GetGeneratorRequest.serialize, response_deserializer=generator.Generator.deserialize, @@ -313,7 +399,7 @@ def list_generators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_generators" not in self._stubs: - self._stubs["list_generators"] = self.grpc_channel.unary_unary( + self._stubs["list_generators"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/ListGenerators", request_serializer=generator.ListGeneratorsRequest.serialize, response_deserializer=generator.ListGeneratorsResponse.deserialize, @@ -339,7 +425,7 @@ def delete_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_generator" not in self._stubs: - self._stubs["delete_generator"] = self.grpc_channel.unary_unary( + self._stubs["delete_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/DeleteGenerator", request_serializer=generator.DeleteGeneratorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -365,7 +451,7 @@ def update_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_generator" not in self._stubs: - self._stubs["update_generator"] = self.grpc_channel.unary_unary( + self._stubs["update_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/UpdateGenerator", request_serializer=gcd_generator.UpdateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -373,7 +459,7 @@ def update_generator( return self._stubs["update_generator"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -385,7 +471,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -402,7 +488,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +507,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -440,7 +526,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, @@ -457,7 +543,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-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc_asyncio.py index 7f130458bd28..09ffdb8e3691 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import generator from google.cloud.dialogflow_v2.types import generator as gcd_generator @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, GeneratorsTransport from .grpc import GeneratorsGrpcTransport +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.dialogflow.v2.Generators", + "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.dialogflow.v2.Generators", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GeneratorsGrpcAsyncIOTransport(GeneratorsTransport): """gRPC AsyncIO backend transport for Generators. @@ -234,10 +316,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 @@ -271,7 +356,7 @@ def create_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_generator" not in self._stubs: - self._stubs["create_generator"] = self.grpc_channel.unary_unary( + self._stubs["create_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/CreateGenerator", request_serializer=gcd_generator.CreateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -297,7 +382,7 @@ def get_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_generator" not in self._stubs: - self._stubs["get_generator"] = self.grpc_channel.unary_unary( + self._stubs["get_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/GetGenerator", request_serializer=generator.GetGeneratorRequest.serialize, response_deserializer=generator.Generator.deserialize, @@ -325,7 +410,7 @@ def list_generators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_generators" not in self._stubs: - self._stubs["list_generators"] = self.grpc_channel.unary_unary( + self._stubs["list_generators"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/ListGenerators", request_serializer=generator.ListGeneratorsRequest.serialize, response_deserializer=generator.ListGeneratorsResponse.deserialize, @@ -351,7 +436,7 @@ def delete_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_generator" not in self._stubs: - self._stubs["delete_generator"] = self.grpc_channel.unary_unary( + self._stubs["delete_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/DeleteGenerator", request_serializer=generator.DeleteGeneratorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -379,7 +464,7 @@ def update_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_generator" not in self._stubs: - self._stubs["update_generator"] = self.grpc_channel.unary_unary( + self._stubs["update_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Generators/UpdateGenerator", request_serializer=gcd_generator.UpdateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -447,7 +532,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: @@ -463,7 +548,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -480,7 +565,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -499,7 +584,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -518,7 +603,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, @@ -535,7 +620,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-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/rest.py index 2611e1b32274..61d47b8c4752 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/generators/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 @@ -41,6 +41,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, @@ -109,8 +117,10 @@ def post_update_generator(self, response): def pre_create_generator( self, request: gcd_generator.CreateGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_generator.CreateGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_generator.CreateGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_generator Override in a subclass to manipulate the request or metadata @@ -132,8 +142,10 @@ def post_create_generator( def pre_delete_generator( self, request: generator.DeleteGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.DeleteGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generator.DeleteGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_generator Override in a subclass to manipulate the request or metadata @@ -144,8 +156,8 @@ def pre_delete_generator( def pre_get_generator( self, request: generator.GetGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.GetGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[generator.GetGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_generator Override in a subclass to manipulate the request or metadata @@ -165,8 +177,10 @@ def post_get_generator(self, response: generator.Generator) -> generator.Generat def pre_list_generators( self, request: generator.ListGeneratorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.ListGeneratorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generator.ListGeneratorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_generators Override in a subclass to manipulate the request or metadata @@ -188,8 +202,10 @@ def post_list_generators( def pre_update_generator( self, request: gcd_generator.UpdateGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_generator.UpdateGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_generator.UpdateGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_generator Override in a subclass to manipulate the request or metadata @@ -211,8 +227,10 @@ def post_update_generator( 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 @@ -234,8 +252,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 @@ -257,8 +277,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -278,8 +300,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -301,8 +325,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -447,7 +473,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]]] = (), ) -> gcd_generator.Generator: r"""Call the create generator method over HTTP. @@ -457,8 +483,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: ~.gcd_generator.Generator: @@ -468,6 +496,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseCreateGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_create_generator( request, metadata ) @@ -484,6 +513,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 = 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.dialogflow_v2.GeneratorsClient.CreateGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "CreateGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._CreateGenerator._get_response( self._host, @@ -505,7 +561,29 @@ def __call__( pb_resp = gcd_generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_generator.Generator.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.dialogflow_v2.GeneratorsClient.create_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "CreateGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGenerator( @@ -542,7 +620,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 generator method over HTTP. @@ -552,13 +630,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 = ( _BaseGeneratorsRestTransport._BaseDeleteGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_delete_generator( request, metadata ) @@ -571,6 +652,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.dialogflow_v2.GeneratorsClient.DeleteGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "DeleteGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._DeleteGenerator._get_response( self._host, @@ -620,7 +728,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]]] = (), ) -> generator.Generator: r"""Call the get generator method over HTTP. @@ -630,8 +738,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: ~.generator.Generator: @@ -641,6 +751,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_get_generator(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetGenerator._get_transcoded_request( @@ -655,6 +766,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.dialogflow_v2.GeneratorsClient.GetGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetGenerator._get_response( self._host, @@ -675,7 +813,29 @@ def __call__( pb_resp = generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generator.Generator.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.dialogflow_v2.GeneratorsClient.get_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGenerators( @@ -712,7 +872,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]]] = (), ) -> generator.ListGeneratorsResponse: r"""Call the list generators method over HTTP. @@ -722,8 +882,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: ~.generator.ListGeneratorsResponse: @@ -733,6 +895,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListGenerators._get_http_options() ) + request, metadata = self._interceptor.pre_list_generators(request, metadata) transcoded_request = _BaseGeneratorsRestTransport._BaseListGenerators._get_transcoded_request( http_options, request @@ -745,6 +908,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.dialogflow_v2.GeneratorsClient.ListGenerators", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListGenerators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListGenerators._get_response( self._host, @@ -765,7 +955,31 @@ def __call__( pb_resp = generator.ListGeneratorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_generators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generator.ListGeneratorsResponse.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.dialogflow_v2.GeneratorsClient.list_generators", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListGenerators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerator( @@ -803,7 +1017,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]]] = (), ) -> gcd_generator.Generator: r"""Call the update generator method over HTTP. @@ -813,8 +1027,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: ~.gcd_generator.Generator: @@ -824,6 +1040,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseUpdateGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_update_generator( request, metadata ) @@ -840,6 +1057,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 = 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.dialogflow_v2.GeneratorsClient.UpdateGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "UpdateGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._UpdateGenerator._get_response( self._host, @@ -861,7 +1105,29 @@ def __call__( pb_resp = gcd_generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_generator.Generator.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.dialogflow_v2.GeneratorsClient.update_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "UpdateGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -942,7 +1208,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. @@ -952,8 +1218,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. @@ -962,6 +1230,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetLocation._get_transcoded_request( @@ -976,6 +1245,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.dialogflow_v2.GeneratorsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetLocation._get_response( self._host, @@ -995,6 +1291,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.dialogflow_v2.GeneratorsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1035,7 +1352,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. @@ -1045,8 +1362,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. @@ -1055,6 +1374,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseListLocations._get_transcoded_request( @@ -1069,6 +1389,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.dialogflow_v2.GeneratorsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListLocations._get_response( self._host, @@ -1088,6 +1435,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.dialogflow_v2.GeneratorsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1128,7 +1496,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1138,13 +1506,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 = ( _BaseGeneratorsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1157,6 +1528,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.dialogflow_v2.GeneratorsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._CancelOperation._get_response( self._host, @@ -1212,7 +1610,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1222,8 +1620,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: operations_pb2.Operation: Response from GetOperation method. @@ -1232,6 +1632,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1246,6 +1647,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.dialogflow_v2.GeneratorsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetOperation._get_response( self._host, @@ -1265,6 +1693,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.GeneratorsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1305,7 +1754,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1315,8 +1764,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1325,6 +1776,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGeneratorsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1337,6 +1789,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.dialogflow_v2.GeneratorsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListOperations._get_response( self._host, @@ -1356,6 +1835,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.GeneratorsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Generators", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/async_client.py index 2a7bebd4ed14..f8ad98ef4e04 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, IntentsTransport from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport +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 IntentsAsyncClient: """Service for managing [Intents][google.cloud.dialogflow.v2.Intent].""" @@ -258,6 +268,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.dialogflow_v2.IntentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "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.dialogflow.v2.Intents", + "credentialsType": None, + }, + ) + async def list_intents( self, request: Optional[Union[intent.ListIntentsRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_intents( language_code: 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.ListIntentsAsyncPager: r"""Returns the list of all intents in the specified agent. @@ -331,8 +363,10 @@ async def sample_list_intents(): 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.dialogflow_v2.services.intents.pagers.ListIntentsAsyncPager: @@ -410,7 +444,7 @@ async def get_intent( language_code: 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]]] = (), ) -> intent.Intent: r"""Retrieves the specified intent. @@ -464,8 +498,10 @@ async def sample_get_intent(): 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.dialogflow_v2.types.Intent: @@ -539,7 +575,7 @@ async def create_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Creates an intent in the specified agent. @@ -606,8 +642,10 @@ async def sample_create_intent(): 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.dialogflow_v2.types.Intent: @@ -683,7 +721,7 @@ async def update_intent( 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]]] = (), ) -> gcd_intent.Intent: r"""Updates the specified intent. @@ -749,8 +787,10 @@ async def sample_update_intent(): 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.dialogflow_v2.types.Intent: @@ -826,7 +866,7 @@ async def delete_intent( 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 the specified intent and its direct or indirect followup intents. @@ -874,8 +914,10 @@ async def sample_delete_intent(): 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 @@ -929,7 +971,7 @@ async def batch_update_intents( intent_batch_inline: Optional[intent.IntentBatch] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates/Creates multiple intents in the specified agent. @@ -1009,8 +1051,10 @@ async def sample_batch_update_intents(): 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.api_core.operation_async.AsyncOperation: @@ -1086,7 +1130,7 @@ async def batch_delete_intents( intents: Optional[MutableSequence[intent.Intent]] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes intents in the specified agent. @@ -1159,8 +1203,10 @@ async def sample_batch_delete_intents(): 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.api_core.operation_async.AsyncOperation: @@ -1240,7 +1286,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1251,8 +1297,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1293,7 +1341,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1304,8 +1352,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1346,7 +1396,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1361,8 +1411,10 @@ async def cancel_operation( 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: None """ @@ -1399,7 +1451,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. @@ -1410,8 +1462,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. @@ -1452,7 +1506,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. @@ -1463,8 +1517,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-dialogflow/google/cloud/dialogflow_v2/services/intents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/client.py index 84b6a43efd15..c1f9782b7085 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -603,6 +613,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( @@ -665,6 +679,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.dialogflow_v2.IntentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "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.dialogflow.v2.Intents", + "credentialsType": None, + }, + ) + def list_intents( self, request: Optional[Union[intent.ListIntentsRequest, dict]] = None, @@ -673,7 +710,7 @@ def list_intents( language_code: 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.ListIntentsPager: r"""Returns the list of all intents in the specified agent. @@ -738,8 +775,10 @@ def sample_list_intents(): 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.dialogflow_v2.services.intents.pagers.ListIntentsPager: @@ -814,7 +853,7 @@ def get_intent( language_code: 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]]] = (), ) -> intent.Intent: r"""Retrieves the specified intent. @@ -868,8 +907,10 @@ def sample_get_intent(): 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.dialogflow_v2.types.Intent: @@ -940,7 +981,7 @@ def create_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Creates an intent in the specified agent. @@ -1007,8 +1048,10 @@ def sample_create_intent(): 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.dialogflow_v2.types.Intent: @@ -1081,7 +1124,7 @@ def update_intent( 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]]] = (), ) -> gcd_intent.Intent: r"""Updates the specified intent. @@ -1147,8 +1190,10 @@ def sample_update_intent(): 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.dialogflow_v2.types.Intent: @@ -1221,7 +1266,7 @@ def delete_intent( 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 the specified intent and its direct or indirect followup intents. @@ -1269,8 +1314,10 @@ def sample_delete_intent(): 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 @@ -1321,7 +1368,7 @@ def batch_update_intents( intent_batch_inline: Optional[intent.IntentBatch] = 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]]] = (), ) -> operation.Operation: r"""Updates/Creates multiple intents in the specified agent. @@ -1401,8 +1448,10 @@ def sample_batch_update_intents(): 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.api_core.operation.Operation: @@ -1475,7 +1524,7 @@ def batch_delete_intents( intents: Optional[MutableSequence[intent.Intent]] = 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]]] = (), ) -> operation.Operation: r"""Deletes intents in the specified agent. @@ -1548,8 +1597,10 @@ def sample_batch_delete_intents(): 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.api_core.operation.Operation: @@ -1639,7 +1690,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1650,8 +1701,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1692,7 +1745,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1703,8 +1756,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1745,7 +1800,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1760,8 +1815,10 @@ def cancel_operation( 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: None """ @@ -1798,7 +1855,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. @@ -1809,8 +1866,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. @@ -1851,7 +1910,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. @@ -1862,8 +1921,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-dialogflow/google/cloud/dialogflow_v2/services/intents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/pagers.py index 43ff84d89cb3..52ee71b10097 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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 = intent.ListIntentsRequest(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 = intent.ListIntentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc.py index 69b048918095..ca39e06f3b83 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import intent from google.cloud.dialogflow_v2.types import intent as gcd_intent from .base import DEFAULT_CLIENT_INFO, IntentsTransport +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.dialogflow.v2.Intents", + "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.dialogflow.v2.Intents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IntentsGrpcTransport(IntentsTransport): """gRPC backend transport for Intents. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -273,7 +361,7 @@ def list_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_intents" not in self._stubs: - self._stubs["list_intents"] = self.grpc_channel.unary_unary( + self._stubs["list_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/ListIntents", request_serializer=intent.ListIntentsRequest.serialize, response_deserializer=intent.ListIntentsResponse.deserialize, @@ -297,7 +385,7 @@ def get_intent(self) -> Callable[[intent.GetIntentRequest], intent.Intent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_intent" not in self._stubs: - self._stubs["get_intent"] = self.grpc_channel.unary_unary( + self._stubs["get_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/GetIntent", request_serializer=intent.GetIntentRequest.serialize, response_deserializer=intent.Intent.deserialize, @@ -327,7 +415,7 @@ def create_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_intent" not in self._stubs: - self._stubs["create_intent"] = self.grpc_channel.unary_unary( + self._stubs["create_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/CreateIntent", request_serializer=gcd_intent.CreateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -357,7 +445,7 @@ def update_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_intent" not in self._stubs: - self._stubs["update_intent"] = self.grpc_channel.unary_unary( + self._stubs["update_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/UpdateIntent", request_serializer=gcd_intent.UpdateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -386,7 +474,7 @@ def delete_intent(self) -> Callable[[intent.DeleteIntentRequest], empty_pb2.Empt # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_intent" not in self._stubs: - self._stubs["delete_intent"] = self.grpc_channel.unary_unary( + self._stubs["delete_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/DeleteIntent", request_serializer=intent.DeleteIntentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -426,7 +514,7 @@ def batch_update_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_intents" not in self._stubs: - self._stubs["batch_update_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/BatchUpdateIntents", request_serializer=intent.BatchUpdateIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -466,7 +554,7 @@ def batch_delete_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_intents" not in self._stubs: - self._stubs["batch_delete_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/BatchDeleteIntents", request_serializer=intent.BatchDeleteIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -474,7 +562,7 @@ def batch_delete_intents( return self._stubs["batch_delete_intents"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -486,7 +574,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -503,7 +591,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -522,7 +610,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -541,7 +629,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, @@ -558,7 +646,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-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py index da2f6c63b612..cb25eb950b72 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import intent from google.cloud.dialogflow_v2.types import intent as gcd_intent @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, IntentsTransport from .grpc import IntentsGrpcTransport +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.dialogflow.v2.Intents", + "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.dialogflow.v2.Intents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IntentsGrpcAsyncIOTransport(IntentsTransport): """gRPC AsyncIO backend transport for Intents. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -283,7 +368,7 @@ def list_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_intents" not in self._stubs: - self._stubs["list_intents"] = self.grpc_channel.unary_unary( + self._stubs["list_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/ListIntents", request_serializer=intent.ListIntentsRequest.serialize, response_deserializer=intent.ListIntentsResponse.deserialize, @@ -309,7 +394,7 @@ def get_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_intent" not in self._stubs: - self._stubs["get_intent"] = self.grpc_channel.unary_unary( + self._stubs["get_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/GetIntent", request_serializer=intent.GetIntentRequest.serialize, response_deserializer=intent.Intent.deserialize, @@ -339,7 +424,7 @@ def create_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_intent" not in self._stubs: - self._stubs["create_intent"] = self.grpc_channel.unary_unary( + self._stubs["create_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/CreateIntent", request_serializer=gcd_intent.CreateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -369,7 +454,7 @@ def update_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_intent" not in self._stubs: - self._stubs["update_intent"] = self.grpc_channel.unary_unary( + self._stubs["update_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/UpdateIntent", request_serializer=gcd_intent.UpdateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -400,7 +485,7 @@ def delete_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_intent" not in self._stubs: - self._stubs["delete_intent"] = self.grpc_channel.unary_unary( + self._stubs["delete_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/DeleteIntent", request_serializer=intent.DeleteIntentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -442,7 +527,7 @@ def batch_update_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_intents" not in self._stubs: - self._stubs["batch_update_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/BatchUpdateIntents", request_serializer=intent.BatchUpdateIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -484,7 +569,7 @@ def batch_delete_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_intents" not in self._stubs: - self._stubs["batch_delete_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Intents/BatchDeleteIntents", request_serializer=intent.BatchDeleteIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -562,7 +647,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: @@ -578,7 +663,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -595,7 +680,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -614,7 +699,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -633,7 +718,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, @@ -650,7 +735,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-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/rest.py index 2ffce4fe883c..ae88e6021ba1 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/intents/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 @@ -41,6 +41,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, @@ -125,8 +133,10 @@ def post_update_intent(self, response): def pre_batch_delete_intents( self, request: intent.BatchDeleteIntentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[intent.BatchDeleteIntentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + intent.BatchDeleteIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_intents Override in a subclass to manipulate the request or metadata @@ -148,8 +158,10 @@ def post_batch_delete_intents( def pre_batch_update_intents( self, request: intent.BatchUpdateIntentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[intent.BatchUpdateIntentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + intent.BatchUpdateIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_intents Override in a subclass to manipulate the request or metadata @@ -171,8 +183,8 @@ def post_batch_update_intents( def pre_create_intent( self, request: gcd_intent.CreateIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_intent.CreateIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_intent.CreateIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_intent Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_create_intent(self, response: gcd_intent.Intent) -> gcd_intent.Intent: return response def pre_delete_intent( - self, request: intent.DeleteIntentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.DeleteIntentRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.DeleteIntentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.DeleteIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_intent Override in a subclass to manipulate the request or metadata @@ -200,8 +214,10 @@ def pre_delete_intent( return request, metadata def pre_get_intent( - self, request: intent.GetIntentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.GetIntentRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.GetIntentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.GetIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_intent Override in a subclass to manipulate the request or metadata @@ -219,8 +235,10 @@ def post_get_intent(self, response: intent.Intent) -> intent.Intent: return response def pre_list_intents( - self, request: intent.ListIntentsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.ListIntentsRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.ListIntentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.ListIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_intents Override in a subclass to manipulate the request or metadata @@ -242,8 +260,8 @@ def post_list_intents( def pre_update_intent( self, request: gcd_intent.UpdateIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_intent.UpdateIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_intent.UpdateIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_intent Override in a subclass to manipulate the request or metadata @@ -263,8 +281,10 @@ def post_update_intent(self, response: gcd_intent.Intent) -> gcd_intent.Intent: 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 @@ -286,8 +306,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 @@ -309,8 +331,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -330,8 +354,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -353,8 +379,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -554,7 +582,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete intents method over HTTP. @@ -565,8 +593,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: ~.operations_pb2.Operation: @@ -579,6 +609,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseBatchDeleteIntents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_intents( request, metadata ) @@ -595,6 +626,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.dialogflow_v2.IntentsClient.BatchDeleteIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "BatchDeleteIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._BatchDeleteIntents._get_response( self._host, @@ -614,7 +672,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_intents(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.dialogflow_v2.IntentsClient.batch_delete_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "BatchDeleteIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateIntents( @@ -652,7 +732,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update intents method over HTTP. @@ -662,8 +742,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: ~.operations_pb2.Operation: @@ -676,6 +758,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseBatchUpdateIntents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_intents( request, metadata ) @@ -692,6 +775,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.dialogflow_v2.IntentsClient.BatchUpdateIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "BatchUpdateIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._BatchUpdateIntents._get_response( self._host, @@ -711,7 +821,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_intents(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.dialogflow_v2.IntentsClient.batch_update_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "BatchUpdateIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIntent(_BaseIntentsRestTransport._BaseCreateIntent, IntentsRestStub): @@ -747,7 +879,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]]] = (), ) -> gcd_intent.Intent: r"""Call the create intent method over HTTP. @@ -758,8 +890,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: ~.gcd_intent.Intent: @@ -780,6 +914,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseCreateIntent._get_http_options() ) + request, metadata = self._interceptor.pre_create_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseCreateIntent._get_transcoded_request( @@ -798,6 +933,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.dialogflow_v2.IntentsClient.CreateIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "CreateIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._CreateIntent._get_response( self._host, @@ -819,7 +981,29 @@ def __call__( pb_resp = gcd_intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_intent.Intent.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.dialogflow_v2.IntentsClient.create_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "CreateIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteIntent(_BaseIntentsRestTransport._BaseDeleteIntent, IntentsRestStub): @@ -854,7 +1038,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 intent method over HTTP. @@ -865,13 +1049,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 = ( _BaseIntentsRestTransport._BaseDeleteIntent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseDeleteIntent._get_transcoded_request( @@ -886,6 +1073,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.dialogflow_v2.IntentsClient.DeleteIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "DeleteIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._DeleteIntent._get_response( self._host, @@ -933,7 +1147,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]]] = (), ) -> intent.Intent: r"""Call the get intent method over HTTP. @@ -944,8 +1158,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: ~.intent.Intent: @@ -964,6 +1180,7 @@ def __call__( """ http_options = _BaseIntentsRestTransport._BaseGetIntent._get_http_options() + request, metadata = self._interceptor.pre_get_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetIntent._get_transcoded_request( @@ -978,6 +1195,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.dialogflow_v2.IntentsClient.GetIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetIntent._get_response( self._host, @@ -998,7 +1242,29 @@ def __call__( pb_resp = intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = intent.Intent.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.dialogflow_v2.IntentsClient.get_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIntents(_BaseIntentsRestTransport._BaseListIntents, IntentsRestStub): @@ -1033,7 +1299,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]]] = (), ) -> intent.ListIntentsResponse: r"""Call the list intents method over HTTP. @@ -1044,8 +1310,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: ~.intent.ListIntentsResponse: @@ -1057,6 +1325,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListIntents._get_http_options() ) + request, metadata = self._interceptor.pre_list_intents(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListIntents._get_transcoded_request( @@ -1071,6 +1340,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.dialogflow_v2.IntentsClient.ListIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListIntents._get_response( self._host, @@ -1091,7 +1387,29 @@ def __call__( pb_resp = intent.ListIntentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_intents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = intent.ListIntentsResponse.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.dialogflow_v2.IntentsClient.list_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIntent(_BaseIntentsRestTransport._BaseUpdateIntent, IntentsRestStub): @@ -1127,7 +1445,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]]] = (), ) -> gcd_intent.Intent: r"""Call the update intent method over HTTP. @@ -1138,8 +1456,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: ~.gcd_intent.Intent: @@ -1160,6 +1480,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseUpdateIntent._get_http_options() ) + request, metadata = self._interceptor.pre_update_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseUpdateIntent._get_transcoded_request( @@ -1178,6 +1499,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.dialogflow_v2.IntentsClient.UpdateIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "UpdateIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._UpdateIntent._get_response( self._host, @@ -1199,7 +1547,29 @@ def __call__( pb_resp = gcd_intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_intent.Intent.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.dialogflow_v2.IntentsClient.update_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "UpdateIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1290,7 +1660,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. @@ -1300,8 +1670,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. @@ -1310,6 +1682,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1324,6 +1697,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.dialogflow_v2.IntentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetLocation._get_response( self._host, @@ -1343,6 +1743,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.dialogflow_v2.IntentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1381,7 +1802,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. @@ -1391,8 +1812,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. @@ -1401,6 +1824,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1415,6 +1839,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.dialogflow_v2.IntentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListLocations._get_response( self._host, @@ -1434,6 +1885,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.dialogflow_v2.IntentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1474,7 +1946,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1484,13 +1956,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 = ( _BaseIntentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1507,6 +1982,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.dialogflow_v2.IntentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._CancelOperation._get_response( self._host, @@ -1560,7 +2062,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1570,8 +2072,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: operations_pb2.Operation: Response from GetOperation method. @@ -1580,6 +2084,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1594,6 +2099,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.dialogflow_v2.IntentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetOperation._get_response( self._host, @@ -1613,6 +2145,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.IntentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1653,7 +2206,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1663,8 +2216,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1673,6 +2228,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1687,6 +2243,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.dialogflow_v2.IntentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListOperations._get_response( self._host, @@ -1706,6 +2289,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.IntentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Intents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py index eed9dadc459f..ad4840a8bb92 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport from .transports.grpc_asyncio import KnowledgeBasesGrpcAsyncIOTransport +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 KnowledgeBasesAsyncClient: """Service for managing @@ -263,6 +273,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.dialogflow_v2.KnowledgeBasesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "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.dialogflow.v2.KnowledgeBases", + "credentialsType": None, + }, + ) + async def list_knowledge_bases( self, request: Optional[Union[knowledge_base.ListKnowledgeBasesRequest, dict]] = None, @@ -270,7 +302,7 @@ async def list_knowledge_bases( 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.ListKnowledgeBasesAsyncPager: r"""Returns the list of all knowledge bases of the specified agent. @@ -317,8 +349,10 @@ async def sample_list_knowledge_bases(): 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.dialogflow_v2.services.knowledge_bases.pagers.ListKnowledgeBasesAsyncPager: @@ -393,7 +427,7 @@ async def get_knowledge_base( 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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Retrieves the specified knowledge base. @@ -438,8 +472,10 @@ async def sample_get_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -513,7 +549,7 @@ async def create_knowledge_base( knowledge_base: Optional[gcd_knowledge_base.KnowledgeBase] = 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Creates a knowledge base. @@ -569,8 +605,10 @@ async def sample_create_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -645,7 +683,7 @@ async def delete_knowledge_base( 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 the specified knowledge base. @@ -687,8 +725,10 @@ async def sample_delete_knowledge_base(): 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 @@ -743,7 +783,7 @@ async def update_knowledge_base( 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Updates the specified knowledge base. @@ -798,8 +838,10 @@ async def sample_update_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -873,7 +915,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -884,8 +926,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -926,7 +970,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -937,8 +981,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -979,7 +1025,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -994,8 +1040,10 @@ async def cancel_operation( 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: None """ @@ -1032,7 +1080,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. @@ -1043,8 +1091,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. @@ -1085,7 +1135,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. @@ -1096,8 +1146,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-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/client.py index aa84ff448b5f..b99e22250a11 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -582,6 +592,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( @@ -647,6 +661,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.dialogflow_v2.KnowledgeBasesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "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.dialogflow.v2.KnowledgeBases", + "credentialsType": None, + }, + ) + def list_knowledge_bases( self, request: Optional[Union[knowledge_base.ListKnowledgeBasesRequest, dict]] = None, @@ -654,7 +691,7 @@ def list_knowledge_bases( 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.ListKnowledgeBasesPager: r"""Returns the list of all knowledge bases of the specified agent. @@ -701,8 +738,10 @@ def sample_list_knowledge_bases(): 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.dialogflow_v2.services.knowledge_bases.pagers.ListKnowledgeBasesPager: @@ -774,7 +813,7 @@ def get_knowledge_base( 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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Retrieves the specified knowledge base. @@ -819,8 +858,10 @@ def sample_get_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -891,7 +932,7 @@ def create_knowledge_base( knowledge_base: Optional[gcd_knowledge_base.KnowledgeBase] = 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Creates a knowledge base. @@ -947,8 +988,10 @@ def sample_create_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -1020,7 +1063,7 @@ def delete_knowledge_base( 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 the specified knowledge base. @@ -1062,8 +1105,10 @@ def sample_delete_knowledge_base(): 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 @@ -1115,7 +1160,7 @@ def update_knowledge_base( 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Updates the specified knowledge base. @@ -1170,8 +1215,10 @@ def sample_update_knowledge_base(): 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.dialogflow_v2.types.KnowledgeBase: @@ -1255,7 +1302,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1266,8 +1313,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1308,7 +1357,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1319,8 +1368,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1361,7 +1412,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1376,8 +1427,10 @@ def cancel_operation( 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: None """ @@ -1414,7 +1467,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. @@ -1425,8 +1478,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. @@ -1467,7 +1522,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. @@ -1478,8 +1533,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-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/pagers.py index cb57d00bf575..2a25e64bc8a7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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 = knowledge_base.ListKnowledgeBasesRequest(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 = knowledge_base.ListKnowledgeBasesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py index ae2f124ee767..7826c6bb907d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import knowledge_base as gcd_knowledge_base from google.cloud.dialogflow_v2.types import knowledge_base from .base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport +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.dialogflow.v2.KnowledgeBases", + "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.dialogflow.v2.KnowledgeBases", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class KnowledgeBasesGrpcTransport(KnowledgeBasesTransport): """gRPC backend transport for KnowledgeBases. @@ -184,7 +265,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 @@ -262,7 +348,7 @@ def list_knowledge_bases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_knowledge_bases" not in self._stubs: - self._stubs["list_knowledge_bases"] = self.grpc_channel.unary_unary( + self._stubs["list_knowledge_bases"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/ListKnowledgeBases", request_serializer=knowledge_base.ListKnowledgeBasesRequest.serialize, response_deserializer=knowledge_base.ListKnowledgeBasesResponse.deserialize, @@ -290,7 +376,7 @@ def get_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_knowledge_base" not in self._stubs: - self._stubs["get_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["get_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/GetKnowledgeBase", request_serializer=knowledge_base.GetKnowledgeBaseRequest.serialize, response_deserializer=knowledge_base.KnowledgeBase.deserialize, @@ -319,7 +405,7 @@ def create_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_knowledge_base" not in self._stubs: - self._stubs["create_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["create_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/CreateKnowledgeBase", request_serializer=gcd_knowledge_base.CreateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -345,7 +431,7 @@ def delete_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_knowledge_base" not in self._stubs: - self._stubs["delete_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["delete_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/DeleteKnowledgeBase", request_serializer=knowledge_base.DeleteKnowledgeBaseRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -374,7 +460,7 @@ def update_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_knowledge_base" not in self._stubs: - self._stubs["update_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["update_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/UpdateKnowledgeBase", request_serializer=gcd_knowledge_base.UpdateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -382,7 +468,7 @@ def update_knowledge_base( return self._stubs["update_knowledge_base"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -394,7 +480,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -411,7 +497,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -430,7 +516,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -449,7 +535,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, @@ -466,7 +552,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-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py index 934e2101d802..95407685ca10 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import knowledge_base as gcd_knowledge_base from google.cloud.dialogflow_v2.types import knowledge_base @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport from .grpc import KnowledgeBasesGrpcTransport +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.dialogflow.v2.KnowledgeBases", + "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.dialogflow.v2.KnowledgeBases", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class KnowledgeBasesGrpcAsyncIOTransport(KnowledgeBasesTransport): """gRPC AsyncIO backend transport for KnowledgeBases. @@ -231,10 +313,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 @@ -270,7 +355,7 @@ def list_knowledge_bases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_knowledge_bases" not in self._stubs: - self._stubs["list_knowledge_bases"] = self.grpc_channel.unary_unary( + self._stubs["list_knowledge_bases"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/ListKnowledgeBases", request_serializer=knowledge_base.ListKnowledgeBasesRequest.serialize, response_deserializer=knowledge_base.ListKnowledgeBasesResponse.deserialize, @@ -299,7 +384,7 @@ def get_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_knowledge_base" not in self._stubs: - self._stubs["get_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["get_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/GetKnowledgeBase", request_serializer=knowledge_base.GetKnowledgeBaseRequest.serialize, response_deserializer=knowledge_base.KnowledgeBase.deserialize, @@ -328,7 +413,7 @@ def create_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_knowledge_base" not in self._stubs: - self._stubs["create_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["create_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/CreateKnowledgeBase", request_serializer=gcd_knowledge_base.CreateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -356,7 +441,7 @@ def delete_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_knowledge_base" not in self._stubs: - self._stubs["delete_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["delete_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/DeleteKnowledgeBase", request_serializer=knowledge_base.DeleteKnowledgeBaseRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -385,7 +470,7 @@ def update_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_knowledge_base" not in self._stubs: - self._stubs["update_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["update_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.KnowledgeBases/UpdateKnowledgeBase", request_serializer=gcd_knowledge_base.UpdateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -453,7 +538,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: @@ -469,7 +554,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -486,7 +571,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -505,7 +590,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -524,7 +609,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, @@ -541,7 +626,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-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py index ed4c15b6f94d..a7f8d8cfe37b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/knowledge_bases/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 @@ -41,6 +41,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, @@ -109,9 +117,10 @@ def post_update_knowledge_base(self, response): def pre_create_knowledge_base( self, request: gcd_knowledge_base.CreateKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_knowledge_base.CreateKnowledgeBaseRequest, Sequence[Tuple[str, str]] + gcd_knowledge_base.CreateKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_knowledge_base @@ -134,8 +143,11 @@ def post_create_knowledge_base( def pre_delete_knowledge_base( self, request: knowledge_base.DeleteKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.DeleteKnowledgeBaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.DeleteKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_knowledge_base Override in a subclass to manipulate the request or metadata @@ -146,8 +158,10 @@ def pre_delete_knowledge_base( def pre_get_knowledge_base( self, request: knowledge_base.GetKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.GetKnowledgeBaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.GetKnowledgeBaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_knowledge_base Override in a subclass to manipulate the request or metadata @@ -169,8 +183,11 @@ def post_get_knowledge_base( def pre_list_knowledge_bases( self, request: knowledge_base.ListKnowledgeBasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.ListKnowledgeBasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.ListKnowledgeBasesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_knowledge_bases Override in a subclass to manipulate the request or metadata @@ -192,9 +209,10 @@ def post_list_knowledge_bases( def pre_update_knowledge_base( self, request: gcd_knowledge_base.UpdateKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_knowledge_base.UpdateKnowledgeBaseRequest, Sequence[Tuple[str, str]] + gcd_knowledge_base.UpdateKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_knowledge_base @@ -217,8 +235,10 @@ def post_update_knowledge_base( 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 @@ -240,8 +260,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 @@ -263,8 +285,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -284,8 +308,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -307,8 +333,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -451,7 +479,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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Call the create knowledge base method over HTTP. @@ -462,8 +490,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: ~.gcd_knowledge_base.KnowledgeBase: @@ -485,6 +515,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseCreateKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_create_knowledge_base( request, metadata ) @@ -501,6 +532,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 = 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.dialogflow_v2.KnowledgeBasesClient.CreateKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "CreateKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._CreateKnowledgeBase._get_response( self._host, @@ -522,7 +580,31 @@ def __call__( pb_resp = gcd_knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_knowledge_base.KnowledgeBase.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.dialogflow_v2.KnowledgeBasesClient.create_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "CreateKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteKnowledgeBase( @@ -560,7 +642,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 knowledge base method over HTTP. @@ -571,13 +653,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 = ( _BaseKnowledgeBasesRestTransport._BaseDeleteKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_delete_knowledge_base( request, metadata ) @@ -590,6 +675,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.dialogflow_v2.KnowledgeBasesClient.DeleteKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "DeleteKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._DeleteKnowledgeBase._get_response( self._host, @@ -639,7 +751,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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Call the get knowledge base method over HTTP. @@ -650,8 +762,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: ~.knowledge_base.KnowledgeBase: @@ -673,6 +787,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_get_knowledge_base( request, metadata ) @@ -685,6 +800,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 = 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.dialogflow_v2.KnowledgeBasesClient.GetKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetKnowledgeBase._get_response( self._host, @@ -705,7 +847,29 @@ def __call__( pb_resp = knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = knowledge_base.KnowledgeBase.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.dialogflow_v2.KnowledgeBasesClient.get_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListKnowledgeBases( @@ -742,7 +906,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]]] = (), ) -> knowledge_base.ListKnowledgeBasesResponse: r"""Call the list knowledge bases method over HTTP. @@ -753,8 +917,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: ~.knowledge_base.ListKnowledgeBasesResponse: @@ -766,6 +932,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListKnowledgeBases._get_http_options() ) + request, metadata = self._interceptor.pre_list_knowledge_bases( request, metadata ) @@ -778,6 +945,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 = 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.dialogflow_v2.KnowledgeBasesClient.ListKnowledgeBases", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListKnowledgeBases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListKnowledgeBases._get_response( self._host, @@ -798,7 +992,31 @@ def __call__( pb_resp = knowledge_base.ListKnowledgeBasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_knowledge_bases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + knowledge_base.ListKnowledgeBasesResponse.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.dialogflow_v2.KnowledgeBasesClient.list_knowledge_bases", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListKnowledgeBases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateKnowledgeBase( @@ -837,7 +1055,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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Call the update knowledge base method over HTTP. @@ -848,8 +1066,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: ~.gcd_knowledge_base.KnowledgeBase: @@ -871,6 +1091,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseUpdateKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_update_knowledge_base( request, metadata ) @@ -887,6 +1108,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 = 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.dialogflow_v2.KnowledgeBasesClient.UpdateKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "UpdateKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._UpdateKnowledgeBase._get_response( self._host, @@ -908,7 +1156,31 @@ def __call__( pb_resp = gcd_knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_knowledge_base.KnowledgeBase.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.dialogflow_v2.KnowledgeBasesClient.update_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "UpdateKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1000,7 +1272,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. @@ -1010,8 +1282,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. @@ -1020,6 +1294,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1030,6 +1305,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.dialogflow_v2.KnowledgeBasesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetLocation._get_response( self._host, @@ -1049,6 +1351,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.dialogflow_v2.KnowledgeBasesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1089,7 +1412,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. @@ -1099,8 +1422,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. @@ -1109,6 +1434,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1119,6 +1445,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.dialogflow_v2.KnowledgeBasesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListLocations._get_response( self._host, @@ -1138,6 +1491,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.dialogflow_v2.KnowledgeBasesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1178,7 +1552,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1188,13 +1562,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 = ( _BaseKnowledgeBasesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1207,6 +1584,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.dialogflow_v2.KnowledgeBasesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._CancelOperation._get_response( self._host, @@ -1262,7 +1666,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1272,8 +1676,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: operations_pb2.Operation: Response from GetOperation method. @@ -1282,6 +1688,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1292,6 +1699,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.dialogflow_v2.KnowledgeBasesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetOperation._get_response( self._host, @@ -1311,6 +1745,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.KnowledgeBasesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1351,7 +1806,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1361,8 +1816,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1371,6 +1828,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1381,6 +1839,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.dialogflow_v2.KnowledgeBasesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListOperations._get_response( self._host, @@ -1400,6 +1885,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.KnowledgeBasesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.KnowledgeBases", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/async_client.py index 66ec34f4ea1b..2dbea20152af 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 ( AsyncIterable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ParticipantsTransport from .transports.grpc_asyncio import ParticipantsGrpcAsyncIOTransport +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 ParticipantsAsyncClient: """Service for managing @@ -275,6 +285,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.dialogflow_v2.ParticipantsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "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.dialogflow.v2.Participants", + "credentialsType": None, + }, + ) + async def create_participant( self, request: Optional[Union[gcd_participant.CreateParticipantRequest, dict]] = None, @@ -283,7 +315,7 @@ async def create_participant( participant: Optional[gcd_participant.Participant] = 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]]] = (), ) -> gcd_participant.Participant: r"""Creates a new participant in a conversation. @@ -333,8 +365,10 @@ async def sample_create_participant(): 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.dialogflow_v2.types.Participant: @@ -397,7 +431,7 @@ async def get_participant( 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]]] = (), ) -> participant.Participant: r"""Retrieves a conversation participant. @@ -441,8 +475,10 @@ async def sample_get_participant(): 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.dialogflow_v2.types.Participant: @@ -503,7 +539,7 @@ async def list_participants( 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.ListParticipantsAsyncPager: r"""Returns the list of all participants in the specified conversation. @@ -550,8 +586,10 @@ async def sample_list_participants(): 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.dialogflow_v2.services.participants.pagers.ListParticipantsAsyncPager: @@ -627,7 +665,7 @@ async def update_participant( 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]]] = (), ) -> gcd_participant.Participant: r"""Updates the specified participant. @@ -675,8 +713,10 @@ async def sample_update_participant(): 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.dialogflow_v2.types.Participant: @@ -743,7 +783,7 @@ async def analyze_content( event_input: Optional[session.EventInput] = 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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. @@ -810,8 +850,10 @@ async def sample_analyze_content(): 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.dialogflow_v2.types.AnalyzeContentResponse: @@ -879,7 +921,7 @@ def streaming_analyze_content( *, 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]]] = (), ) -> Awaitable[AsyncIterable[participant.StreamingAnalyzeContentResponse]]: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. Note: @@ -987,8 +1029,10 @@ def request_generator(): 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: AsyncIterable[google.cloud.dialogflow_v2.types.StreamingAnalyzeContentResponse]: @@ -1048,7 +1092,7 @@ async def suggest_articles( 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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Gets suggested articles for a participant based on specific historical messages. @@ -1094,8 +1138,10 @@ async def sample_suggest_articles(): 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.dialogflow_v2.types.SuggestArticlesResponse: @@ -1156,7 +1202,7 @@ async def suggest_faq_answers( 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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Gets suggested faq answers for a participant based on specific historical messages. @@ -1202,8 +1248,10 @@ async def sample_suggest_faq_answers(): 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.dialogflow_v2.types.SuggestFaqAnswersResponse: @@ -1264,7 +1312,7 @@ async def suggest_smart_replies( 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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Gets smart replies for a participant based on specific historical messages. @@ -1310,8 +1358,10 @@ async def sample_suggest_smart_replies(): 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.dialogflow_v2.types.SuggestSmartRepliesResponse: @@ -1373,7 +1423,7 @@ async def suggest_knowledge_assist( *, 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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Gets knowledge assist suggestions based on historical messages. @@ -1411,8 +1461,10 @@ async def sample_suggest_knowledge_assist(): 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.dialogflow_v2.types.SuggestKnowledgeAssistResponse: @@ -1458,7 +1510,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1469,8 +1521,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1511,7 +1565,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1522,8 +1576,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1564,7 +1620,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1579,8 +1635,10 @@ async def cancel_operation( 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: None """ @@ -1617,7 +1675,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. @@ -1628,8 +1686,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. @@ -1670,7 +1730,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. @@ -1681,8 +1741,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-dialogflow/google/cloud/dialogflow_v2/services/participants/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/client.py index 0a31c943c4b5..e18bada3741f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -712,6 +722,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( @@ -774,6 +788,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.dialogflow_v2.ParticipantsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "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.dialogflow.v2.Participants", + "credentialsType": None, + }, + ) + def create_participant( self, request: Optional[Union[gcd_participant.CreateParticipantRequest, dict]] = None, @@ -782,7 +819,7 @@ def create_participant( participant: Optional[gcd_participant.Participant] = 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]]] = (), ) -> gcd_participant.Participant: r"""Creates a new participant in a conversation. @@ -832,8 +869,10 @@ def sample_create_participant(): 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.dialogflow_v2.types.Participant: @@ -893,7 +932,7 @@ def get_participant( 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]]] = (), ) -> participant.Participant: r"""Retrieves a conversation participant. @@ -937,8 +976,10 @@ def sample_get_participant(): 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.dialogflow_v2.types.Participant: @@ -996,7 +1037,7 @@ def list_participants( 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.ListParticipantsPager: r"""Returns the list of all participants in the specified conversation. @@ -1043,8 +1084,10 @@ def sample_list_participants(): 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.dialogflow_v2.services.participants.pagers.ListParticipantsPager: @@ -1117,7 +1160,7 @@ def update_participant( 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]]] = (), ) -> gcd_participant.Participant: r"""Updates the specified participant. @@ -1165,8 +1208,10 @@ def sample_update_participant(): 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.dialogflow_v2.types.Participant: @@ -1230,7 +1275,7 @@ def analyze_content( event_input: Optional[session.EventInput] = 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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. @@ -1297,8 +1342,10 @@ def sample_analyze_content(): 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.dialogflow_v2.types.AnalyzeContentResponse: @@ -1361,7 +1408,7 @@ def streaming_analyze_content( *, 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]]] = (), ) -> Iterable[participant.StreamingAnalyzeContentResponse]: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. Note: @@ -1469,8 +1516,10 @@ def request_generator(): 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: Iterable[google.cloud.dialogflow_v2.types.StreamingAnalyzeContentResponse]: @@ -1530,7 +1579,7 @@ def suggest_articles( 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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Gets suggested articles for a participant based on specific historical messages. @@ -1576,8 +1625,10 @@ def sample_suggest_articles(): 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.dialogflow_v2.types.SuggestArticlesResponse: @@ -1635,7 +1686,7 @@ def suggest_faq_answers( 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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Gets suggested faq answers for a participant based on specific historical messages. @@ -1681,8 +1732,10 @@ def sample_suggest_faq_answers(): 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.dialogflow_v2.types.SuggestFaqAnswersResponse: @@ -1740,7 +1793,7 @@ def suggest_smart_replies( 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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Gets smart replies for a participant based on specific historical messages. @@ -1786,8 +1839,10 @@ def sample_suggest_smart_replies(): 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.dialogflow_v2.types.SuggestSmartRepliesResponse: @@ -1846,7 +1901,7 @@ def suggest_knowledge_assist( *, 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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Gets knowledge assist suggestions based on historical messages. @@ -1884,8 +1939,10 @@ def sample_suggest_knowledge_assist(): 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.dialogflow_v2.types.SuggestKnowledgeAssistResponse: @@ -1942,7 +1999,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1953,8 +2010,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1995,7 +2054,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2006,8 +2065,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2048,7 +2109,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2063,8 +2124,10 @@ def cancel_operation( 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: None """ @@ -2101,7 +2164,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. @@ -2112,8 +2175,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. @@ -2154,7 +2219,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. @@ -2165,8 +2230,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-dialogflow/google/cloud/dialogflow_v2/services/participants/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/pagers.py index 7d3181ff6322..99cc2be9532b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 = participant.ListParticipantsRequest(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 = participant.ListParticipantsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc.py index 9fe1dfd7167f..c8f130794693 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import participant from google.cloud.dialogflow_v2.types import participant as gcd_participant from .base import DEFAULT_CLIENT_INFO, ParticipantsTransport +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.dialogflow.v2.Participants", + "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.dialogflow.v2.Participants", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParticipantsGrpcTransport(ParticipantsTransport): """gRPC backend transport for Participants. @@ -183,7 +264,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 @@ -259,7 +345,7 @@ def create_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_participant" not in self._stubs: - self._stubs["create_participant"] = self.grpc_channel.unary_unary( + self._stubs["create_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/CreateParticipant", request_serializer=gcd_participant.CreateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -285,7 +371,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/GetParticipant", request_serializer=participant.GetParticipantRequest.serialize, response_deserializer=participant.Participant.deserialize, @@ -314,7 +400,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/ListParticipants", request_serializer=participant.ListParticipantsRequest.serialize, response_deserializer=participant.ListParticipantsResponse.deserialize, @@ -342,7 +428,7 @@ def update_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_participant" not in self._stubs: - self._stubs["update_participant"] = self.grpc_channel.unary_unary( + self._stubs["update_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/UpdateParticipant", request_serializer=gcd_participant.UpdateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -375,7 +461,7 @@ def analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_content" not in self._stubs: - self._stubs["analyze_content"] = self.grpc_channel.unary_unary( + self._stubs["analyze_content"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/AnalyzeContent", request_serializer=gcd_participant.AnalyzeContentRequest.serialize, response_deserializer=gcd_participant.AnalyzeContentResponse.deserialize, @@ -419,7 +505,9 @@ def streaming_analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_analyze_content" not in self._stubs: - self._stubs["streaming_analyze_content"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_analyze_content" + ] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2.Participants/StreamingAnalyzeContent", request_serializer=participant.StreamingAnalyzeContentRequest.serialize, response_deserializer=participant.StreamingAnalyzeContentResponse.deserialize, @@ -448,7 +536,7 @@ def suggest_articles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_articles" not in self._stubs: - self._stubs["suggest_articles"] = self.grpc_channel.unary_unary( + self._stubs["suggest_articles"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestArticles", request_serializer=participant.SuggestArticlesRequest.serialize, response_deserializer=participant.SuggestArticlesResponse.deserialize, @@ -477,7 +565,7 @@ def suggest_faq_answers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_faq_answers" not in self._stubs: - self._stubs["suggest_faq_answers"] = self.grpc_channel.unary_unary( + self._stubs["suggest_faq_answers"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestFaqAnswers", request_serializer=participant.SuggestFaqAnswersRequest.serialize, response_deserializer=participant.SuggestFaqAnswersResponse.deserialize, @@ -507,7 +595,7 @@ def suggest_smart_replies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_smart_replies" not in self._stubs: - self._stubs["suggest_smart_replies"] = self.grpc_channel.unary_unary( + self._stubs["suggest_smart_replies"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestSmartReplies", request_serializer=participant.SuggestSmartRepliesRequest.serialize, response_deserializer=participant.SuggestSmartRepliesResponse.deserialize, @@ -537,7 +625,7 @@ def suggest_knowledge_assist( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_knowledge_assist" not in self._stubs: - self._stubs["suggest_knowledge_assist"] = self.grpc_channel.unary_unary( + self._stubs["suggest_knowledge_assist"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestKnowledgeAssist", request_serializer=participant.SuggestKnowledgeAssistRequest.serialize, response_deserializer=participant.SuggestKnowledgeAssistResponse.deserialize, @@ -545,7 +633,7 @@ def suggest_knowledge_assist( return self._stubs["suggest_knowledge_assist"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -557,7 +645,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -574,7 +662,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -593,7 +681,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -612,7 +700,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, @@ -629,7 +717,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-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py index 462bfe2122dd..32d572259f22 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import participant from google.cloud.dialogflow_v2.types import participant as gcd_participant @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, ParticipantsTransport from .grpc import ParticipantsGrpcTransport +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.dialogflow.v2.Participants", + "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.dialogflow.v2.Participants", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParticipantsGrpcAsyncIOTransport(ParticipantsTransport): """gRPC AsyncIO backend transport for Participants. @@ -230,10 +312,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 @@ -268,7 +353,7 @@ def create_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_participant" not in self._stubs: - self._stubs["create_participant"] = self.grpc_channel.unary_unary( + self._stubs["create_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/CreateParticipant", request_serializer=gcd_participant.CreateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -296,7 +381,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/GetParticipant", request_serializer=participant.GetParticipantRequest.serialize, response_deserializer=participant.Participant.deserialize, @@ -326,7 +411,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/ListParticipants", request_serializer=participant.ListParticipantsRequest.serialize, response_deserializer=participant.ListParticipantsResponse.deserialize, @@ -355,7 +440,7 @@ def update_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_participant" not in self._stubs: - self._stubs["update_participant"] = self.grpc_channel.unary_unary( + self._stubs["update_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/UpdateParticipant", request_serializer=gcd_participant.UpdateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -389,7 +474,7 @@ def analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_content" not in self._stubs: - self._stubs["analyze_content"] = self.grpc_channel.unary_unary( + self._stubs["analyze_content"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/AnalyzeContent", request_serializer=gcd_participant.AnalyzeContentRequest.serialize, response_deserializer=gcd_participant.AnalyzeContentResponse.deserialize, @@ -433,7 +518,9 @@ def streaming_analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_analyze_content" not in self._stubs: - self._stubs["streaming_analyze_content"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_analyze_content" + ] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2.Participants/StreamingAnalyzeContent", request_serializer=participant.StreamingAnalyzeContentRequest.serialize, response_deserializer=participant.StreamingAnalyzeContentResponse.deserialize, @@ -463,7 +550,7 @@ def suggest_articles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_articles" not in self._stubs: - self._stubs["suggest_articles"] = self.grpc_channel.unary_unary( + self._stubs["suggest_articles"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestArticles", request_serializer=participant.SuggestArticlesRequest.serialize, response_deserializer=participant.SuggestArticlesResponse.deserialize, @@ -493,7 +580,7 @@ def suggest_faq_answers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_faq_answers" not in self._stubs: - self._stubs["suggest_faq_answers"] = self.grpc_channel.unary_unary( + self._stubs["suggest_faq_answers"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestFaqAnswers", request_serializer=participant.SuggestFaqAnswersRequest.serialize, response_deserializer=participant.SuggestFaqAnswersResponse.deserialize, @@ -523,7 +610,7 @@ def suggest_smart_replies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_smart_replies" not in self._stubs: - self._stubs["suggest_smart_replies"] = self.grpc_channel.unary_unary( + self._stubs["suggest_smart_replies"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestSmartReplies", request_serializer=participant.SuggestSmartRepliesRequest.serialize, response_deserializer=participant.SuggestSmartRepliesResponse.deserialize, @@ -553,7 +640,7 @@ def suggest_knowledge_assist( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_knowledge_assist" not in self._stubs: - self._stubs["suggest_knowledge_assist"] = self.grpc_channel.unary_unary( + self._stubs["suggest_knowledge_assist"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Participants/SuggestKnowledgeAssist", request_serializer=participant.SuggestKnowledgeAssistRequest.serialize, response_deserializer=participant.SuggestKnowledgeAssistResponse.deserialize, @@ -655,7 +742,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: @@ -671,7 +758,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -688,7 +775,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +794,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -726,7 +813,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, @@ -743,7 +830,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-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/rest.py index 3c6d211d9ddd..08618be1bd56 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/participants/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 @@ -40,6 +40,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, @@ -144,8 +152,10 @@ def post_update_participant(self, response): def pre_analyze_content( self, request: gcd_participant.AnalyzeContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.AnalyzeContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.AnalyzeContentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for analyze_content Override in a subclass to manipulate the request or metadata @@ -167,8 +177,11 @@ def post_analyze_content( def pre_create_participant( self, request: gcd_participant.CreateParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.CreateParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.CreateParticipantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_participant Override in a subclass to manipulate the request or metadata @@ -190,8 +203,10 @@ def post_create_participant( def pre_get_participant( self, request: participant.GetParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.GetParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.GetParticipantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_participant Override in a subclass to manipulate the request or metadata @@ -213,8 +228,10 @@ def post_get_participant( def pre_list_participants( self, request: participant.ListParticipantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.ListParticipantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.ListParticipantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participants Override in a subclass to manipulate the request or metadata @@ -236,8 +253,10 @@ def post_list_participants( def pre_suggest_articles( self, request: participant.SuggestArticlesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestArticlesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestArticlesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_articles Override in a subclass to manipulate the request or metadata @@ -259,8 +278,10 @@ def post_suggest_articles( def pre_suggest_faq_answers( self, request: participant.SuggestFaqAnswersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestFaqAnswersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestFaqAnswersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_faq_answers Override in a subclass to manipulate the request or metadata @@ -282,8 +303,11 @@ def post_suggest_faq_answers( def pre_suggest_knowledge_assist( self, request: participant.SuggestKnowledgeAssistRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestKnowledgeAssistRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestKnowledgeAssistRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for suggest_knowledge_assist Override in a subclass to manipulate the request or metadata @@ -305,8 +329,10 @@ def post_suggest_knowledge_assist( def pre_suggest_smart_replies( self, request: participant.SuggestSmartRepliesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestSmartRepliesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestSmartRepliesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_smart_replies Override in a subclass to manipulate the request or metadata @@ -328,8 +354,11 @@ def post_suggest_smart_replies( def pre_update_participant( self, request: gcd_participant.UpdateParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.UpdateParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.UpdateParticipantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_participant Override in a subclass to manipulate the request or metadata @@ -351,8 +380,10 @@ def post_update_participant( 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 @@ -374,8 +405,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 @@ -397,8 +430,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -418,8 +453,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -441,8 +478,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -584,7 +623,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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Call the analyze content method over HTTP. @@ -595,8 +634,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: ~.gcd_participant.AnalyzeContentResponse: @@ -608,6 +649,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseAnalyzeContent._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_content(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseAnalyzeContent._get_transcoded_request( http_options, request @@ -622,6 +664,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 = 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.dialogflow_v2.ParticipantsClient.AnalyzeContent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "AnalyzeContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._AnalyzeContent._get_response( self._host, @@ -643,7 +712,31 @@ def __call__( pb_resp = gcd_participant.AnalyzeContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.AnalyzeContentResponse.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.dialogflow_v2.ParticipantsClient.analyze_content", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "AnalyzeContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateParticipant( @@ -681,7 +774,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]]] = (), ) -> gcd_participant.Participant: r"""Call the create participant method over HTTP. @@ -692,8 +785,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: ~.gcd_participant.Participant: @@ -705,6 +800,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseCreateParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_create_participant( request, metadata ) @@ -721,6 +817,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 = 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.dialogflow_v2.ParticipantsClient.CreateParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "CreateParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._CreateParticipant._get_response( self._host, @@ -742,7 +865,29 @@ def __call__( pb_resp = gcd_participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.Participant.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.dialogflow_v2.ParticipantsClient.create_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "CreateParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipant( @@ -779,7 +924,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]]] = (), ) -> participant.Participant: r"""Call the get participant method over HTTP. @@ -790,8 +935,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: ~.participant.Participant: @@ -803,6 +950,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseGetParticipant._get_transcoded_request( http_options, request @@ -813,6 +961,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 = 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.dialogflow_v2.ParticipantsClient.GetParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetParticipant._get_response( self._host, @@ -833,7 +1008,29 @@ def __call__( pb_resp = participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.Participant.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.dialogflow_v2.ParticipantsClient.get_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipants( @@ -870,7 +1067,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]]] = (), ) -> participant.ListParticipantsResponse: r"""Call the list participants method over HTTP. @@ -881,8 +1078,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: ~.participant.ListParticipantsResponse: @@ -894,6 +1093,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListParticipants._get_http_options() ) + request, metadata = self._interceptor.pre_list_participants( request, metadata ) @@ -906,6 +1106,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 = 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.dialogflow_v2.ParticipantsClient.ListParticipants", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListParticipants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListParticipants._get_response( self._host, @@ -926,7 +1153,31 @@ def __call__( pb_resp = participant.ListParticipantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.ListParticipantsResponse.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.dialogflow_v2.ParticipantsClient.list_participants", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListParticipants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingAnalyzeContent( @@ -942,7 +1193,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingAnalyzeContent is not available over REST transport" @@ -983,7 +1234,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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Call the suggest articles method over HTTP. @@ -994,8 +1245,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: ~.participant.SuggestArticlesResponse: @@ -1007,6 +1260,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestArticles._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_articles( request, metadata ) @@ -1023,6 +1277,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 = 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.dialogflow_v2.ParticipantsClient.SuggestArticles", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestArticles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestArticles._get_response( self._host, @@ -1044,7 +1325,31 @@ def __call__( pb_resp = participant.SuggestArticlesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_articles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestArticlesResponse.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.dialogflow_v2.ParticipantsClient.suggest_articles", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestArticles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestFaqAnswers( @@ -1082,7 +1387,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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Call the suggest faq answers method over HTTP. @@ -1093,8 +1398,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: ~.participant.SuggestFaqAnswersResponse: @@ -1106,6 +1413,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestFaqAnswers._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_faq_answers( request, metadata ) @@ -1122,6 +1430,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 = 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.dialogflow_v2.ParticipantsClient.SuggestFaqAnswers", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestFaqAnswers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestFaqAnswers._get_response( self._host, @@ -1143,7 +1478,31 @@ def __call__( pb_resp = participant.SuggestFaqAnswersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_faq_answers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestFaqAnswersResponse.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.dialogflow_v2.ParticipantsClient.suggest_faq_answers", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestFaqAnswers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestKnowledgeAssist( @@ -1181,7 +1540,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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Call the suggest knowledge assist method over HTTP. @@ -1192,8 +1551,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: ~.participant.SuggestKnowledgeAssistResponse: @@ -1205,6 +1566,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestKnowledgeAssist._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_knowledge_assist( request, metadata ) @@ -1221,6 +1583,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 = 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.dialogflow_v2.ParticipantsClient.SuggestKnowledgeAssist", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestKnowledgeAssist", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestKnowledgeAssist._get_response( self._host, @@ -1242,7 +1631,31 @@ def __call__( pb_resp = participant.SuggestKnowledgeAssistResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_knowledge_assist(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + participant.SuggestKnowledgeAssistResponse.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.dialogflow_v2.ParticipantsClient.suggest_knowledge_assist", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestKnowledgeAssist", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestSmartReplies( @@ -1280,7 +1693,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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Call the suggest smart replies method over HTTP. @@ -1291,8 +1704,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: ~.participant.SuggestSmartRepliesResponse: @@ -1304,6 +1719,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestSmartReplies._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_smart_replies( request, metadata ) @@ -1320,6 +1736,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 = 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.dialogflow_v2.ParticipantsClient.SuggestSmartReplies", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestSmartReplies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestSmartReplies._get_response( self._host, @@ -1341,7 +1784,31 @@ def __call__( pb_resp = participant.SuggestSmartRepliesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_smart_replies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestSmartRepliesResponse.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.dialogflow_v2.ParticipantsClient.suggest_smart_replies", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "SuggestSmartReplies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateParticipant( @@ -1379,7 +1846,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]]] = (), ) -> gcd_participant.Participant: r"""Call the update participant method over HTTP. @@ -1390,8 +1857,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: ~.gcd_participant.Participant: @@ -1403,6 +1872,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseUpdateParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_update_participant( request, metadata ) @@ -1419,6 +1889,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 = 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.dialogflow_v2.ParticipantsClient.UpdateParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "UpdateParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._UpdateParticipant._get_response( self._host, @@ -1440,7 +1937,29 @@ def __call__( pb_resp = gcd_participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.Participant.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.dialogflow_v2.ParticipantsClient.update_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "UpdateParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1582,7 +2101,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. @@ -1592,8 +2111,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. @@ -1602,6 +2123,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseParticipantsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1616,6 +2138,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.dialogflow_v2.ParticipantsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetLocation._get_response( self._host, @@ -1635,6 +2184,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.dialogflow_v2.ParticipantsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1675,7 +2245,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. @@ -1685,8 +2255,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. @@ -1695,6 +2267,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1705,6 +2278,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.dialogflow_v2.ParticipantsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListLocations._get_response( self._host, @@ -1724,6 +2324,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.dialogflow_v2.ParticipantsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1764,7 +2385,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1774,13 +2395,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 = ( _BaseParticipantsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1793,6 +2417,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.dialogflow_v2.ParticipantsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._CancelOperation._get_response( self._host, @@ -1848,7 +2499,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1858,8 +2509,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: operations_pb2.Operation: Response from GetOperation method. @@ -1868,6 +2521,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1880,6 +2534,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.dialogflow_v2.ParticipantsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetOperation._get_response( self._host, @@ -1899,6 +2580,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.ParticipantsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1939,7 +2641,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1949,8 +2651,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1959,6 +2663,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1969,6 +2674,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.dialogflow_v2.ParticipantsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListOperations._get_response( self._host, @@ -1988,6 +2720,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.ParticipantsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Participants", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py index 8c52b7313a1f..793e3ec1a7dc 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport from .transports.grpc_asyncio import SessionEntityTypesGrpcAsyncIOTransport +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 SessionEntityTypesAsyncClient: """Service for managing @@ -272,6 +282,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.dialogflow_v2.SessionEntityTypesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "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.dialogflow.v2.SessionEntityTypes", + "credentialsType": None, + }, + ) + async def list_session_entity_types( self, request: Optional[ @@ -281,7 +313,7 @@ async def list_session_entity_types( 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.ListSessionEntityTypesAsyncPager: r"""Returns the list of all session entity types in the specified session. @@ -335,8 +367,10 @@ async def sample_list_session_entity_types(): 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.dialogflow_v2.services.session_entity_types.pagers.ListSessionEntityTypesAsyncPager: @@ -413,7 +447,7 @@ async def get_session_entity_type( 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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. @@ -466,8 +500,10 @@ async def sample_get_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -539,7 +575,7 @@ async def create_session_entity_type( session_entity_type: Optional[gcd_session_entity_type.SessionEntityType] = 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. @@ -609,8 +645,10 @@ async def sample_create_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -686,7 +724,7 @@ async def update_session_entity_type( 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. @@ -747,8 +785,10 @@ async def sample_update_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -825,7 +865,7 @@ async def delete_session_entity_type( 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 the specified session entity type. @@ -875,8 +915,10 @@ async def sample_delete_session_entity_type(): 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 @@ -927,7 +969,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -938,8 +980,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -980,7 +1024,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -991,8 +1035,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1033,7 +1079,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1048,8 +1094,10 @@ async def cancel_operation( 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: None """ @@ -1086,7 +1134,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. @@ -1097,8 +1145,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. @@ -1139,7 +1189,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. @@ -1150,8 +1200,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-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/client.py index cc46abe22863..397fa8434e00 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -592,6 +602,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( @@ -658,6 +672,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.dialogflow_v2.SessionEntityTypesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "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.dialogflow.v2.SessionEntityTypes", + "credentialsType": None, + }, + ) + def list_session_entity_types( self, request: Optional[ @@ -667,7 +704,7 @@ def list_session_entity_types( 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.ListSessionEntityTypesPager: r"""Returns the list of all session entity types in the specified session. @@ -721,8 +758,10 @@ def sample_list_session_entity_types(): 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.dialogflow_v2.services.session_entity_types.pagers.ListSessionEntityTypesPager: @@ -798,7 +837,7 @@ def get_session_entity_type( 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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. @@ -851,8 +890,10 @@ def sample_get_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -921,7 +962,7 @@ def create_session_entity_type( session_entity_type: Optional[gcd_session_entity_type.SessionEntityType] = 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. @@ -991,8 +1032,10 @@ def sample_create_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -1067,7 +1110,7 @@ def update_session_entity_type( 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. @@ -1128,8 +1171,10 @@ def sample_update_session_entity_type(): 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.dialogflow_v2.types.SessionEntityType: @@ -1205,7 +1250,7 @@ def delete_session_entity_type( 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 the specified session entity type. @@ -1255,8 +1300,10 @@ def sample_delete_session_entity_type(): 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 @@ -1319,7 +1366,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1330,8 +1377,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1372,7 +1421,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1383,8 +1432,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1425,7 +1476,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1440,8 +1491,10 @@ def cancel_operation( 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: None """ @@ -1478,7 +1531,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. @@ -1489,8 +1542,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. @@ -1531,7 +1586,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. @@ -1542,8 +1597,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-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/pagers.py index 499770997a36..f789d70215f1 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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 = session_entity_type.ListSessionEntityTypesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = session_entity_type.ListSessionEntityTypesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py index 0ec779b679a2..ad73ad093bf7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( session_entity_type as gcd_session_entity_type, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport +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.dialogflow.v2.SessionEntityTypes", + "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.dialogflow.v2.SessionEntityTypes", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionEntityTypesGrpcTransport(SessionEntityTypesTransport): """gRPC backend transport for SessionEntityTypes. @@ -186,7 +267,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 @@ -267,7 +353,7 @@ def list_session_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_session_entity_types" not in self._stubs: - self._stubs["list_session_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_session_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/ListSessionEntityTypes", request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, @@ -300,7 +386,7 @@ def get_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_session_entity_type" not in self._stubs: - self._stubs["get_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_session_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/GetSessionEntityType", request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, response_deserializer=session_entity_type.SessionEntityType.deserialize, @@ -336,7 +422,9 @@ def create_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_session_entity_type" not in self._stubs: - self._stubs["create_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/CreateSessionEntityType", request_serializer=gcd_session_entity_type.CreateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -369,7 +457,9 @@ def update_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_session_entity_type" not in self._stubs: - self._stubs["update_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/UpdateSessionEntityType", request_serializer=gcd_session_entity_type.UpdateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -401,7 +491,9 @@ def delete_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_session_entity_type" not in self._stubs: - self._stubs["delete_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/DeleteSessionEntityType", request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -409,7 +501,7 @@ def delete_session_entity_type( return self._stubs["delete_session_entity_type"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -421,7 +513,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -438,7 +530,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +549,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -476,7 +568,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, @@ -493,7 +585,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-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py index 66123cc5f872..3495c4dbb6a6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import ( session_entity_type as gcd_session_entity_type, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport from .grpc import SessionEntityTypesGrpcTransport +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.dialogflow.v2.SessionEntityTypes", + "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.dialogflow.v2.SessionEntityTypes", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionEntityTypesGrpcAsyncIOTransport(SessionEntityTypesTransport): """gRPC AsyncIO backend transport for SessionEntityTypes. @@ -233,10 +315,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 @@ -275,7 +360,7 @@ def list_session_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_session_entity_types" not in self._stubs: - self._stubs["list_session_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_session_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/ListSessionEntityTypes", request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, @@ -308,7 +393,7 @@ def get_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_session_entity_type" not in self._stubs: - self._stubs["get_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_session_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/GetSessionEntityType", request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, response_deserializer=session_entity_type.SessionEntityType.deserialize, @@ -344,7 +429,9 @@ def create_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_session_entity_type" not in self._stubs: - self._stubs["create_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/CreateSessionEntityType", request_serializer=gcd_session_entity_type.CreateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -377,7 +464,9 @@ def update_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_session_entity_type" not in self._stubs: - self._stubs["update_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/UpdateSessionEntityType", request_serializer=gcd_session_entity_type.UpdateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -409,7 +498,9 @@ def delete_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_session_entity_type" not in self._stubs: - self._stubs["delete_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.SessionEntityTypes/DeleteSessionEntityType", request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -477,7 +568,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: @@ -493,7 +584,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -510,7 +601,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -529,7 +620,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -548,7 +639,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, @@ -565,7 +656,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-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py index 46e5aacf2b27..0304c6a29855 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/session_entity_types/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 @@ -43,6 +43,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, @@ -111,10 +119,10 @@ def post_update_session_entity_type(self, response): def pre_create_session_entity_type( self, request: gcd_session_entity_type.CreateSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_session_entity_type.CreateSessionEntityTypeRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_session_entity_type @@ -137,9 +145,10 @@ def post_create_session_entity_type( def pre_delete_session_entity_type( self, request: session_entity_type.DeleteSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.DeleteSessionEntityTypeRequest, Sequence[Tuple[str, str]] + session_entity_type.DeleteSessionEntityTypeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_session_entity_type @@ -151,9 +160,10 @@ def pre_delete_session_entity_type( def pre_get_session_entity_type( self, request: session_entity_type.GetSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.GetSessionEntityTypeRequest, Sequence[Tuple[str, str]] + session_entity_type.GetSessionEntityTypeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_session_entity_type @@ -176,9 +186,10 @@ def post_get_session_entity_type( def pre_list_session_entity_types( self, request: session_entity_type.ListSessionEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.ListSessionEntityTypesRequest, Sequence[Tuple[str, str]] + session_entity_type.ListSessionEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_session_entity_types @@ -201,10 +212,10 @@ def post_list_session_entity_types( def pre_update_session_entity_type( self, request: gcd_session_entity_type.UpdateSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_session_entity_type.UpdateSessionEntityTypeRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_session_entity_type @@ -227,8 +238,10 @@ def post_update_session_entity_type( 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 @@ -250,8 +263,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 @@ -273,8 +288,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -294,8 +311,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -317,8 +336,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -461,7 +482,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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Call the create session entity type method over HTTP. @@ -473,8 +494,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: ~.gcd_session_entity_type.SessionEntityType: @@ -494,6 +517,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseCreateSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_create_session_entity_type( request, metadata ) @@ -510,6 +534,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 = 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.dialogflow_v2.SessionEntityTypesClient.CreateSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "CreateSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._CreateSessionEntityType._get_response( @@ -533,7 +584,31 @@ def __call__( pb_resp = gcd_session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_session_entity_type.SessionEntityType.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.dialogflow_v2.SessionEntityTypesClient.create_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "CreateSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSessionEntityType( @@ -571,7 +646,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 session entity type method over HTTP. @@ -583,13 +658,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 = ( _BaseSessionEntityTypesRestTransport._BaseDeleteSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_delete_session_entity_type( request, metadata ) @@ -602,6 +680,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.dialogflow_v2.SessionEntityTypesClient.DeleteSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "DeleteSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._DeleteSessionEntityType._get_response( @@ -654,7 +759,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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Call the get session entity type method over HTTP. @@ -665,8 +770,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: ~.session_entity_type.SessionEntityType: @@ -686,6 +793,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_get_session_entity_type( request, metadata ) @@ -698,6 +806,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 = 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.dialogflow_v2.SessionEntityTypesClient.GetSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._GetSessionEntityType._get_response( @@ -720,7 +855,31 @@ def __call__( pb_resp = session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = session_entity_type.SessionEntityType.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.dialogflow_v2.SessionEntityTypesClient.get_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSessionEntityTypes( @@ -758,7 +917,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]]] = (), ) -> session_entity_type.ListSessionEntityTypesResponse: r"""Call the list session entity types method over HTTP. @@ -769,8 +928,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: ~.session_entity_type.ListSessionEntityTypesResponse: @@ -782,6 +943,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListSessionEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_session_entity_types( request, metadata ) @@ -794,6 +956,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 = 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.dialogflow_v2.SessionEntityTypesClient.ListSessionEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListSessionEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._ListSessionEntityTypes._get_response( @@ -816,7 +1005,33 @@ def __call__( pb_resp = session_entity_type.ListSessionEntityTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_session_entity_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + session_entity_type.ListSessionEntityTypesResponse.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.dialogflow_v2.SessionEntityTypesClient.list_session_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListSessionEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSessionEntityType( @@ -855,7 +1070,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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Call the update session entity type method over HTTP. @@ -867,8 +1082,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: ~.gcd_session_entity_type.SessionEntityType: @@ -888,6 +1105,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseUpdateSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_update_session_entity_type( request, metadata ) @@ -904,6 +1122,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 = 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.dialogflow_v2.SessionEntityTypesClient.UpdateSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "UpdateSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._UpdateSessionEntityType._get_response( @@ -927,7 +1172,31 @@ def __call__( pb_resp = gcd_session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_session_entity_type.SessionEntityType.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.dialogflow_v2.SessionEntityTypesClient.update_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "UpdateSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1023,7 +1292,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. @@ -1033,8 +1302,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. @@ -1043,6 +1314,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1053,6 +1325,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.dialogflow_v2.SessionEntityTypesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._GetLocation._get_response( self._host, @@ -1072,6 +1371,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.dialogflow_v2.SessionEntityTypesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1113,7 +1433,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. @@ -1123,8 +1443,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. @@ -1133,6 +1455,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1143,6 +1466,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.dialogflow_v2.SessionEntityTypesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._ListLocations._get_response( self._host, @@ -1162,6 +1512,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.dialogflow_v2.SessionEntityTypesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1203,7 +1574,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1213,13 +1584,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 = ( _BaseSessionEntityTypesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1232,6 +1606,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.dialogflow_v2.SessionEntityTypesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._CancelOperation._get_response( self._host, @@ -1288,7 +1689,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1298,8 +1699,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: operations_pb2.Operation: Response from GetOperation method. @@ -1308,6 +1711,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1318,6 +1722,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.dialogflow_v2.SessionEntityTypesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._GetOperation._get_response( self._host, @@ -1337,6 +1768,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.SessionEntityTypesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1378,7 +1830,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1388,8 +1840,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1398,6 +1852,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1408,6 +1863,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.dialogflow_v2.SessionEntityTypesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._ListOperations._get_response( self._host, @@ -1427,6 +1909,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.SessionEntityTypesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.SessionEntityTypes", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/async_client.py index c1843d5db7de..eef2faf6a485 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/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 ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SessionsTransport from .transports.grpc_asyncio import SessionsGrpcAsyncIOTransport +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 SessionsAsyncClient: """A service used for session interactions. @@ -268,6 +278,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.dialogflow_v2.SessionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "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.dialogflow.v2.Sessions", + "credentialsType": None, + }, + ) + async def detect_intent( self, request: Optional[Union[gcd_session.DetectIntentRequest, dict]] = None, @@ -276,7 +308,7 @@ async def detect_intent( query_input: Optional[gcd_session.QueryInput] = 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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, @@ -375,14 +407,14 @@ async def sample_detect_intent(): 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.dialogflow_v2.types.DetectIntentResponse: - The message returned from the - DetectIntent method. - + The message returned from the [DetectIntent][] method. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -438,7 +470,7 @@ def streaming_detect_intent( *, 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]]] = (), ) -> Awaitable[AsyncIterable[session.StreamingDetectIntentResponse]]: r"""Processes a natural language query in audio format in a streaming fashion and returns structured, actionable data as a @@ -503,8 +535,7 @@ def request_generator(): Args: requests (AsyncIterator[`google.cloud.dialogflow_v2.types.StreamingDetectIntentRequest`]): The request object AsyncIterator. The top-level message sent by the client to the - [Sessions.StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent] - method. + [StreamingDetectIntent][] method. Multiple request messages should be sent in order: @@ -545,22 +576,26 @@ def request_generator(): 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: AsyncIterable[google.cloud.dialogflow_v2.types.StreamingDetectIntentResponse]: The top-level message returned from the - StreamingDetectIntent method. + [StreamingDetectIntent][] method. Multiple response messages can be returned in order: - 1. If the StreamingDetectIntentRequest.input_audio - field was set, the recognition_result field is - populated for one or more messages. See the - [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] - message for details about the result message - sequence. + 1. If the + [StreamingDetectIntentRequest.input_audio][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.input_audio] + field was set, the recognition_result field is + populated for one or more messages. See the + [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] + message for details about the result message + sequence. + 2. The next message contains response_id, query_result and optionally webhook_status if a WebHook was called. @@ -593,7 +628,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -604,8 +639,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -646,7 +683,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -657,8 +694,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -699,7 +738,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -714,8 +753,10 @@ async def cancel_operation( 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: None """ @@ -752,7 +793,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. @@ -763,8 +804,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. @@ -805,7 +848,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. @@ -816,8 +859,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-dialogflow/google/cloud/dialogflow_v2/services/sessions/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/client.py index e6f2b13cc399..46d575903adb 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -667,6 +677,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( @@ -729,6 +743,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.dialogflow_v2.SessionsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "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.dialogflow.v2.Sessions", + "credentialsType": None, + }, + ) + def detect_intent( self, request: Optional[Union[gcd_session.DetectIntentRequest, dict]] = None, @@ -737,7 +774,7 @@ def detect_intent( query_input: Optional[gcd_session.QueryInput] = 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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, @@ -836,14 +873,14 @@ def sample_detect_intent(): 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.dialogflow_v2.types.DetectIntentResponse: - The message returned from the - DetectIntent method. - + The message returned from the [DetectIntent][] method. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -896,7 +933,7 @@ def streaming_detect_intent( *, 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]]] = (), ) -> Iterable[session.StreamingDetectIntentResponse]: r"""Processes a natural language query in audio format in a streaming fashion and returns structured, actionable data as a @@ -961,8 +998,7 @@ def request_generator(): Args: requests (Iterator[google.cloud.dialogflow_v2.types.StreamingDetectIntentRequest]): The request object iterator. The top-level message sent by the client to the - [Sessions.StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent] - method. + [StreamingDetectIntent][] method. Multiple request messages should be sent in order: @@ -1003,22 +1039,26 @@ def request_generator(): 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: Iterable[google.cloud.dialogflow_v2.types.StreamingDetectIntentResponse]: The top-level message returned from the - StreamingDetectIntent method. + [StreamingDetectIntent][] method. Multiple response messages can be returned in order: - 1. If the StreamingDetectIntentRequest.input_audio - field was set, the recognition_result field is - populated for one or more messages. See the - [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] - message for details about the result message - sequence. + 1. If the + [StreamingDetectIntentRequest.input_audio][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.input_audio] + field was set, the recognition_result field is + populated for one or more messages. See the + [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] + message for details about the result message + sequence. + 2. The next message contains response_id, query_result and optionally webhook_status if a WebHook was called. @@ -1062,7 +1102,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1073,8 +1113,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1115,7 +1157,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1126,8 +1168,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1168,7 +1212,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1183,8 +1227,10 @@ def cancel_operation( 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: None """ @@ -1221,7 +1267,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. @@ -1232,8 +1278,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. @@ -1274,7 +1322,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. @@ -1285,8 +1333,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-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py index c4e9c0aecb7c..3cf064f2bac6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import session from google.cloud.dialogflow_v2.types import session as gcd_session from .base import DEFAULT_CLIENT_INFO, SessionsTransport +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.dialogflow.v2.Sessions", + "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.dialogflow.v2.Sessions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionsGrpcTransport(SessionsTransport): """gRPC backend transport for Sessions. @@ -185,7 +266,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 @@ -273,7 +359,7 @@ def detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_intent" not in self._stubs: - self._stubs["detect_intent"] = self.grpc_channel.unary_unary( + self._stubs["detect_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Sessions/DetectIntent", request_serializer=gcd_session.DetectIntentRequest.serialize, response_deserializer=gcd_session.DetectIntentResponse.deserialize, @@ -316,7 +402,7 @@ def streaming_detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_detect_intent" not in self._stubs: - self._stubs["streaming_detect_intent"] = self.grpc_channel.stream_stream( + self._stubs["streaming_detect_intent"] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2.Sessions/StreamingDetectIntent", request_serializer=session.StreamingDetectIntentRequest.serialize, response_deserializer=session.StreamingDetectIntentResponse.deserialize, @@ -324,7 +410,7 @@ def streaming_detect_intent( return self._stubs["streaming_detect_intent"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -336,7 +422,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -353,7 +439,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +458,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -391,7 +477,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, @@ -408,7 +494,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-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py index 92da260704ac..9a2b3ecfc5c4 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import session from google.cloud.dialogflow_v2.types import session as gcd_session @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, SessionsTransport from .grpc import SessionsGrpcTransport +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.dialogflow.v2.Sessions", + "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.dialogflow.v2.Sessions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionsGrpcAsyncIOTransport(SessionsTransport): """gRPC AsyncIO backend transport for Sessions. @@ -232,10 +314,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 @@ -283,7 +368,7 @@ def detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_intent" not in self._stubs: - self._stubs["detect_intent"] = self.grpc_channel.unary_unary( + self._stubs["detect_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Sessions/DetectIntent", request_serializer=gcd_session.DetectIntentRequest.serialize, response_deserializer=gcd_session.DetectIntentResponse.deserialize, @@ -327,7 +412,7 @@ def streaming_detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_detect_intent" not in self._stubs: - self._stubs["streaming_detect_intent"] = self.grpc_channel.stream_stream( + self._stubs["streaming_detect_intent"] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2.Sessions/StreamingDetectIntent", request_serializer=session.StreamingDetectIntentRequest.serialize, response_deserializer=session.StreamingDetectIntentResponse.deserialize, @@ -389,7 +474,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: @@ -405,7 +490,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -422,7 +507,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +526,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -460,7 +545,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, @@ -477,7 +562,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-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/rest.py index dc2dff49113a..8ff4d4772a99 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/sessions/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 @@ -40,6 +40,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, @@ -80,8 +88,10 @@ def post_detect_intent(self, response): def pre_detect_intent( self, request: gcd_session.DetectIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_session.DetectIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_session.DetectIntentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for detect_intent Override in a subclass to manipulate the request or metadata @@ -103,8 +113,10 @@ def post_detect_intent( 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 @@ -126,8 +138,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 @@ -149,8 +163,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -170,8 +186,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -193,8 +211,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -336,7 +356,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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Call the detect intent method over HTTP. @@ -346,19 +366,20 @@ 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: ~.gcd_session.DetectIntentResponse: - The message returned from the - DetectIntent method. - + The message returned from the [DetectIntent][] method. """ http_options = ( _BaseSessionsRestTransport._BaseDetectIntent._get_http_options() ) + request, metadata = self._interceptor.pre_detect_intent(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseDetectIntent._get_transcoded_request( @@ -377,6 +398,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.dialogflow_v2.SessionsClient.DetectIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "DetectIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._DetectIntent._get_response( self._host, @@ -398,7 +446,31 @@ def __call__( pb_resp = gcd_session.DetectIntentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_session.DetectIntentResponse.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.dialogflow_v2.SessionsClient.detect_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "DetectIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingDetectIntent( @@ -413,7 +485,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingDetectIntent is not available over REST transport" @@ -473,7 +545,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. @@ -483,8 +555,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. @@ -493,6 +567,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseGetLocation._get_transcoded_request( @@ -507,6 +582,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.dialogflow_v2.SessionsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._GetLocation._get_response( self._host, @@ -526,6 +628,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.dialogflow_v2.SessionsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -566,7 +689,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. @@ -576,8 +699,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. @@ -586,6 +711,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseListLocations._get_transcoded_request( @@ -600,6 +726,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.dialogflow_v2.SessionsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._ListLocations._get_response( self._host, @@ -619,6 +772,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.dialogflow_v2.SessionsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -659,7 +833,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -669,13 +843,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 = ( _BaseSessionsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -692,6 +869,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.dialogflow_v2.SessionsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._CancelOperation._get_response( self._host, @@ -745,7 +949,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -755,8 +959,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: operations_pb2.Operation: Response from GetOperation method. @@ -765,6 +971,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -779,6 +986,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.dialogflow_v2.SessionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._GetOperation._get_response( self._host, @@ -798,6 +1032,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.SessionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -838,7 +1093,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -848,8 +1103,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -858,6 +1115,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseListOperations._get_transcoded_request( @@ -872,6 +1130,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.dialogflow_v2.SessionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._ListOperations._get_response( self._host, @@ -891,6 +1176,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.SessionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Sessions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/async_client.py index c72f7a1147b5..af70d651fe35 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VersionsTransport from .transports.grpc_asyncio import VersionsGrpcAsyncIOTransport +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 VersionsAsyncClient: """Service for managing [Versions][google.cloud.dialogflow.v2.Version].""" @@ -252,6 +262,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.dialogflow_v2.VersionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "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.dialogflow.v2.Versions", + "credentialsType": None, + }, + ) + async def list_versions( self, request: Optional[Union[version.ListVersionsRequest, dict]] = None, @@ -259,7 +291,7 @@ async def list_versions( 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.ListVersionsAsyncPager: r"""Returns the list of all versions of the specified agent. @@ -308,8 +340,10 @@ async def sample_list_versions(): 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.dialogflow_v2.services.versions.pagers.ListVersionsAsyncPager: @@ -384,7 +418,7 @@ async def get_version( 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]]] = (), ) -> version.Version: r"""Retrieves the specified agent version. @@ -430,8 +464,10 @@ async def sample_get_version(): 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.dialogflow_v2.types.Version: @@ -512,7 +548,7 @@ async def create_version( version: Optional[gcd_version.Version] = 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]]] = (), ) -> gcd_version.Version: r"""Creates an agent version. @@ -567,8 +603,10 @@ async def sample_create_version(): 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.dialogflow_v2.types.Version: @@ -651,7 +689,7 @@ async def update_version( 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]]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. @@ -708,8 +746,10 @@ async def sample_update_version(): 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.dialogflow_v2.types.Version: @@ -793,7 +833,7 @@ async def delete_version( 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"""Delete the specified agent version. @@ -837,8 +877,10 @@ async def sample_delete_version(): 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 @@ -889,7 +931,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -900,8 +942,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -942,7 +986,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -953,8 +997,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -995,7 +1041,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1010,8 +1056,10 @@ async def cancel_operation( 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: None """ @@ -1048,7 +1096,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. @@ -1059,8 +1107,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. @@ -1101,7 +1151,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. @@ -1112,8 +1162,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-dialogflow/google/cloud/dialogflow_v2/services/versions/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/client.py index b61fa2c04bc0..abf88d652e3f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -579,6 +589,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( @@ -641,6 +655,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.dialogflow_v2.VersionsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "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.dialogflow.v2.Versions", + "credentialsType": None, + }, + ) + def list_versions( self, request: Optional[Union[version.ListVersionsRequest, dict]] = None, @@ -648,7 +685,7 @@ def list_versions( 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.ListVersionsPager: r"""Returns the list of all versions of the specified agent. @@ -697,8 +734,10 @@ def sample_list_versions(): 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.dialogflow_v2.services.versions.pagers.ListVersionsPager: @@ -770,7 +809,7 @@ def get_version( 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]]] = (), ) -> version.Version: r"""Retrieves the specified agent version. @@ -816,8 +855,10 @@ def sample_get_version(): 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.dialogflow_v2.types.Version: @@ -895,7 +936,7 @@ def create_version( version: Optional[gcd_version.Version] = 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]]] = (), ) -> gcd_version.Version: r"""Creates an agent version. @@ -950,8 +991,10 @@ def sample_create_version(): 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.dialogflow_v2.types.Version: @@ -1031,7 +1074,7 @@ def update_version( 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]]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. @@ -1088,8 +1131,10 @@ def sample_update_version(): 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.dialogflow_v2.types.Version: @@ -1170,7 +1215,7 @@ def delete_version( 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"""Delete the specified agent version. @@ -1214,8 +1259,10 @@ def sample_delete_version(): 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 @@ -1276,7 +1323,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1287,8 +1334,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1329,7 +1378,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1340,8 +1389,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1382,7 +1433,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1397,8 +1448,10 @@ def cancel_operation( 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: None """ @@ -1435,7 +1488,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. @@ -1446,8 +1499,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. @@ -1488,7 +1543,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. @@ -1499,8 +1554,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-dialogflow/google/cloud/dialogflow_v2/services/versions/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/pagers.py index e44e78020945..ba11cd7d6dad 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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 = version.ListVersionsRequest(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 = version.ListVersionsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc.py index 317b6e2f064e..bf49421934eb 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import version from google.cloud.dialogflow_v2.types import version as gcd_version from .base import DEFAULT_CLIENT_INFO, VersionsTransport +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.dialogflow.v2.Versions", + "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.dialogflow.v2.Versions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcTransport(VersionsTransport): """gRPC backend transport for Versions. @@ -183,7 +264,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 @@ -258,7 +344,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -282,7 +368,7 @@ def get_version(self) -> Callable[[version.GetVersionRequest], version.Version]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -311,7 +397,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/CreateVersion", request_serializer=gcd_version.CreateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -342,7 +428,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/UpdateVersion", request_serializer=gcd_version.UpdateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -368,7 +454,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -376,7 +462,7 @@ def delete_version( return self._stubs["delete_version"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -388,7 +474,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -405,7 +491,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -424,7 +510,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -443,7 +529,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, @@ -460,7 +546,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-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py index 6391453fa21e..ca30d836aabc 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2.types import version from google.cloud.dialogflow_v2.types import version as gcd_version @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, VersionsTransport from .grpc import VersionsGrpcTransport +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.dialogflow.v2.Versions", + "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.dialogflow.v2.Versions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcAsyncIOTransport(VersionsTransport): """gRPC AsyncIO backend transport for Versions. @@ -230,10 +312,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 @@ -268,7 +353,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -294,7 +379,7 @@ def get_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -323,7 +408,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/CreateVersion", request_serializer=gcd_version.CreateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -354,7 +439,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/UpdateVersion", request_serializer=gcd_version.UpdateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -380,7 +465,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2.Versions/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -448,7 +533,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: @@ -464,7 +549,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -481,7 +566,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -500,7 +585,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -519,7 +604,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, @@ -536,7 +621,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-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/rest.py index 23fb3c782e90..2d6e0d717708 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/services/versions/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 @@ -41,6 +41,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, @@ -109,8 +117,10 @@ def post_update_version(self, response): def pre_create_version( self, request: gcd_version.CreateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_version.CreateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_version.CreateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_version Override in a subclass to manipulate the request or metadata @@ -128,8 +138,10 @@ def post_create_version(self, response: gcd_version.Version) -> gcd_version.Vers return response def pre_delete_version( - self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.DeleteVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -138,8 +150,10 @@ def pre_delete_version( return request, metadata def pre_get_version( - self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.GetVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -157,8 +171,10 @@ def post_get_version(self, response: version.Version) -> version.Version: return response def pre_list_versions( - self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: + self, + request: version.ListVersionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -180,8 +196,10 @@ def post_list_versions( def pre_update_version( self, request: gcd_version.UpdateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_version.UpdateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_version Override in a subclass to manipulate the request or metadata @@ -201,8 +219,10 @@ def post_update_version(self, response: gcd_version.Version) -> gcd_version.Vers 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 @@ -224,8 +244,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 @@ -247,8 +269,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -268,8 +292,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -291,8 +317,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -433,7 +461,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]]] = (), ) -> gcd_version.Version: r"""Call the create version method over HTTP. @@ -444,8 +472,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: ~.gcd_version.Version: @@ -474,6 +504,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseCreateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_create_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseCreateVersion._get_transcoded_request( @@ -492,6 +523,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.dialogflow_v2.VersionsClient.CreateVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "CreateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._CreateVersion._get_response( self._host, @@ -513,7 +571,29 @@ def __call__( pb_resp = gcd_version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_version.Version.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.dialogflow_v2.VersionsClient.create_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "CreateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteVersion( @@ -550,7 +630,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 version method over HTTP. @@ -561,13 +641,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 = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_transcoded_request( @@ -582,6 +665,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.dialogflow_v2.VersionsClient.DeleteVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._DeleteVersion._get_response( self._host, @@ -629,7 +739,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]]] = (), ) -> version.Version: r"""Call the get version method over HTTP. @@ -640,8 +750,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: ~.version.Version: @@ -670,6 +782,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetVersion._get_transcoded_request( @@ -684,6 +797,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.dialogflow_v2.VersionsClient.GetVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetVersion._get_response( self._host, @@ -704,7 +844,29 @@ def __call__( pb_resp = version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.Version.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.dialogflow_v2.VersionsClient.get_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions(_BaseVersionsRestTransport._BaseListVersions, VersionsRestStub): @@ -739,7 +901,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]]] = (), ) -> version.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -750,8 +912,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: ~.version.ListVersionsResponse: @@ -763,6 +927,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListVersions._get_transcoded_request( @@ -777,6 +942,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.dialogflow_v2.VersionsClient.ListVersions", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListVersions._get_response( self._host, @@ -797,7 +989,29 @@ def __call__( pb_resp = version.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.ListVersionsResponse.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.dialogflow_v2.VersionsClient.list_versions", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVersion( @@ -835,7 +1049,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]]] = (), ) -> gcd_version.Version: r"""Call the update version method over HTTP. @@ -846,8 +1060,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: ~.gcd_version.Version: @@ -876,6 +1092,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_transcoded_request( @@ -894,6 +1111,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.dialogflow_v2.VersionsClient.UpdateVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "UpdateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._UpdateVersion._get_response( self._host, @@ -915,7 +1159,29 @@ def __call__( pb_resp = gcd_version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_version.Version.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.dialogflow_v2.VersionsClient.update_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "UpdateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -992,7 +1258,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. @@ -1002,8 +1268,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. @@ -1012,6 +1280,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1026,6 +1295,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.dialogflow_v2.VersionsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetLocation._get_response( self._host, @@ -1045,6 +1341,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.dialogflow_v2.VersionsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1085,7 +1402,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. @@ -1095,8 +1412,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. @@ -1105,6 +1424,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListLocations._get_transcoded_request( @@ -1119,6 +1439,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.dialogflow_v2.VersionsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListLocations._get_response( self._host, @@ -1138,6 +1485,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.dialogflow_v2.VersionsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1178,7 +1546,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1188,13 +1556,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 = ( _BaseVersionsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1211,6 +1582,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.dialogflow_v2.VersionsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._CancelOperation._get_response( self._host, @@ -1264,7 +1662,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1274,8 +1672,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: operations_pb2.Operation: Response from GetOperation method. @@ -1284,6 +1684,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1298,6 +1699,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.dialogflow_v2.VersionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetOperation._get_response( self._host, @@ -1317,6 +1745,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2.VersionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1357,7 +1806,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1367,8 +1816,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1377,6 +1828,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListOperations._get_transcoded_request( @@ -1391,6 +1843,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.dialogflow_v2.VersionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListOperations._get_response( self._host, @@ -1410,6 +1889,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2.VersionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2.Versions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/answer_record.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/answer_record.py index f15efd7d8759..71976c60847b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/answer_record.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/answer_record.py @@ -64,8 +64,10 @@ class AnswerRecord(proto.Message): are returned to the customers. 2. The customer uses the [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name] - to call the [UpdateAnswerRecord][] method to send feedback about - a specific answer that they believe is wrong. + to call the + [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord] + method to send feedback about a specific answer that they believe + is wrong. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/audio_config.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/audio_config.py index 827581f16dc4..4cd6183b54b3 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/audio_config.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/audio_config.py @@ -181,9 +181,8 @@ class SpeechModelVariant(proto.Enum): No model variant specified. In this case Dialogflow defaults to USE_BEST_AVAILABLE. USE_BEST_AVAILABLE (1): - Use the best available variant of the [Speech - model][InputAudioConfig.model] that the caller is eligible - for. + Use the best available variant of the [Speech model][model] + that the caller is eligible for. Please see the `Dialogflow docs `__ diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation.py index fd30762f8979..dde3396f534d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation.py @@ -473,10 +473,11 @@ class SuggestConversationSummaryResponse(proto.Message): ``projects//locations//conversations//messages/``. context_size (int): Number of messages prior to and including - [last_conversation_message][] used to compile the - suggestion. It may be smaller than the - [SuggestSummaryRequest.context_size][] field in the request - if there weren't that many messages in the conversation. + [latest_message][google.cloud.dialogflow.v2.SuggestConversationSummaryResponse.latest_message] + used to compile the suggestion. It may be smaller than the + [SuggestConversationSummaryRequest.context_size][google.cloud.dialogflow.v2.SuggestConversationSummaryRequest.context_size] + field in the request if there weren't that many messages in + the conversation. """ class Summary(proto.Message): @@ -623,11 +624,11 @@ class GenerateStatelessSummaryResponse(proto.Message): the messages provided. context_size (int): Number of messages prior to and including - [last_conversation_message][] used to compile the - suggestion. It may be smaller than the - [GenerateStatelessSummaryRequest.context_size][] field in - the request if there weren't that many messages in the - conversation. + [latest_message][google.cloud.dialogflow.v2.GenerateStatelessSummaryResponse.latest_message] + used to compile the suggestion. It may be smaller than the + [GenerateStatelessSummaryRequest.max_context_size][google.cloud.dialogflow.v2.GenerateStatelessSummaryRequest.max_context_size] + field in the request if there weren't that many messages in + the conversation. """ class Summary(proto.Message): diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_dataset.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_dataset.py index 19ba30433068..6c74a9a19538 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_dataset.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_dataset.py @@ -372,7 +372,7 @@ class ImportConversationDataOperationResponse(proto.Message): class CreateConversationDatasetOperationMetadata(proto.Message): - r"""Metadata for [ConversationDatasets][CreateConversationDataset]. + r"""Metadata for [CreateConversationDataset][]. Attributes: conversation_dataset (str): @@ -388,7 +388,7 @@ class CreateConversationDatasetOperationMetadata(proto.Message): class DeleteConversationDatasetOperationMetadata(proto.Message): - r"""Metadata for [ConversationDatasets][DeleteConversationDataset].""" + r"""Metadata for [DeleteConversationDataset][].""" __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_profile.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_profile.py index 8796c987a34b..da87185af50d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_profile.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/conversation_profile.py @@ -1156,7 +1156,7 @@ class Type(proto.Enum): class SetSuggestionFeatureConfigRequest(proto.Message): r"""The request message for - [ConversationProfiles.SetSuggestionFeature][]. + [ConversationProfiles.SetSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.SetSuggestionFeatureConfig]. Attributes: conversation_profile (str): @@ -1191,7 +1191,8 @@ class SetSuggestionFeatureConfigRequest(proto.Message): class ClearSuggestionFeatureConfigRequest(proto.Message): - r"""The request message for [ConversationProfiles.ClearFeature][]. + r"""The request message for + [ConversationProfiles.ClearSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.ClearSuggestionFeatureConfig]. Attributes: conversation_profile (str): @@ -1223,7 +1224,8 @@ class ClearSuggestionFeatureConfigRequest(proto.Message): class SetSuggestionFeatureConfigOperationMetadata(proto.Message): - r"""Metadata for a [ConversationProfile.SetSuggestionFeatureConfig][] + r"""Metadata for a + [ConversationProfiles.SetSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.SetSuggestionFeatureConfig] operation. Attributes: @@ -1264,7 +1266,8 @@ class SetSuggestionFeatureConfigOperationMetadata(proto.Message): class ClearSuggestionFeatureConfigOperationMetadata(proto.Message): - r"""Metadata for a [ConversationProfile.ClearSuggestionFeatureConfig][] + r"""Metadata for a + [ConversationProfiles.ClearSuggestionFeatureConfig][google.cloud.dialogflow.v2.ConversationProfiles.ClearSuggestionFeatureConfig] operation. Attributes: diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/participant.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/participant.py index b6e1b9dff4fe..b95b924e5a41 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/participant.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/participant.py @@ -99,9 +99,9 @@ class Participant(proto.Message): participant. 2. If you set this field in - [AnalyzeContent][google.cloud.dialogflow.v2.AnalyzeContentRequest.obfuscated_external_user_id] + [AnalyzeContent][google.cloud.dialogflow.v2.AnalyzeContentRequest.participant] or - [StreamingAnalyzeContent][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.obfuscated_external_user_id], + [StreamingAnalyzeContent][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.participant], Dialogflow will update [Participant.obfuscated_external_user_id][google.cloud.dialogflow.v2.Participant.obfuscated_external_user_id]. @@ -528,11 +528,10 @@ class AnalyzeContentResponse(proto.Message): top-most-level audio output has content. automated_agent_reply (google.cloud.dialogflow_v2.types.AutomatedAgentReply): Only set if a Dialogflow automated agent has responded. Note - that: - [AutomatedAgentReply.detect_intent_response.output_audio][] - and - [AutomatedAgentReply.detect_intent_response.output_audio_config][] - are always empty, use + that in [AutomatedAgentReply.DetectIntentResponse][], + [Sessions.DetectIntentResponse.output_audio][] and + [Sessions.DetectIntentResponse.output_audio_config][] are + always empty, use [reply_audio][google.cloud.dialogflow.v2.AnalyzeContentResponse.reply_audio] instead. message (google.cloud.dialogflow_v2.types.Message): @@ -719,8 +718,9 @@ class StreamingAnalyzeContentRequest(proto.Message): and [AudioEncoding.AUDIO_ENCODING_MULAW][google.cloud.dialogflow.v2.AudioEncoding.AUDIO_ENCODING_MULAW] - Lifecycle: conversation should be in ``Assist Stage``, go - to [Conversation.CreateConversation][] for more - information. + to + [Conversations.CreateConversation][google.cloud.dialogflow.v2.Conversations.CreateConversation] + for more information. InvalidArgument Error will be returned if the one of restriction checks failed. @@ -853,12 +853,10 @@ class StreamingAnalyzeContentResponse(proto.Message): present in the response structure. In these cases, only the top-most-level audio output has content. automated_agent_reply (google.cloud.dialogflow_v2.types.AutomatedAgentReply): - Only set if a Dialogflow automated agent has responded. Note - that: - [AutomatedAgentReply.detect_intent_response.output_audio][] - and - [AutomatedAgentReply.detect_intent_response.output_audio_config][] - are always empty, use + Note that in [AutomatedAgentReply.DetectIntentResponse][], + [Sessions.DetectIntentResponse.output_audio][] and + [Sessions.DetectIntentResponse.output_audio_config][] are + always empty, use [reply_audio][google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.reply_audio] instead. message (google.cloud.dialogflow_v2.types.Message): diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/session.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/session.py index 582c5b6d4443..4d51a3a877b5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/session.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2/types/session.py @@ -142,7 +142,7 @@ class DetectIntentRequest(proto.Message): class DetectIntentResponse(proto.Message): - r"""The message returned from the DetectIntent method. + r"""The message returned from the [DetectIntent][] method. Attributes: response_id (str): @@ -377,17 +377,15 @@ class QueryResult(proto.Message): Support `__ for a list of the currently supported language codes. speech_recognition_confidence (float): - The Speech recognition confidence between 0.0 - and 1.0. A higher number indicates an estimated - greater likelihood that the recognized words are - correct. The default of 0.0 is a sentinel value - indicating that confidence was not set. - - This field is not guaranteed to be accurate or - set. In particular this field isn't set for - StreamingDetectIntent since the streaming - endpoint has separate confidence estimates per - portion of the audio in + The Speech recognition confidence between 0.0 and 1.0. A + higher number indicates an estimated greater likelihood that + the recognized words are correct. The default of 0.0 is a + sentinel value indicating that confidence was not set. + + This field is not guaranteed to be accurate or set. In + particular this field isn't set for + [StreamingDetectIntent][] since the streaming endpoint has + separate confidence estimates per portion of the audio in StreamingRecognitionResult. action (str): The action name from the matched intent. @@ -551,8 +549,7 @@ class QueryResult(proto.Message): class StreamingDetectIntentRequest(proto.Message): r"""The top-level message sent by the client to the - [Sessions.StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent] - method. + [StreamingDetectIntent][] method. Multiple request messages should be sent in order: @@ -851,14 +848,15 @@ class CloudConversationDebuggingInfo(proto.Message): class StreamingDetectIntentResponse(proto.Message): - r"""The top-level message returned from the ``StreamingDetectIntent`` + r"""The top-level message returned from the [StreamingDetectIntent][] method. Multiple response messages can be returned in order: - 1. If the ``StreamingDetectIntentRequest.input_audio`` field was - set, the ``recognition_result`` field is populated for one or - more messages. See the + 1. If the + [StreamingDetectIntentRequest.input_audio][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.input_audio] + field was set, the ``recognition_result`` field is populated for + one or more messages. See the [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] message for details about the result message sequence. @@ -894,8 +892,8 @@ class StreamingDetectIntentResponse(proto.Message): generate the output audio. debugging_info (google.cloud.dialogflow_v2.types.CloudConversationDebuggingInfo): Debugging info that would get populated when - ``StreamingDetectIntentRequest.enable_debugging_info`` is - set to true. + [StreamingDetectIntentRequest.enable_debugging_info][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.enable_debugging_info] + is set to true. """ response_id: str = proto.Field( @@ -1177,10 +1175,9 @@ class SentimentAnalysisResult(proto.Message): r"""The result of sentiment analysis. Sentiment analysis inspects user input and identifies the prevailing subjective opinion, especially to determine a user's attitude as positive, negative, or neutral. - For [Participants.DetectIntent][], it needs to be configured in + For [DetectIntent][], it needs to be configured in [DetectIntentRequest.query_params][google.cloud.dialogflow.v2.DetectIntentRequest.query_params]. - For [Participants.StreamingDetectIntent][], it needs to be - configured in + For [StreamingDetectIntent][], it needs to be configured in [StreamingDetectIntentRequest.query_params][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.query_params]. And for [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent] diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py index 102e325cdfdf..558c8aab67c5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.36.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/async_client.py index 4cee9d63b255..cf9fcb3878c5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AgentsTransport from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport +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 AgentsAsyncClient: """Service for managing @@ -255,6 +265,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.dialogflow_v2beta1.AgentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "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.dialogflow.v2beta1.Agents", + "credentialsType": None, + }, + ) + async def get_agent( self, request: Optional[Union[agent.GetAgentRequest, dict]] = None, @@ -262,7 +294,7 @@ async def get_agent( 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]]] = (), ) -> agent.Agent: r"""Retrieves the specified agent. @@ -307,8 +339,10 @@ async def sample_get_agent(): 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.dialogflow_v2beta1.types.Agent: @@ -378,7 +412,7 @@ async def set_agent( agent: Optional[gcd_agent.Agent] = 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]]] = (), ) -> gcd_agent.Agent: r"""Creates/updates the specified agent. @@ -427,8 +461,10 @@ async def sample_set_agent(): 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.dialogflow_v2beta1.types.Agent: @@ -500,7 +536,7 @@ async def delete_agent( 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]]] = (), ) -> None: r"""Deletes the specified agent. @@ -542,8 +578,10 @@ async def sample_delete_agent(): 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 @@ -595,7 +633,7 @@ async def search_agents( 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.SearchAgentsAsyncPager: r"""Returns the list of agents. Since there is at most one conversational agent per project, this method is useful @@ -646,8 +684,10 @@ async def sample_search_agents(): 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.dialogflow_v2beta1.services.agents.pagers.SearchAgentsAsyncPager: @@ -722,7 +762,7 @@ async def train_agent( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Trains the specified agent. @@ -785,8 +825,10 @@ async def sample_train_agent(): 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.api_core.operation_async.AsyncOperation: @@ -865,7 +907,7 @@ async def export_agent( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports the specified agent to a ZIP file. @@ -924,8 +966,10 @@ async def sample_export_agent(): 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.api_core.operation_async.AsyncOperation: @@ -995,7 +1039,7 @@ async def import_agent( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Imports the specified agent from a ZIP file. @@ -1066,8 +1110,10 @@ async def sample_import_agent(): 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.api_core.operation_async.AsyncOperation: @@ -1131,7 +1177,7 @@ async def restore_agent( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Restores the specified agent from a ZIP file. @@ -1200,8 +1246,10 @@ async def sample_restore_agent(): 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.api_core.operation_async.AsyncOperation: @@ -1265,7 +1313,7 @@ async def get_validation_result( *, 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]]] = (), ) -> validation_result.ValidationResult: r"""Gets agent validation result. Agent validation is performed during training time and is updated @@ -1304,8 +1352,10 @@ async def sample_get_validation_result(): 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.dialogflow_v2beta1.types.ValidationResult: @@ -1351,7 +1401,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1362,8 +1412,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1404,7 +1456,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1415,8 +1467,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1457,7 +1511,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1472,8 +1526,10 @@ async def cancel_operation( 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: None """ @@ -1510,7 +1566,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. @@ -1521,8 +1577,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. @@ -1563,7 +1621,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. @@ -1574,8 +1632,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-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/client.py index a0a1e5302b72..29501e1892cd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -580,6 +590,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( @@ -642,6 +656,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.dialogflow_v2beta1.AgentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "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.dialogflow.v2beta1.Agents", + "credentialsType": None, + }, + ) + def get_agent( self, request: Optional[Union[agent.GetAgentRequest, dict]] = None, @@ -649,7 +686,7 @@ def get_agent( 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]]] = (), ) -> agent.Agent: r"""Retrieves the specified agent. @@ -694,8 +731,10 @@ def sample_get_agent(): 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.dialogflow_v2beta1.types.Agent: @@ -762,7 +801,7 @@ def set_agent( agent: Optional[gcd_agent.Agent] = 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]]] = (), ) -> gcd_agent.Agent: r"""Creates/updates the specified agent. @@ -811,8 +850,10 @@ def sample_set_agent(): 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.dialogflow_v2beta1.types.Agent: @@ -881,7 +922,7 @@ def delete_agent( 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]]] = (), ) -> None: r"""Deletes the specified agent. @@ -923,8 +964,10 @@ def sample_delete_agent(): 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 @@ -973,7 +1016,7 @@ def search_agents( 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.SearchAgentsPager: r"""Returns the list of agents. Since there is at most one conversational agent per project, this method is useful @@ -1024,8 +1067,10 @@ def sample_search_agents(): 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.dialogflow_v2beta1.services.agents.pagers.SearchAgentsPager: @@ -1097,7 +1142,7 @@ def train_agent( 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]]] = (), ) -> operation.Operation: r"""Trains the specified agent. @@ -1160,8 +1205,10 @@ def sample_train_agent(): 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.api_core.operation.Operation: @@ -1237,7 +1284,7 @@ def export_agent( 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]]] = (), ) -> operation.Operation: r"""Exports the specified agent to a ZIP file. @@ -1296,8 +1343,10 @@ def sample_export_agent(): 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.api_core.operation.Operation: @@ -1364,7 +1413,7 @@ def import_agent( *, 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]]] = (), ) -> operation.Operation: r"""Imports the specified agent from a ZIP file. @@ -1435,8 +1484,10 @@ def sample_import_agent(): 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.api_core.operation.Operation: @@ -1498,7 +1549,7 @@ def restore_agent( *, 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]]] = (), ) -> operation.Operation: r"""Restores the specified agent from a ZIP file. @@ -1567,8 +1618,10 @@ def sample_restore_agent(): 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.api_core.operation.Operation: @@ -1630,7 +1683,7 @@ def get_validation_result( *, 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]]] = (), ) -> validation_result.ValidationResult: r"""Gets agent validation result. Agent validation is performed during training time and is updated @@ -1669,8 +1722,10 @@ def sample_get_validation_result(): 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.dialogflow_v2beta1.types.ValidationResult: @@ -1727,7 +1782,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1738,8 +1793,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1780,7 +1837,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1791,8 +1848,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1833,7 +1892,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1848,8 +1907,10 @@ def cancel_operation( 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: None """ @@ -1886,7 +1947,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. @@ -1897,8 +1958,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. @@ -1939,7 +2002,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. @@ -1950,8 +2013,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-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/pagers.py index 0e852f3e711e..e2f35f9e1817 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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 = agent.SearchAgentsRequest(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 = agent.SearchAgentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py index a8494cac720c..3a719a1228b9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import agent from google.cloud.dialogflow_v2beta1.types import agent as gcd_agent @@ -31,6 +37,81 @@ from .base import DEFAULT_CLIENT_INFO, AgentsTransport +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.dialogflow.v2beta1.Agents", + "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.dialogflow.v2beta1.Agents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AgentsGrpcTransport(AgentsTransport): """gRPC backend transport for Agents. @@ -186,7 +267,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 @@ -250,7 +336,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def get_agent(self) -> Callable[[agent.GetAgentRequest], agent.Agent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent" not in self._stubs: - self._stubs["get_agent"] = self.grpc_channel.unary_unary( + self._stubs["get_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/GetAgent", request_serializer=agent.GetAgentRequest.serialize, response_deserializer=agent.Agent.deserialize, @@ -300,7 +388,7 @@ def set_agent(self) -> Callable[[gcd_agent.SetAgentRequest], gcd_agent.Agent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_agent" not in self._stubs: - self._stubs["set_agent"] = self.grpc_channel.unary_unary( + self._stubs["set_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/SetAgent", request_serializer=gcd_agent.SetAgentRequest.serialize, response_deserializer=gcd_agent.Agent.deserialize, @@ -324,7 +412,7 @@ def delete_agent(self) -> Callable[[agent.DeleteAgentRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent" not in self._stubs: - self._stubs["delete_agent"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/DeleteAgent", request_serializer=agent.DeleteAgentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -355,7 +443,7 @@ def search_agents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_agents" not in self._stubs: - self._stubs["search_agents"] = self.grpc_channel.unary_unary( + self._stubs["search_agents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/SearchAgents", request_serializer=agent.SearchAgentsRequest.serialize, response_deserializer=agent.SearchAgentsResponse.deserialize, @@ -395,7 +483,7 @@ def train_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "train_agent" not in self._stubs: - self._stubs["train_agent"] = self.grpc_channel.unary_unary( + self._stubs["train_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/TrainAgent", request_serializer=agent.TrainAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def export_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_agent" not in self._stubs: - self._stubs["export_agent"] = self.grpc_channel.unary_unary( + self._stubs["export_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/ExportAgent", request_serializer=agent.ExportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -486,7 +574,7 @@ def import_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_agent" not in self._stubs: - self._stubs["import_agent"] = self.grpc_channel.unary_unary( + self._stubs["import_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/ImportAgent", request_serializer=agent.ImportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -539,7 +627,7 @@ def restore_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_agent" not in self._stubs: - self._stubs["restore_agent"] = self.grpc_channel.unary_unary( + self._stubs["restore_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/RestoreAgent", request_serializer=agent.RestoreAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -569,7 +657,7 @@ def get_validation_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_validation_result" not in self._stubs: - self._stubs["get_validation_result"] = self.grpc_channel.unary_unary( + self._stubs["get_validation_result"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/GetValidationResult", request_serializer=agent.GetValidationResultRequest.serialize, response_deserializer=validation_result.ValidationResult.deserialize, @@ -577,7 +665,7 @@ def get_validation_result( return self._stubs["get_validation_result"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -589,7 +677,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -606,7 +694,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -625,7 +713,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -644,7 +732,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, @@ -661,7 +749,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-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py index b9e2ac92bc3e..2ee467d5d62f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import agent from google.cloud.dialogflow_v2beta1.types import agent as gcd_agent @@ -35,6 +41,82 @@ from .base import DEFAULT_CLIENT_INFO, AgentsTransport from .grpc import AgentsGrpcTransport +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.dialogflow.v2beta1.Agents", + "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.dialogflow.v2beta1.Agents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AgentsGrpcAsyncIOTransport(AgentsTransport): """gRPC AsyncIO backend transport for Agents. @@ -233,10 +315,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 @@ -259,7 +344,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def get_agent(self) -> Callable[[agent.GetAgentRequest], Awaitable[agent.Agent]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_agent" not in self._stubs: - self._stubs["get_agent"] = self.grpc_channel.unary_unary( + self._stubs["get_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/GetAgent", request_serializer=agent.GetAgentRequest.serialize, response_deserializer=agent.Agent.deserialize, @@ -312,7 +397,7 @@ def set_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_agent" not in self._stubs: - self._stubs["set_agent"] = self.grpc_channel.unary_unary( + self._stubs["set_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/SetAgent", request_serializer=gcd_agent.SetAgentRequest.serialize, response_deserializer=gcd_agent.Agent.deserialize, @@ -338,7 +423,7 @@ def delete_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_agent" not in self._stubs: - self._stubs["delete_agent"] = self.grpc_channel.unary_unary( + self._stubs["delete_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/DeleteAgent", request_serializer=agent.DeleteAgentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -369,7 +454,7 @@ def search_agents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_agents" not in self._stubs: - self._stubs["search_agents"] = self.grpc_channel.unary_unary( + self._stubs["search_agents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/SearchAgents", request_serializer=agent.SearchAgentsRequest.serialize, response_deserializer=agent.SearchAgentsResponse.deserialize, @@ -409,7 +494,7 @@ def train_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "train_agent" not in self._stubs: - self._stubs["train_agent"] = self.grpc_channel.unary_unary( + self._stubs["train_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/TrainAgent", request_serializer=agent.TrainAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -445,7 +530,7 @@ def export_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_agent" not in self._stubs: - self._stubs["export_agent"] = self.grpc_channel.unary_unary( + self._stubs["export_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/ExportAgent", request_serializer=agent.ExportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -500,7 +585,7 @@ def import_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_agent" not in self._stubs: - self._stubs["import_agent"] = self.grpc_channel.unary_unary( + self._stubs["import_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/ImportAgent", request_serializer=agent.ImportAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +638,7 @@ def restore_agent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_agent" not in self._stubs: - self._stubs["restore_agent"] = self.grpc_channel.unary_unary( + self._stubs["restore_agent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/RestoreAgent", request_serializer=agent.RestoreAgentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -584,7 +669,7 @@ def get_validation_result( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_validation_result" not in self._stubs: - self._stubs["get_validation_result"] = self.grpc_channel.unary_unary( + self._stubs["get_validation_result"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Agents/GetValidationResult", request_serializer=agent.GetValidationResultRequest.serialize, response_deserializer=validation_result.ValidationResult.deserialize, @@ -672,7 +757,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: @@ -688,7 +773,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -705,7 +790,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -724,7 +809,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -743,7 +828,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, @@ -760,7 +845,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-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py index 56d41d59a60d..86631cf4c344 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/agents/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 @@ -42,6 +42,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, @@ -140,8 +148,10 @@ def post_train_agent(self, response): """ def pre_delete_agent( - self, request: agent.DeleteAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.DeleteAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.DeleteAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.DeleteAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_agent Override in a subclass to manipulate the request or metadata @@ -150,8 +160,10 @@ def pre_delete_agent( return request, metadata def pre_export_agent( - self, request: agent.ExportAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.ExportAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.ExportAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.ExportAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_agent Override in a subclass to manipulate the request or metadata @@ -171,8 +183,10 @@ def post_export_agent( return response def pre_get_agent( - self, request: agent.GetAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.GetAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.GetAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.GetAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_agent Override in a subclass to manipulate the request or metadata @@ -192,8 +206,10 @@ def post_get_agent(self, response: agent.Agent) -> agent.Agent: def pre_get_validation_result( self, request: agent.GetValidationResultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[agent.GetValidationResultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + agent.GetValidationResultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_validation_result Override in a subclass to manipulate the request or metadata @@ -213,8 +229,10 @@ def post_get_validation_result( return response def pre_import_agent( - self, request: agent.ImportAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.ImportAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.ImportAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.ImportAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_agent Override in a subclass to manipulate the request or metadata @@ -234,8 +252,10 @@ def post_import_agent( return response def pre_restore_agent( - self, request: agent.RestoreAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.RestoreAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.RestoreAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.RestoreAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restore_agent Override in a subclass to manipulate the request or metadata @@ -255,8 +275,10 @@ def post_restore_agent( return response def pre_search_agents( - self, request: agent.SearchAgentsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.SearchAgentsRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.SearchAgentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.SearchAgentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_agents Override in a subclass to manipulate the request or metadata @@ -276,8 +298,10 @@ def post_search_agents( return response def pre_set_agent( - self, request: gcd_agent.SetAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gcd_agent.SetAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: gcd_agent.SetAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_agent.SetAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for set_agent Override in a subclass to manipulate the request or metadata @@ -295,8 +319,10 @@ def post_set_agent(self, response: gcd_agent.Agent) -> gcd_agent.Agent: return response def pre_train_agent( - self, request: agent.TrainAgentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[agent.TrainAgentRequest, Sequence[Tuple[str, str]]]: + self, + request: agent.TrainAgentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[agent.TrainAgentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for train_agent Override in a subclass to manipulate the request or metadata @@ -318,8 +344,10 @@ def post_train_agent( 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 @@ -341,8 +369,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 @@ -364,8 +394,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -385,8 +417,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -408,8 +442,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -607,7 +643,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 agent method over HTTP. @@ -618,11 +654,14 @@ 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 = _BaseAgentsRestTransport._BaseDeleteAgent._get_http_options() + request, metadata = self._interceptor.pre_delete_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseDeleteAgent._get_transcoded_request( @@ -637,6 +676,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.dialogflow_v2beta1.AgentsClient.DeleteAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "DeleteAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._DeleteAgent._get_response( self._host, @@ -685,7 +751,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export agent method over HTTP. @@ -696,8 +762,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: ~.operations_pb2.Operation: @@ -708,6 +776,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseExportAgent._get_http_options() + request, metadata = self._interceptor.pre_export_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseExportAgent._get_transcoded_request( @@ -726,6 +795,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.dialogflow_v2beta1.AgentsClient.ExportAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ExportAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ExportAgent._get_response( self._host, @@ -745,7 +841,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_agent(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.dialogflow_v2beta1.AgentsClient.export_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ExportAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAgent(_BaseAgentsRestTransport._BaseGetAgent, AgentsRestStub): @@ -780,7 +898,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]]] = (), ) -> agent.Agent: r"""Call the get agent method over HTTP. @@ -791,8 +909,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: ~.agent.Agent: @@ -812,6 +932,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseGetAgent._get_http_options() + request, metadata = self._interceptor.pre_get_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetAgent._get_transcoded_request( @@ -826,6 +947,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.dialogflow_v2beta1.AgentsClient.GetAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetAgent._get_response( self._host, @@ -846,7 +994,29 @@ def __call__( pb_resp = agent.Agent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_agent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = agent.Agent.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.dialogflow_v2beta1.AgentsClient.get_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetValidationResult( @@ -883,7 +1053,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]]] = (), ) -> validation_result.ValidationResult: r"""Call the get validation result method over HTTP. @@ -894,8 +1064,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: ~.validation_result.ValidationResult: @@ -907,6 +1079,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseGetValidationResult._get_http_options() ) + request, metadata = self._interceptor.pre_get_validation_result( request, metadata ) @@ -919,6 +1092,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 = 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.dialogflow_v2beta1.AgentsClient.GetValidationResult", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetValidationResult", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetValidationResult._get_response( self._host, @@ -939,7 +1139,31 @@ def __call__( pb_resp = validation_result.ValidationResult.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_validation_result(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = validation_result.ValidationResult.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.dialogflow_v2beta1.AgentsClient.get_validation_result", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetValidationResult", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAgent(_BaseAgentsRestTransport._BaseImportAgent, AgentsRestStub): @@ -975,7 +1199,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import agent method over HTTP. @@ -986,8 +1210,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: ~.operations_pb2.Operation: @@ -998,6 +1224,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseImportAgent._get_http_options() + request, metadata = self._interceptor.pre_import_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseImportAgent._get_transcoded_request( @@ -1016,6 +1243,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.dialogflow_v2beta1.AgentsClient.ImportAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ImportAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ImportAgent._get_response( self._host, @@ -1035,7 +1289,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_agent(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.dialogflow_v2beta1.AgentsClient.import_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ImportAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreAgent(_BaseAgentsRestTransport._BaseRestoreAgent, AgentsRestStub): @@ -1071,7 +1347,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]]] = (), ) -> operations_pb2.Operation: r"""Call the restore agent method over HTTP. @@ -1082,8 +1358,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: ~.operations_pb2.Operation: @@ -1096,6 +1374,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseRestoreAgent._get_http_options() ) + request, metadata = self._interceptor.pre_restore_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseRestoreAgent._get_transcoded_request( @@ -1114,6 +1393,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.dialogflow_v2beta1.AgentsClient.RestoreAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "RestoreAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._RestoreAgent._get_response( self._host, @@ -1133,7 +1439,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_agent(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.dialogflow_v2beta1.AgentsClient.restore_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "RestoreAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAgents(_BaseAgentsRestTransport._BaseSearchAgents, AgentsRestStub): @@ -1168,7 +1496,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]]] = (), ) -> agent.SearchAgentsResponse: r"""Call the search agents method over HTTP. @@ -1179,8 +1507,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: ~.agent.SearchAgentsResponse: @@ -1192,6 +1522,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseSearchAgents._get_http_options() ) + request, metadata = self._interceptor.pre_search_agents(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseSearchAgents._get_transcoded_request( @@ -1206,6 +1537,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.dialogflow_v2beta1.AgentsClient.SearchAgents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "SearchAgents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._SearchAgents._get_response( self._host, @@ -1226,7 +1584,29 @@ def __call__( pb_resp = agent.SearchAgentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_agents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = agent.SearchAgentsResponse.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.dialogflow_v2beta1.AgentsClient.search_agents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "SearchAgents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetAgent(_BaseAgentsRestTransport._BaseSetAgent, AgentsRestStub): @@ -1262,7 +1642,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]]] = (), ) -> gcd_agent.Agent: r"""Call the set agent method over HTTP. @@ -1273,8 +1653,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: ~.gcd_agent.Agent: @@ -1294,6 +1676,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseSetAgent._get_http_options() + request, metadata = self._interceptor.pre_set_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseSetAgent._get_transcoded_request( @@ -1312,6 +1695,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.dialogflow_v2beta1.AgentsClient.SetAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "SetAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._SetAgent._get_response( self._host, @@ -1333,7 +1743,29 @@ def __call__( pb_resp = gcd_agent.Agent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_agent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_agent.Agent.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.dialogflow_v2beta1.AgentsClient.set_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "SetAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TrainAgent(_BaseAgentsRestTransport._BaseTrainAgent, AgentsRestStub): @@ -1369,7 +1801,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]]] = (), ) -> operations_pb2.Operation: r"""Call the train agent method over HTTP. @@ -1380,8 +1812,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: ~.operations_pb2.Operation: @@ -1392,6 +1826,7 @@ def __call__( """ http_options = _BaseAgentsRestTransport._BaseTrainAgent._get_http_options() + request, metadata = self._interceptor.pre_train_agent(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseTrainAgent._get_transcoded_request( @@ -1410,6 +1845,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.dialogflow_v2beta1.AgentsClient.TrainAgent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "TrainAgent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._TrainAgent._get_response( self._host, @@ -1429,7 +1891,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_train_agent(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.dialogflow_v2beta1.AgentsClient.train_agent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "TrainAgent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1536,7 +2020,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. @@ -1546,14 +2030,17 @@ 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. """ http_options = _BaseAgentsRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1568,6 +2055,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.dialogflow_v2beta1.AgentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetLocation._get_response( self._host, @@ -1587,6 +2101,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.dialogflow_v2beta1.AgentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1625,7 +2160,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. @@ -1635,8 +2170,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. @@ -1645,6 +2182,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1659,6 +2197,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.dialogflow_v2beta1.AgentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ListLocations._get_response( self._host, @@ -1678,6 +2243,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.dialogflow_v2beta1.AgentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1718,7 +2304,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1728,13 +2314,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 = ( _BaseAgentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1751,6 +2340,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.dialogflow_v2beta1.AgentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._CancelOperation._get_response( self._host, @@ -1804,7 +2420,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1814,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: operations_pb2.Operation: Response from GetOperation method. @@ -1824,6 +2442,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1838,6 +2457,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.dialogflow_v2beta1.AgentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._GetOperation._get_response( self._host, @@ -1857,6 +2503,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.AgentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1895,7 +2562,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1905,8 +2572,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1915,6 +2584,7 @@ def __call__( http_options = ( _BaseAgentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseAgentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1929,6 +2599,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.dialogflow_v2beta1.AgentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AgentsRestTransport._ListOperations._get_response( self._host, @@ -1948,6 +2645,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.AgentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Agents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py index 4321d49573c4..a073ca3c351d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport from .transports.grpc_asyncio import AnswerRecordsGrpcAsyncIOTransport +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 AnswerRecordsAsyncClient: """Service for managing @@ -270,13 +280,35 @@ 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.dialogflow_v2beta1.AnswerRecordsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "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.dialogflow.v2beta1.AnswerRecords", + "credentialsType": None, + }, + ) + async def get_answer_record( self, request: Optional[Union[answer_record.GetAnswerRecordRequest, dict]] = 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]]] = (), ) -> answer_record.AnswerRecord: r"""Deprecated. Retrieves a specific answer record. @@ -313,8 +345,10 @@ async def sample_get_answer_record(): 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.dialogflow_v2beta1.types.AnswerRecord: @@ -398,7 +432,7 @@ async def list_answer_records( 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.ListAnswerRecordsAsyncPager: r"""Returns the list of all answer records in the specified project in reverse chronological order. @@ -444,8 +478,10 @@ async def sample_list_answer_records(): 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.dialogflow_v2beta1.services.answer_records.pagers.ListAnswerRecordsAsyncPager: @@ -523,7 +559,7 @@ async def update_answer_record( 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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Updates the specified answer record. @@ -571,8 +607,10 @@ async def sample_update_answer_record(): 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.dialogflow_v2beta1.types.AnswerRecord: @@ -668,7 +706,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -679,8 +717,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -721,7 +761,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -732,8 +772,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -774,7 +816,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -789,8 +831,10 @@ async def cancel_operation( 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: None """ @@ -827,7 +871,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. @@ -838,8 +882,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. @@ -880,7 +926,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. @@ -891,8 +937,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-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/client.py index c0ee55ba90e6..a0e39a9c03c6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -641,6 +651,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( @@ -706,13 +720,36 @@ 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.dialogflow_v2beta1.AnswerRecordsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "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.dialogflow.v2beta1.AnswerRecords", + "credentialsType": None, + }, + ) + def get_answer_record( self, request: Optional[Union[answer_record.GetAnswerRecordRequest, dict]] = 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]]] = (), ) -> answer_record.AnswerRecord: r"""Deprecated. Retrieves a specific answer record. @@ -749,8 +786,10 @@ def sample_get_answer_record(): 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.dialogflow_v2beta1.types.AnswerRecord: @@ -831,7 +870,7 @@ def list_answer_records( 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.ListAnswerRecordsPager: r"""Returns the list of all answer records in the specified project in reverse chronological order. @@ -877,8 +916,10 @@ def sample_list_answer_records(): 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.dialogflow_v2beta1.services.answer_records.pagers.ListAnswerRecordsPager: @@ -953,7 +994,7 @@ def update_answer_record( 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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Updates the specified answer record. @@ -1001,8 +1042,10 @@ def sample_update_answer_record(): 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.dialogflow_v2beta1.types.AnswerRecord: @@ -1108,7 +1151,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1119,8 +1162,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1161,7 +1206,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1172,8 +1217,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1214,7 +1261,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1229,8 +1276,10 @@ def cancel_operation( 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: None """ @@ -1267,7 +1316,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. @@ -1278,8 +1327,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. @@ -1320,7 +1371,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. @@ -1331,8 +1382,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-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/pagers.py index 1555d677e8ab..dd3f0c1f2ccd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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 = answer_record.ListAnswerRecordsRequest(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 = answer_record.ListAnswerRecordsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py index 534aaa359edd..c0fdbaa2382c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import answer_record as gcd_answer_record from google.cloud.dialogflow_v2beta1.types import answer_record from .base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport +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.dialogflow.v2beta1.AnswerRecords", + "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.dialogflow.v2beta1.AnswerRecords", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnswerRecordsGrpcTransport(AnswerRecordsTransport): """gRPC backend transport for AnswerRecords. @@ -183,7 +264,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 @@ -258,7 +344,7 @@ def get_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_answer_record" not in self._stubs: - self._stubs["get_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["get_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/GetAnswerRecord", request_serializer=answer_record.GetAnswerRecordRequest.serialize, response_deserializer=answer_record.AnswerRecord.deserialize, @@ -288,7 +374,7 @@ def list_answer_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_answer_records" not in self._stubs: - self._stubs["list_answer_records"] = self.grpc_channel.unary_unary( + self._stubs["list_answer_records"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/ListAnswerRecords", request_serializer=answer_record.ListAnswerRecordsRequest.serialize, response_deserializer=answer_record.ListAnswerRecordsResponse.deserialize, @@ -316,7 +402,7 @@ def update_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_answer_record" not in self._stubs: - self._stubs["update_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["update_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/UpdateAnswerRecord", request_serializer=gcd_answer_record.UpdateAnswerRecordRequest.serialize, response_deserializer=gcd_answer_record.AnswerRecord.deserialize, @@ -324,7 +410,7 @@ def update_answer_record( return self._stubs["update_answer_record"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -336,7 +422,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -353,7 +439,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +458,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -391,7 +477,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, @@ -408,7 +494,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-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py index 9f1eb1c27a67..c1e0b4c84818 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import answer_record as gcd_answer_record from google.cloud.dialogflow_v2beta1.types import answer_record @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, AnswerRecordsTransport from .grpc import AnswerRecordsGrpcTransport +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.dialogflow.v2beta1.AnswerRecords", + "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.dialogflow.v2beta1.AnswerRecords", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnswerRecordsGrpcAsyncIOTransport(AnswerRecordsTransport): """gRPC AsyncIO backend transport for AnswerRecords. @@ -230,10 +312,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 @@ -268,7 +353,7 @@ def get_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_answer_record" not in self._stubs: - self._stubs["get_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["get_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/GetAnswerRecord", request_serializer=answer_record.GetAnswerRecordRequest.serialize, response_deserializer=answer_record.AnswerRecord.deserialize, @@ -298,7 +383,7 @@ def list_answer_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_answer_records" not in self._stubs: - self._stubs["list_answer_records"] = self.grpc_channel.unary_unary( + self._stubs["list_answer_records"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/ListAnswerRecords", request_serializer=answer_record.ListAnswerRecordsRequest.serialize, response_deserializer=answer_record.ListAnswerRecordsResponse.deserialize, @@ -327,7 +412,7 @@ def update_answer_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_answer_record" not in self._stubs: - self._stubs["update_answer_record"] = self.grpc_channel.unary_unary( + self._stubs["update_answer_record"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.AnswerRecords/UpdateAnswerRecord", request_serializer=gcd_answer_record.UpdateAnswerRecordRequest.serialize, response_deserializer=gcd_answer_record.AnswerRecord.deserialize, @@ -385,7 +470,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: @@ -401,7 +486,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -418,7 +503,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -437,7 +522,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -456,7 +541,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, @@ -473,7 +558,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-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py index b8f5fe3abb00..b18d5c593c80 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/answer_records/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 @@ -40,6 +40,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, @@ -96,8 +104,10 @@ def post_update_answer_record(self, response): def pre_get_answer_record( self, request: answer_record.GetAnswerRecordRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[answer_record.GetAnswerRecordRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + answer_record.GetAnswerRecordRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_answer_record Override in a subclass to manipulate the request or metadata @@ -119,8 +129,10 @@ def post_get_answer_record( def pre_list_answer_records( self, request: answer_record.ListAnswerRecordsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[answer_record.ListAnswerRecordsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + answer_record.ListAnswerRecordsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_answer_records Override in a subclass to manipulate the request or metadata @@ -142,8 +154,11 @@ def post_list_answer_records( def pre_update_answer_record( self, request: gcd_answer_record.UpdateAnswerRecordRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_answer_record.UpdateAnswerRecordRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_answer_record.UpdateAnswerRecordRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_answer_record Override in a subclass to manipulate the request or metadata @@ -165,8 +180,10 @@ def post_update_answer_record( 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 @@ -188,8 +205,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 @@ -211,8 +230,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -232,8 +253,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -255,8 +278,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -397,7 +422,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]]] = (), ) -> answer_record.AnswerRecord: r"""Call the get answer record method over HTTP. @@ -408,8 +433,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: ~.answer_record.AnswerRecord: @@ -450,6 +477,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseGetAnswerRecord._get_http_options() ) + request, metadata = self._interceptor.pre_get_answer_record( request, metadata ) @@ -462,6 +490,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 = 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.dialogflow_v2beta1.AnswerRecordsClient.GetAnswerRecord", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetAnswerRecord", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._GetAnswerRecord._get_response( self._host, @@ -482,7 +537,29 @@ def __call__( pb_resp = answer_record.AnswerRecord.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_answer_record(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = answer_record.AnswerRecord.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.dialogflow_v2beta1.AnswerRecordsClient.get_answer_record", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetAnswerRecord", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnswerRecords( @@ -519,7 +596,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]]] = (), ) -> answer_record.ListAnswerRecordsResponse: r"""Call the list answer records method over HTTP. @@ -530,8 +607,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: ~.answer_record.ListAnswerRecordsResponse: @@ -543,6 +622,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListAnswerRecords._get_http_options() ) + request, metadata = self._interceptor.pre_list_answer_records( request, metadata ) @@ -555,6 +635,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 = 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.dialogflow_v2beta1.AnswerRecordsClient.ListAnswerRecords", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListAnswerRecords", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListAnswerRecords._get_response( self._host, @@ -575,7 +682,31 @@ def __call__( pb_resp = answer_record.ListAnswerRecordsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_answer_records(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = answer_record.ListAnswerRecordsResponse.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.dialogflow_v2beta1.AnswerRecordsClient.list_answer_records", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListAnswerRecords", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAnswerRecord( @@ -613,7 +744,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]]] = (), ) -> gcd_answer_record.AnswerRecord: r"""Call the update answer record method over HTTP. @@ -624,8 +755,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: ~.gcd_answer_record.AnswerRecord: @@ -666,6 +799,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseUpdateAnswerRecord._get_http_options() ) + request, metadata = self._interceptor.pre_update_answer_record( request, metadata ) @@ -682,6 +816,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 = 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.dialogflow_v2beta1.AnswerRecordsClient.UpdateAnswerRecord", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "UpdateAnswerRecord", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._UpdateAnswerRecord._get_response( self._host, @@ -703,7 +864,29 @@ def __call__( pb_resp = gcd_answer_record.AnswerRecord.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_answer_record(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_answer_record.AnswerRecord.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.dialogflow_v2beta1.AnswerRecordsClient.update_answer_record", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "UpdateAnswerRecord", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -773,7 +956,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. @@ -783,8 +966,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. @@ -793,6 +978,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -805,6 +991,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.dialogflow_v2beta1.AnswerRecordsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._GetLocation._get_response( self._host, @@ -824,6 +1037,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.dialogflow_v2beta1.AnswerRecordsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -864,7 +1098,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. @@ -874,8 +1108,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. @@ -884,6 +1120,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -894,6 +1131,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.dialogflow_v2beta1.AnswerRecordsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListLocations._get_response( self._host, @@ -913,6 +1177,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.dialogflow_v2beta1.AnswerRecordsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -953,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -963,13 +1248,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 = ( _BaseAnswerRecordsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -982,6 +1270,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.dialogflow_v2beta1.AnswerRecordsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._CancelOperation._get_response( self._host, @@ -1037,7 +1352,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1047,8 +1362,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: operations_pb2.Operation: Response from GetOperation method. @@ -1057,6 +1374,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1067,6 +1385,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.dialogflow_v2beta1.AnswerRecordsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._GetOperation._get_response( self._host, @@ -1086,6 +1431,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.AnswerRecordsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1126,7 +1492,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1136,8 +1502,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1146,6 +1514,7 @@ def __call__( http_options = ( _BaseAnswerRecordsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAnswerRecordsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1156,6 +1525,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.dialogflow_v2beta1.AnswerRecordsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnswerRecordsRestTransport._ListOperations._get_response( self._host, @@ -1175,6 +1571,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.AnswerRecordsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.AnswerRecords", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py index 839ab9364162..4bc55bcc93b5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ContextsTransport from .transports.grpc_asyncio import ContextsGrpcAsyncIOTransport +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 ContextsAsyncClient: """Service for managing @@ -254,6 +264,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.dialogflow_v2beta1.ContextsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "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.dialogflow.v2beta1.Contexts", + "credentialsType": None, + }, + ) + async def list_contexts( self, request: Optional[Union[context.ListContextsRequest, dict]] = None, @@ -261,7 +293,7 @@ async def list_contexts( 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.ListContextsAsyncPager: r"""Returns the list of all contexts in the specified session. @@ -317,8 +349,10 @@ async def sample_list_contexts(): 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.dialogflow_v2beta1.services.contexts.pagers.ListContextsAsyncPager: @@ -393,7 +427,7 @@ async def get_context( 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]]] = (), ) -> context.Context: r"""Retrieves the specified context. @@ -446,8 +480,10 @@ async def sample_get_context(): 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.dialogflow_v2beta1.types.Context: @@ -526,7 +562,7 @@ async def create_context( context: Optional[gcd_context.Context] = 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]]] = (), ) -> gcd_context.Context: r"""Creates a context. @@ -588,8 +624,10 @@ async def sample_create_context(): 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.dialogflow_v2beta1.types.Context: @@ -670,7 +708,7 @@ async def update_context( 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]]] = (), ) -> gcd_context.Context: r"""Updates the specified context. @@ -718,8 +756,10 @@ async def sample_update_context(): 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.dialogflow_v2beta1.types.Context: @@ -801,7 +841,7 @@ async def delete_context( 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 the specified context. @@ -852,8 +892,10 @@ async def sample_delete_context(): 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 @@ -905,7 +947,7 @@ async def delete_all_contexts( 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]]] = (), ) -> None: r"""Deletes all active contexts in the specified session. @@ -956,8 +998,10 @@ async def sample_delete_all_contexts(): 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 @@ -1008,7 +1052,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1019,8 +1063,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1061,7 +1107,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1072,8 +1118,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1114,7 +1162,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1129,8 +1177,10 @@ async def cancel_operation( 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: None """ @@ -1167,7 +1217,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. @@ -1178,8 +1228,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. @@ -1220,7 +1272,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. @@ -1231,8 +1283,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-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/client.py index af6194d93f68..7bdd79509b8c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -584,6 +594,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( @@ -646,6 +660,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.dialogflow_v2beta1.ContextsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "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.dialogflow.v2beta1.Contexts", + "credentialsType": None, + }, + ) + def list_contexts( self, request: Optional[Union[context.ListContextsRequest, dict]] = None, @@ -653,7 +690,7 @@ def list_contexts( 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.ListContextsPager: r"""Returns the list of all contexts in the specified session. @@ -709,8 +746,10 @@ def sample_list_contexts(): 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.dialogflow_v2beta1.services.contexts.pagers.ListContextsPager: @@ -782,7 +821,7 @@ def get_context( 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]]] = (), ) -> context.Context: r"""Retrieves the specified context. @@ -835,8 +874,10 @@ def sample_get_context(): 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.dialogflow_v2beta1.types.Context: @@ -912,7 +953,7 @@ def create_context( context: Optional[gcd_context.Context] = 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]]] = (), ) -> gcd_context.Context: r"""Creates a context. @@ -974,8 +1015,10 @@ def sample_create_context(): 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.dialogflow_v2beta1.types.Context: @@ -1053,7 +1096,7 @@ def update_context( 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]]] = (), ) -> gcd_context.Context: r"""Updates the specified context. @@ -1101,8 +1144,10 @@ def sample_update_context(): 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.dialogflow_v2beta1.types.Context: @@ -1181,7 +1226,7 @@ def delete_context( 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 the specified context. @@ -1232,8 +1277,10 @@ def sample_delete_context(): 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 @@ -1282,7 +1329,7 @@ def delete_all_contexts( 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]]] = (), ) -> None: r"""Deletes all active contexts in the specified session. @@ -1333,8 +1380,10 @@ def sample_delete_all_contexts(): 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 @@ -1395,7 +1444,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1406,8 +1455,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1448,7 +1499,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1459,8 +1510,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1501,7 +1554,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1516,8 +1569,10 @@ def cancel_operation( 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: None """ @@ -1554,7 +1609,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. @@ -1565,8 +1620,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. @@ -1607,7 +1664,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. @@ -1618,8 +1675,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-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/pagers.py index d31b1c5700a1..9a482cdb7901 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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 = context.ListContextsRequest(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 = context.ListContextsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py index c3c71951ea35..483f95deb5c0 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import context from google.cloud.dialogflow_v2beta1.types import context as gcd_context from .base import DEFAULT_CLIENT_INFO, ContextsTransport +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.dialogflow.v2beta1.Contexts", + "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.dialogflow.v2beta1.Contexts", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ContextsGrpcTransport(ContextsTransport): """gRPC backend transport for Contexts. @@ -184,7 +265,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 @@ -259,7 +345,7 @@ def list_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_contexts" not in self._stubs: - self._stubs["list_contexts"] = self.grpc_channel.unary_unary( + self._stubs["list_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/ListContexts", request_serializer=context.ListContextsRequest.serialize, response_deserializer=context.ListContextsResponse.deserialize, @@ -283,7 +369,7 @@ def get_context(self) -> Callable[[context.GetContextRequest], context.Context]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_context" not in self._stubs: - self._stubs["get_context"] = self.grpc_channel.unary_unary( + self._stubs["get_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/GetContext", request_serializer=context.GetContextRequest.serialize, response_deserializer=context.Context.deserialize, @@ -312,7 +398,7 @@ def create_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_context" not in self._stubs: - self._stubs["create_context"] = self.grpc_channel.unary_unary( + self._stubs["create_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/CreateContext", request_serializer=gcd_context.CreateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -338,7 +424,7 @@ def update_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_context" not in self._stubs: - self._stubs["update_context"] = self.grpc_channel.unary_unary( + self._stubs["update_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/UpdateContext", request_serializer=gcd_context.UpdateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -364,7 +450,7 @@ def delete_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_context" not in self._stubs: - self._stubs["delete_context"] = self.grpc_channel.unary_unary( + self._stubs["delete_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/DeleteContext", request_serializer=context.DeleteContextRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -390,7 +476,7 @@ def delete_all_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_all_contexts" not in self._stubs: - self._stubs["delete_all_contexts"] = self.grpc_channel.unary_unary( + self._stubs["delete_all_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/DeleteAllContexts", request_serializer=context.DeleteAllContextsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -398,7 +484,7 @@ def delete_all_contexts( return self._stubs["delete_all_contexts"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -410,7 +496,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -427,7 +513,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +532,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -465,7 +551,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, @@ -482,7 +568,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-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py index 5af0e27bf96a..4db05fda54af 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import context from google.cloud.dialogflow_v2beta1.types import context as gcd_context @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, ContextsTransport from .grpc import ContextsGrpcTransport +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.dialogflow.v2beta1.Contexts", + "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.dialogflow.v2beta1.Contexts", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ContextsGrpcAsyncIOTransport(ContextsTransport): """gRPC AsyncIO backend transport for Contexts. @@ -231,10 +313,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 @@ -269,7 +354,7 @@ def list_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_contexts" not in self._stubs: - self._stubs["list_contexts"] = self.grpc_channel.unary_unary( + self._stubs["list_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/ListContexts", request_serializer=context.ListContextsRequest.serialize, response_deserializer=context.ListContextsResponse.deserialize, @@ -295,7 +380,7 @@ def get_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_context" not in self._stubs: - self._stubs["get_context"] = self.grpc_channel.unary_unary( + self._stubs["get_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/GetContext", request_serializer=context.GetContextRequest.serialize, response_deserializer=context.Context.deserialize, @@ -324,7 +409,7 @@ def create_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_context" not in self._stubs: - self._stubs["create_context"] = self.grpc_channel.unary_unary( + self._stubs["create_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/CreateContext", request_serializer=gcd_context.CreateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -350,7 +435,7 @@ def update_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_context" not in self._stubs: - self._stubs["update_context"] = self.grpc_channel.unary_unary( + self._stubs["update_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/UpdateContext", request_serializer=gcd_context.UpdateContextRequest.serialize, response_deserializer=gcd_context.Context.deserialize, @@ -376,7 +461,7 @@ def delete_context( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_context" not in self._stubs: - self._stubs["delete_context"] = self.grpc_channel.unary_unary( + self._stubs["delete_context"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/DeleteContext", request_serializer=context.DeleteContextRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -402,7 +487,7 @@ def delete_all_contexts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_all_contexts" not in self._stubs: - self._stubs["delete_all_contexts"] = self.grpc_channel.unary_unary( + self._stubs["delete_all_contexts"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Contexts/DeleteAllContexts", request_serializer=context.DeleteAllContextsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -475,7 +560,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: @@ -491,7 +576,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -508,7 +593,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -527,7 +612,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -546,7 +631,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, @@ -563,7 +648,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-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py index e470294c6396..ca1a92be3248 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/contexts/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 @@ -41,6 +41,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, @@ -113,8 +121,10 @@ def post_update_context(self, response): def pre_create_context( self, request: gcd_context.CreateContextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_context.CreateContextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_context.CreateContextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_context Override in a subclass to manipulate the request or metadata @@ -134,8 +144,10 @@ def post_create_context(self, response: gcd_context.Context) -> gcd_context.Cont def pre_delete_all_contexts( self, request: context.DeleteAllContextsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[context.DeleteAllContextsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + context.DeleteAllContextsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_all_contexts Override in a subclass to manipulate the request or metadata @@ -144,8 +156,10 @@ def pre_delete_all_contexts( return request, metadata def pre_delete_context( - self, request: context.DeleteContextRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.DeleteContextRequest, Sequence[Tuple[str, str]]]: + self, + request: context.DeleteContextRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.DeleteContextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_context Override in a subclass to manipulate the request or metadata @@ -154,8 +168,10 @@ def pre_delete_context( return request, metadata def pre_get_context( - self, request: context.GetContextRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.GetContextRequest, Sequence[Tuple[str, str]]]: + self, + request: context.GetContextRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.GetContextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_context Override in a subclass to manipulate the request or metadata @@ -173,8 +189,10 @@ def post_get_context(self, response: context.Context) -> context.Context: return response def pre_list_contexts( - self, request: context.ListContextsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[context.ListContextsRequest, Sequence[Tuple[str, str]]]: + self, + request: context.ListContextsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[context.ListContextsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_contexts Override in a subclass to manipulate the request or metadata @@ -196,8 +214,10 @@ def post_list_contexts( def pre_update_context( self, request: gcd_context.UpdateContextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_context.UpdateContextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_context.UpdateContextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_context Override in a subclass to manipulate the request or metadata @@ -217,8 +237,10 @@ def post_update_context(self, response: gcd_context.Context) -> gcd_context.Cont 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 @@ -240,8 +262,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 @@ -263,8 +287,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -284,8 +310,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -307,8 +335,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -450,7 +480,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]]] = (), ) -> gcd_context.Context: r"""Call the create context method over HTTP. @@ -461,8 +491,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: ~.gcd_context.Context: @@ -491,6 +523,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseCreateContext._get_http_options() ) + request, metadata = self._interceptor.pre_create_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseCreateContext._get_transcoded_request( @@ -509,6 +542,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.dialogflow_v2beta1.ContextsClient.CreateContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "CreateContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._CreateContext._get_response( self._host, @@ -530,7 +590,29 @@ def __call__( pb_resp = gcd_context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_context.Context.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.dialogflow_v2beta1.ContextsClient.create_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "CreateContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAllContexts( @@ -567,7 +649,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 all contexts method over HTTP. @@ -578,13 +660,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 = ( _BaseContextsRestTransport._BaseDeleteAllContexts._get_http_options() ) + request, metadata = self._interceptor.pre_delete_all_contexts( request, metadata ) @@ -597,6 +682,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.dialogflow_v2beta1.ContextsClient.DeleteAllContexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "DeleteAllContexts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._DeleteAllContexts._get_response( self._host, @@ -646,7 +758,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 context method over HTTP. @@ -657,13 +769,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 = ( _BaseContextsRestTransport._BaseDeleteContext._get_http_options() ) + request, metadata = self._interceptor.pre_delete_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseDeleteContext._get_transcoded_request( @@ -678,6 +793,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.dialogflow_v2beta1.ContextsClient.DeleteContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "DeleteContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._DeleteContext._get_response( self._host, @@ -725,7 +867,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]]] = (), ) -> context.Context: r"""Call the get context method over HTTP. @@ -736,8 +878,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: ~.context.Context: @@ -766,6 +910,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetContext._get_http_options() ) + request, metadata = self._interceptor.pre_get_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetContext._get_transcoded_request( @@ -780,6 +925,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.dialogflow_v2beta1.ContextsClient.GetContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetContext._get_response( self._host, @@ -800,7 +972,29 @@ def __call__( pb_resp = context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = context.Context.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.dialogflow_v2beta1.ContextsClient.get_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListContexts(_BaseContextsRestTransport._BaseListContexts, ContextsRestStub): @@ -835,7 +1029,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]]] = (), ) -> context.ListContextsResponse: r"""Call the list contexts method over HTTP. @@ -846,8 +1040,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: ~.context.ListContextsResponse: @@ -859,6 +1055,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListContexts._get_http_options() ) + request, metadata = self._interceptor.pre_list_contexts(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListContexts._get_transcoded_request( @@ -873,6 +1070,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.dialogflow_v2beta1.ContextsClient.ListContexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListContexts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListContexts._get_response( self._host, @@ -893,7 +1117,29 @@ def __call__( pb_resp = context.ListContextsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_contexts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = context.ListContextsResponse.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.dialogflow_v2beta1.ContextsClient.list_contexts", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListContexts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateContext( @@ -931,7 +1177,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]]] = (), ) -> gcd_context.Context: r"""Call the update context method over HTTP. @@ -942,8 +1188,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: ~.gcd_context.Context: @@ -972,6 +1220,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseUpdateContext._get_http_options() ) + request, metadata = self._interceptor.pre_update_context(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseUpdateContext._get_transcoded_request( @@ -990,6 +1239,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.dialogflow_v2beta1.ContextsClient.UpdateContext", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "UpdateContext", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._UpdateContext._get_response( self._host, @@ -1011,7 +1287,29 @@ def __call__( pb_resp = gcd_context.Context.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_context(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_context.Context.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.dialogflow_v2beta1.ContextsClient.update_context", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "UpdateContext", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1096,7 +1394,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. @@ -1106,8 +1404,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. @@ -1116,6 +1416,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1130,6 +1431,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.dialogflow_v2beta1.ContextsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetLocation._get_response( self._host, @@ -1149,6 +1477,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.dialogflow_v2beta1.ContextsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1189,7 +1538,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. @@ -1199,8 +1548,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. @@ -1209,6 +1560,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListLocations._get_transcoded_request( @@ -1223,6 +1575,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.dialogflow_v2beta1.ContextsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListLocations._get_response( self._host, @@ -1242,6 +1621,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.dialogflow_v2beta1.ContextsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1282,7 +1682,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1292,13 +1692,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 = ( _BaseContextsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1315,6 +1718,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.dialogflow_v2beta1.ContextsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._CancelOperation._get_response( self._host, @@ -1368,7 +1798,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1378,8 +1808,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: operations_pb2.Operation: Response from GetOperation method. @@ -1388,6 +1820,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1402,6 +1835,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.dialogflow_v2beta1.ContextsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._GetOperation._get_response( self._host, @@ -1421,6 +1881,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.ContextsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1461,7 +1942,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1471,8 +1952,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1481,6 +1964,7 @@ def __call__( http_options = ( _BaseContextsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseContextsRestTransport._BaseListOperations._get_transcoded_request( @@ -1495,6 +1979,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.dialogflow_v2beta1.ContextsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ContextsRestTransport._ListOperations._get_response( self._host, @@ -1514,6 +2025,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.ContextsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Contexts", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py index bfb4eb7c2935..5c1de7d5a3c8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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, ConversationProfilesTransport from .transports.grpc_asyncio import ConversationProfilesGrpcAsyncIOTransport +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 ConversationProfilesAsyncClient: """Service for managing @@ -302,6 +312,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.dialogflow_v2beta1.ConversationProfilesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "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.dialogflow.v2beta1.ConversationProfiles", + "credentialsType": None, + }, + ) + async def list_conversation_profiles( self, request: Optional[ @@ -311,7 +343,7 @@ async def list_conversation_profiles( 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.ListConversationProfilesAsyncPager: r"""Returns the list of all conversation profiles in the specified project. @@ -358,8 +390,10 @@ async def sample_list_conversation_profiles(): 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.dialogflow_v2beta1.services.conversation_profiles.pagers.ListConversationProfilesAsyncPager: @@ -438,7 +472,7 @@ async def get_conversation_profile( 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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Retrieves the specified conversation profile. @@ -483,8 +517,10 @@ async def sample_get_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -550,7 +586,7 @@ async def create_conversation_profile( ] = 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Creates a conversation profile in the specified project. @@ -612,8 +648,10 @@ async def sample_create_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -683,7 +721,7 @@ async def update_conversation_profile( 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Updates the specified conversation profile. @@ -743,8 +781,10 @@ async def sample_update_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -813,7 +853,7 @@ async def delete_conversation_profile( 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 the specified conversation profile. @@ -858,8 +898,10 @@ async def sample_delete_conversation_profile(): 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 @@ -919,7 +961,7 @@ async def set_suggestion_feature_config( ] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Adds or updates a suggestion feature in a conversation profile. If the conversation profile contains the type of suggestion @@ -1003,8 +1045,10 @@ async def sample_set_suggestion_feature_config(): 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.api_core.operation_async.AsyncOperation: @@ -1093,7 +1137,7 @@ async def clear_suggestion_feature_config( suggestion_feature_type: Optional[participant.SuggestionFeature.Type] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Clears a suggestion feature from a conversation profile for the given participant role. @@ -1170,8 +1214,10 @@ async def sample_clear_suggestion_feature_config(): 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.api_core.operation_async.AsyncOperation: @@ -1255,7 +1301,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1266,8 +1312,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1308,7 +1356,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1319,8 +1367,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1361,7 +1411,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1376,8 +1426,10 @@ async def cancel_operation( 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: None """ @@ -1414,7 +1466,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. @@ -1425,8 +1477,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. @@ -1467,7 +1521,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. @@ -1478,8 +1532,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py index 9307b3bc66c4..5dd5e881b7e3 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -738,6 +748,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( @@ -804,6 +818,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.dialogflow_v2beta1.ConversationProfilesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "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.dialogflow.v2beta1.ConversationProfiles", + "credentialsType": None, + }, + ) + def list_conversation_profiles( self, request: Optional[ @@ -813,7 +850,7 @@ def list_conversation_profiles( 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.ListConversationProfilesPager: r"""Returns the list of all conversation profiles in the specified project. @@ -860,8 +897,10 @@ def sample_list_conversation_profiles(): 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.dialogflow_v2beta1.services.conversation_profiles.pagers.ListConversationProfilesPager: @@ -939,7 +978,7 @@ def get_conversation_profile( 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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Retrieves the specified conversation profile. @@ -984,8 +1023,10 @@ def sample_get_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -1048,7 +1089,7 @@ def create_conversation_profile( ] = 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Creates a conversation profile in the specified project. @@ -1110,8 +1151,10 @@ def sample_create_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -1180,7 +1223,7 @@ def update_conversation_profile( 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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Updates the specified conversation profile. @@ -1240,8 +1283,10 @@ def sample_update_conversation_profile(): 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.dialogflow_v2beta1.types.ConversationProfile: @@ -1309,7 +1354,7 @@ def delete_conversation_profile( 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 the specified conversation profile. @@ -1354,8 +1399,10 @@ def sample_delete_conversation_profile(): 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 @@ -1414,7 +1461,7 @@ def set_suggestion_feature_config( ] = 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]]] = (), ) -> operation.Operation: r"""Adds or updates a suggestion feature in a conversation profile. If the conversation profile contains the type of suggestion @@ -1498,8 +1545,10 @@ def sample_set_suggestion_feature_config(): 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.api_core.operation.Operation: @@ -1587,7 +1636,7 @@ def clear_suggestion_feature_config( suggestion_feature_type: Optional[participant.SuggestionFeature.Type] = 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]]] = (), ) -> operation.Operation: r"""Clears a suggestion feature from a conversation profile for the given participant role. @@ -1664,8 +1713,10 @@ def sample_clear_suggestion_feature_config(): 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.api_core.operation.Operation: @@ -1761,7 +1812,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1772,8 +1823,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1814,7 +1867,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1825,8 +1878,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1867,7 +1922,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1882,8 +1937,10 @@ def cancel_operation( 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: None """ @@ -1920,7 +1977,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. @@ -1931,8 +1988,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. @@ -1973,7 +2032,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. @@ -1984,8 +2043,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/pagers.py index b882f211a924..d25d7deb2577 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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 = conversation_profile.ListConversationProfilesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = conversation_profile.ListConversationProfilesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py index ee3285ced3bf..4e0a2a4d74df 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import ( conversation_profile as gcd_conversation_profile, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ConversationProfilesTransport +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.dialogflow.v2beta1.ConversationProfiles", + "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.dialogflow.v2beta1.ConversationProfiles", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationProfilesGrpcTransport(ConversationProfilesTransport): """gRPC backend transport for ConversationProfiles. @@ -187,7 +268,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 @@ -251,7 +337,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -279,7 +367,9 @@ def list_conversation_profiles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_profiles" not in self._stubs: - self._stubs["list_conversation_profiles"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_profiles" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/ListConversationProfiles", request_serializer=conversation_profile.ListConversationProfilesRequest.serialize, response_deserializer=conversation_profile.ListConversationProfilesResponse.deserialize, @@ -308,7 +398,7 @@ def get_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_profile" not in self._stubs: - self._stubs["get_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_profile"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/GetConversationProfile", request_serializer=conversation_profile.GetConversationProfileRequest.serialize, response_deserializer=conversation_profile.ConversationProfile.deserialize, @@ -343,7 +433,9 @@ def create_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_profile" not in self._stubs: - self._stubs["create_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/CreateConversationProfile", request_serializer=gcd_conversation_profile.CreateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -378,7 +470,9 @@ def update_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversation_profile" not in self._stubs: - self._stubs["update_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/UpdateConversationProfile", request_serializer=gcd_conversation_profile.UpdateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -406,7 +500,9 @@ def delete_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_profile" not in self._stubs: - self._stubs["delete_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/DeleteConversationProfile", request_serializer=conversation_profile.DeleteConversationProfileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -456,7 +552,7 @@ def set_suggestion_feature_config( if "set_suggestion_feature_config" not in self._stubs: self._stubs[ "set_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/SetSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.SetSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -499,7 +595,7 @@ def clear_suggestion_feature_config( if "clear_suggestion_feature_config" not in self._stubs: self._stubs[ "clear_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/ClearSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.ClearSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -507,7 +603,7 @@ def clear_suggestion_feature_config( return self._stubs["clear_suggestion_feature_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -519,7 +615,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -536,7 +632,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -555,7 +651,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -574,7 +670,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, @@ -591,7 +687,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py index ff2833e59e4c..80387179467d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import ( conversation_profile as gcd_conversation_profile, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationProfilesTransport from .grpc import ConversationProfilesGrpcTransport +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.dialogflow.v2beta1.ConversationProfiles", + "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.dialogflow.v2beta1.ConversationProfiles", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationProfilesGrpcAsyncIOTransport(ConversationProfilesTransport): """gRPC AsyncIO backend transport for ConversationProfiles. @@ -234,10 +316,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 @@ -260,7 +345,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -289,7 +374,9 @@ def list_conversation_profiles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversation_profiles" not in self._stubs: - self._stubs["list_conversation_profiles"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_conversation_profiles" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/ListConversationProfiles", request_serializer=conversation_profile.ListConversationProfilesRequest.serialize, response_deserializer=conversation_profile.ListConversationProfilesResponse.deserialize, @@ -318,7 +405,7 @@ def get_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation_profile" not in self._stubs: - self._stubs["get_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation_profile"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/GetConversationProfile", request_serializer=conversation_profile.GetConversationProfileRequest.serialize, response_deserializer=conversation_profile.ConversationProfile.deserialize, @@ -353,7 +440,9 @@ def create_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation_profile" not in self._stubs: - self._stubs["create_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/CreateConversationProfile", request_serializer=gcd_conversation_profile.CreateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -388,7 +477,9 @@ def update_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversation_profile" not in self._stubs: - self._stubs["update_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/UpdateConversationProfile", request_serializer=gcd_conversation_profile.UpdateConversationProfileRequest.serialize, response_deserializer=gcd_conversation_profile.ConversationProfile.deserialize, @@ -417,7 +508,9 @@ def delete_conversation_profile( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversation_profile" not in self._stubs: - self._stubs["delete_conversation_profile"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_conversation_profile" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/DeleteConversationProfile", request_serializer=conversation_profile.DeleteConversationProfileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -467,7 +560,7 @@ def set_suggestion_feature_config( if "set_suggestion_feature_config" not in self._stubs: self._stubs[ "set_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/SetSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.SetSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -510,7 +603,7 @@ def clear_suggestion_feature_config( if "clear_suggestion_feature_config" not in self._stubs: self._stubs[ "clear_suggestion_feature_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.ConversationProfiles/ClearSuggestionFeatureConfig", request_serializer=gcd_conversation_profile.ClearSuggestionFeatureConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -588,7 +681,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: @@ -604,7 +697,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -621,7 +714,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -640,7 +733,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -659,7 +752,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, @@ -676,7 +769,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py index b9d13a15606e..c6c0e21d77b5 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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 @@ -43,6 +43,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, @@ -127,10 +135,10 @@ def post_update_conversation_profile(self, response): def pre_clear_suggestion_feature_config( self, request: gcd_conversation_profile.ClearSuggestionFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.ClearSuggestionFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for clear_suggestion_feature_config @@ -153,10 +161,10 @@ def post_clear_suggestion_feature_config( def pre_create_conversation_profile( self, request: gcd_conversation_profile.CreateConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.CreateConversationProfileRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_conversation_profile @@ -179,9 +187,10 @@ def post_create_conversation_profile( def pre_delete_conversation_profile( self, request: conversation_profile.DeleteConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.DeleteConversationProfileRequest, Sequence[Tuple[str, str]] + conversation_profile.DeleteConversationProfileRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_conversation_profile @@ -193,9 +202,10 @@ def pre_delete_conversation_profile( def pre_get_conversation_profile( self, request: conversation_profile.GetConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.GetConversationProfileRequest, Sequence[Tuple[str, str]] + conversation_profile.GetConversationProfileRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_conversation_profile @@ -218,9 +228,10 @@ def post_get_conversation_profile( def pre_list_conversation_profiles( self, request: conversation_profile.ListConversationProfilesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation_profile.ListConversationProfilesRequest, Sequence[Tuple[str, str]] + conversation_profile.ListConversationProfilesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_conversation_profiles @@ -243,10 +254,10 @@ def post_list_conversation_profiles( def pre_set_suggestion_feature_config( self, request: gcd_conversation_profile.SetSuggestionFeatureConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.SetSuggestionFeatureConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_suggestion_feature_config @@ -269,10 +280,10 @@ def post_set_suggestion_feature_config( def pre_update_conversation_profile( self, request: gcd_conversation_profile.UpdateConversationProfileRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_conversation_profile.UpdateConversationProfileRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_conversation_profile @@ -295,8 +306,10 @@ def post_update_conversation_profile( 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 @@ -318,8 +331,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 @@ -341,8 +356,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -362,8 +379,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -385,8 +404,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -590,7 +611,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]]] = (), ) -> operations_pb2.Operation: r"""Call the clear suggestion feature config method over HTTP. @@ -602,8 +623,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: ~.operations_pb2.Operation: @@ -616,6 +639,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseClearSuggestionFeatureConfig._get_http_options() ) + request, metadata = self._interceptor.pre_clear_suggestion_feature_config( request, metadata ) @@ -632,6 +656,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.dialogflow_v2beta1.ConversationProfilesClient.ClearSuggestionFeatureConfig", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ClearSuggestionFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ClearSuggestionFeatureConfig._get_response( self._host, @@ -651,7 +702,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_clear_suggestion_feature_config(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.dialogflow_v2beta1.ConversationProfilesClient.clear_suggestion_feature_config", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ClearSuggestionFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversationProfile( @@ -690,7 +763,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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Call the create conversation profile method over HTTP. @@ -702,8 +775,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: ~.gcd_conversation_profile.ConversationProfile: @@ -715,6 +790,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseCreateConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation_profile( request, metadata ) @@ -731,6 +807,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 = 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.dialogflow_v2beta1.ConversationProfilesClient.CreateConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "CreateConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._CreateConversationProfile._get_response( self._host, @@ -752,7 +855,31 @@ def __call__( pb_resp = gcd_conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation_profile.ConversationProfile.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.dialogflow_v2beta1.ConversationProfilesClient.create_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "CreateConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConversationProfile( @@ -790,7 +917,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 conversation profile method over HTTP. @@ -805,13 +932,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 = ( _BaseConversationProfilesRestTransport._BaseDeleteConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversation_profile( request, metadata ) @@ -824,6 +954,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.dialogflow_v2beta1.ConversationProfilesClient.DeleteConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "DeleteConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._DeleteConversationProfile._get_response( self._host, @@ -874,7 +1031,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]]] = (), ) -> conversation_profile.ConversationProfile: r"""Call the get conversation profile method over HTTP. @@ -885,8 +1042,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: ~.conversation_profile.ConversationProfile: @@ -898,6 +1057,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation_profile( request, metadata ) @@ -910,6 +1070,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 = 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.dialogflow_v2beta1.ConversationProfilesClient.GetConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationProfilesRestTransport._GetConversationProfile._get_response( @@ -932,7 +1119,31 @@ def __call__( pb_resp = conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation_profile.ConversationProfile.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.dialogflow_v2beta1.ConversationProfilesClient.get_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversationProfiles( @@ -970,7 +1181,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]]] = (), ) -> conversation_profile.ListConversationProfilesResponse: r"""Call the list conversation profiles method over HTTP. @@ -982,8 +1193,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: ~.conversation_profile.ListConversationProfilesResponse: @@ -995,6 +1208,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListConversationProfiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversation_profiles( request, metadata ) @@ -1007,6 +1221,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 = 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.dialogflow_v2beta1.ConversationProfilesClient.ListConversationProfiles", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListConversationProfiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListConversationProfiles._get_response( self._host, @@ -1027,7 +1268,33 @@ def __call__( pb_resp = conversation_profile.ListConversationProfilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversation_profiles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation_profile.ListConversationProfilesResponse.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.dialogflow_v2beta1.ConversationProfilesClient.list_conversation_profiles", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListConversationProfiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetSuggestionFeatureConfig( @@ -1066,7 +1333,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]]] = (), ) -> operations_pb2.Operation: r"""Call the set suggestion feature config method over HTTP. @@ -1078,8 +1345,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: ~.operations_pb2.Operation: @@ -1092,6 +1361,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseSetSuggestionFeatureConfig._get_http_options() ) + request, metadata = self._interceptor.pre_set_suggestion_feature_config( request, metadata ) @@ -1108,6 +1378,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.dialogflow_v2beta1.ConversationProfilesClient.SetSuggestionFeatureConfig", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "SetSuggestionFeatureConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._SetSuggestionFeatureConfig._get_response( self._host, @@ -1127,7 +1424,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_suggestion_feature_config(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.dialogflow_v2beta1.ConversationProfilesClient.set_suggestion_feature_config", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "SetSuggestionFeatureConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConversationProfile( @@ -1166,7 +1485,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]]] = (), ) -> gcd_conversation_profile.ConversationProfile: r"""Call the update conversation profile method over HTTP. @@ -1178,8 +1497,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: ~.gcd_conversation_profile.ConversationProfile: @@ -1191,6 +1512,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseUpdateConversationProfile._get_http_options() ) + request, metadata = self._interceptor.pre_update_conversation_profile( request, metadata ) @@ -1207,6 +1529,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 = 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.dialogflow_v2beta1.ConversationProfilesClient.UpdateConversationProfile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "UpdateConversationProfile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._UpdateConversationProfile._get_response( self._host, @@ -1228,7 +1577,31 @@ def __call__( pb_resp = gcd_conversation_profile.ConversationProfile.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_conversation_profile(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation_profile.ConversationProfile.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.dialogflow_v2beta1.ConversationProfilesClient.update_conversation_profile", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "UpdateConversationProfile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1346,7 +1719,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. @@ -1356,8 +1729,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. @@ -1366,6 +1741,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1376,6 +1752,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.dialogflow_v2beta1.ConversationProfilesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._GetLocation._get_response( self._host, @@ -1395,6 +1798,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.dialogflow_v2beta1.ConversationProfilesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1436,7 +1860,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. @@ -1446,8 +1870,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. @@ -1456,6 +1882,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1466,6 +1893,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.dialogflow_v2beta1.ConversationProfilesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListLocations._get_response( self._host, @@ -1485,6 +1939,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.dialogflow_v2beta1.ConversationProfilesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1526,7 +2001,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1536,13 +2011,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 = ( _BaseConversationProfilesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1555,6 +2033,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.dialogflow_v2beta1.ConversationProfilesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._CancelOperation._get_response( self._host, @@ -1611,7 +2116,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1621,8 +2126,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: operations_pb2.Operation: Response from GetOperation method. @@ -1631,6 +2138,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1641,6 +2149,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.dialogflow_v2beta1.ConversationProfilesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._GetOperation._get_response( self._host, @@ -1660,6 +2195,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.ConversationProfilesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1701,7 +2257,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1711,8 +2267,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1721,6 +2279,7 @@ def __call__( http_options = ( _BaseConversationProfilesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationProfilesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1731,6 +2290,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.dialogflow_v2beta1.ConversationProfilesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationProfilesRestTransport._ListOperations._get_response( self._host, @@ -1750,6 +2336,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.ConversationProfilesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.ConversationProfiles", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py index 7a53aa4eb201..37840988dbad 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ConversationsTransport from .transports.grpc_asyncio import ConversationsGrpcAsyncIOTransport +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 ConversationsAsyncClient: """Service for managing @@ -298,6 +308,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.dialogflow_v2beta1.ConversationsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "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.dialogflow.v2beta1.Conversations", + "credentialsType": None, + }, + ) + async def create_conversation( self, request: Optional[ @@ -308,7 +340,7 @@ async def create_conversation( conversation: Optional[gcd_conversation.Conversation] = 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]]] = (), ) -> gcd_conversation.Conversation: r"""Creates a new conversation. Conversations are auto-completed after 24 hours. @@ -382,8 +414,10 @@ async def sample_create_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -451,7 +485,7 @@ async def list_conversations( 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.ListConversationsAsyncPager: r"""Returns the list of all conversations in the specified project. @@ -498,8 +532,10 @@ async def sample_list_conversations(): 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.dialogflow_v2beta1.services.conversations.pagers.ListConversationsAsyncPager: @@ -574,7 +610,7 @@ async def get_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Retrieves the specific conversation. @@ -618,8 +654,10 @@ async def sample_get_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -685,7 +723,7 @@ async def complete_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Completes the specified conversation. Finished conversations are purged from the database after 30 @@ -732,8 +770,10 @@ async def sample_complete_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -800,7 +840,7 @@ async def batch_create_messages( requests: Optional[MutableSequence[conversation.CreateMessageRequest]] = 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]]] = (), ) -> conversation.BatchCreateMessagesResponse: r"""Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to @@ -861,8 +901,10 @@ async def sample_batch_create_messages(): 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.dialogflow_v2beta1.types.BatchCreateMessagesResponse: @@ -925,7 +967,7 @@ async def list_messages( 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.ListMessagesAsyncPager: r"""Lists messages that belong to a given conversation. ``messages`` are ordered by ``create_time`` in descending order. To fetch @@ -975,8 +1017,10 @@ async def sample_list_messages(): 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.dialogflow_v2beta1.services.conversations.pagers.ListMessagesAsyncPager: @@ -1053,7 +1097,7 @@ async def suggest_conversation_summary( conversation: 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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Suggest summary for a conversation based on specific historical messages. The range of the messages to be @@ -1100,8 +1144,10 @@ async def sample_suggest_conversation_summary(): 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.dialogflow_v2beta1.types.SuggestConversationSummaryResponse: @@ -1165,7 +1211,7 @@ async def generate_stateless_summary( *, 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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Generates and returns a summary for a conversation that does not have a resource created for it. @@ -1211,8 +1257,10 @@ async def sample_generate_stateless_summary(): 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.dialogflow_v2beta1.types.GenerateStatelessSummaryResponse: @@ -1267,7 +1315,7 @@ async def generate_stateless_suggestion( *, 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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Generates and returns a suggestion for a conversation that does not have a resource created for it. @@ -1305,8 +1353,10 @@ async def sample_generate_stateless_suggestion(): 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.dialogflow_v2beta1.types.GenerateStatelessSuggestionResponse: @@ -1352,7 +1402,7 @@ async def search_knowledge( *, 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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Get answers for the given query based on knowledge documents. @@ -1392,8 +1442,10 @@ async def sample_search_knowledge(): 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.dialogflow_v2beta1.types.SearchKnowledgeResponse: @@ -1439,7 +1491,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1450,8 +1502,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1492,7 +1546,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1503,8 +1557,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1545,7 +1601,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1560,8 +1616,10 @@ async def cancel_operation( 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: None """ @@ -1598,7 +1656,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. @@ -1609,8 +1667,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. @@ -1651,7 +1711,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. @@ -1662,8 +1722,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/client.py index 588ba148cb41..7e08953cd0c6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -812,6 +822,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( @@ -877,6 +891,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.dialogflow_v2beta1.ConversationsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "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.dialogflow.v2beta1.Conversations", + "credentialsType": None, + }, + ) + def create_conversation( self, request: Optional[ @@ -887,7 +924,7 @@ def create_conversation( conversation: Optional[gcd_conversation.Conversation] = 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]]] = (), ) -> gcd_conversation.Conversation: r"""Creates a new conversation. Conversations are auto-completed after 24 hours. @@ -961,8 +998,10 @@ def sample_create_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -1027,7 +1066,7 @@ def list_conversations( 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.ListConversationsPager: r"""Returns the list of all conversations in the specified project. @@ -1074,8 +1113,10 @@ def sample_list_conversations(): 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.dialogflow_v2beta1.services.conversations.pagers.ListConversationsPager: @@ -1147,7 +1188,7 @@ def get_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Retrieves the specific conversation. @@ -1191,8 +1232,10 @@ def sample_get_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -1255,7 +1298,7 @@ def complete_conversation( 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]]] = (), ) -> conversation.Conversation: r"""Completes the specified conversation. Finished conversations are purged from the database after 30 @@ -1302,8 +1345,10 @@ def sample_complete_conversation(): 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.dialogflow_v2beta1.types.Conversation: @@ -1367,7 +1412,7 @@ def batch_create_messages( requests: Optional[MutableSequence[conversation.CreateMessageRequest]] = 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]]] = (), ) -> conversation.BatchCreateMessagesResponse: r"""Batch ingests messages to conversation. Customers can use this RPC to ingest historical messages to @@ -1428,8 +1473,10 @@ def sample_batch_create_messages(): 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.dialogflow_v2beta1.types.BatchCreateMessagesResponse: @@ -1489,7 +1536,7 @@ def list_messages( 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.ListMessagesPager: r"""Lists messages that belong to a given conversation. ``messages`` are ordered by ``create_time`` in descending order. To fetch @@ -1539,8 +1586,10 @@ def sample_list_messages(): 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.dialogflow_v2beta1.services.conversations.pagers.ListMessagesPager: @@ -1614,7 +1663,7 @@ def suggest_conversation_summary( conversation: 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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Suggest summary for a conversation based on specific historical messages. The range of the messages to be @@ -1661,8 +1710,10 @@ def sample_suggest_conversation_summary(): 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.dialogflow_v2beta1.types.SuggestConversationSummaryResponse: @@ -1725,7 +1776,7 @@ def generate_stateless_summary( *, 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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Generates and returns a summary for a conversation that does not have a resource created for it. @@ -1771,8 +1822,10 @@ def sample_generate_stateless_summary(): 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.dialogflow_v2beta1.types.GenerateStatelessSummaryResponse: @@ -1827,7 +1880,7 @@ def generate_stateless_suggestion( *, 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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Generates and returns a suggestion for a conversation that does not have a resource created for it. @@ -1865,8 +1918,10 @@ def sample_generate_stateless_suggestion(): 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.dialogflow_v2beta1.types.GenerateStatelessSuggestionResponse: @@ -1912,7 +1967,7 @@ def search_knowledge( *, 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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Get answers for the given query based on knowledge documents. @@ -1952,8 +2007,10 @@ def sample_search_knowledge(): 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.dialogflow_v2beta1.types.SearchKnowledgeResponse: @@ -2010,7 +2067,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2021,8 +2078,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2063,7 +2122,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2074,8 +2133,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2116,7 +2177,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2131,8 +2192,10 @@ def cancel_operation( 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: None """ @@ -2169,7 +2232,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. @@ -2180,8 +2243,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. @@ -2222,7 +2287,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. @@ -2233,8 +2298,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/pagers.py index 71944c3a2b39..ca256aff91c3 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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 = conversation.ListConversationsRequest(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 = conversation.ListConversationsRequest(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 = conversation.ListMessagesRequest(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 = conversation.ListMessagesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py index cd920e4a9c96..12609caad470 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import conversation as gcd_conversation from google.cloud.dialogflow_v2beta1.types import conversation from .base import DEFAULT_CLIENT_INFO, ConversationsTransport +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.dialogflow.v2beta1.Conversations", + "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.dialogflow.v2beta1.Conversations", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationsGrpcTransport(ConversationsTransport): """gRPC backend transport for Conversations. @@ -183,7 +264,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 @@ -279,7 +365,7 @@ def create_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation" not in self._stubs: - self._stubs["create_conversation"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/CreateConversation", request_serializer=gcd_conversation.CreateConversationRequest.serialize, response_deserializer=gcd_conversation.Conversation.deserialize, @@ -308,7 +394,7 @@ def list_conversations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversations" not in self._stubs: - self._stubs["list_conversations"] = self.grpc_channel.unary_unary( + self._stubs["list_conversations"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/ListConversations", request_serializer=conversation.ListConversationsRequest.serialize, response_deserializer=conversation.ListConversationsResponse.deserialize, @@ -334,7 +420,7 @@ def get_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation" not in self._stubs: - self._stubs["get_conversation"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GetConversation", request_serializer=conversation.GetConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -364,7 +450,7 @@ def complete_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_conversation" not in self._stubs: - self._stubs["complete_conversation"] = self.grpc_channel.unary_unary( + self._stubs["complete_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/CompleteConversation", request_serializer=conversation.CompleteConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -395,7 +481,7 @@ def batch_create_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_messages" not in self._stubs: - self._stubs["batch_create_messages"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/BatchCreateMessages", request_serializer=conversation.BatchCreateMessagesRequest.serialize, response_deserializer=conversation.BatchCreateMessagesResponse.deserialize, @@ -427,7 +513,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/ListMessages", request_serializer=conversation.ListMessagesRequest.serialize, response_deserializer=conversation.ListMessagesResponse.deserialize, @@ -458,7 +544,9 @@ def suggest_conversation_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_conversation_summary" not in self._stubs: - self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "suggest_conversation_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/SuggestConversationSummary", request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize, response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize, @@ -488,7 +576,9 @@ def generate_stateless_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stateless_summary" not in self._stubs: - self._stubs["generate_stateless_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_stateless_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GenerateStatelessSummary", request_serializer=conversation.GenerateStatelessSummaryRequest.serialize, response_deserializer=conversation.GenerateStatelessSummaryResponse.deserialize, @@ -520,7 +610,7 @@ def generate_stateless_suggestion( if "generate_stateless_suggestion" not in self._stubs: self._stubs[ "generate_stateless_suggestion" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GenerateStatelessSuggestion", request_serializer=conversation.GenerateStatelessSuggestionRequest.serialize, response_deserializer=conversation.GenerateStatelessSuggestionResponse.deserialize, @@ -549,7 +639,7 @@ def search_knowledge( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_knowledge" not in self._stubs: - self._stubs["search_knowledge"] = self.grpc_channel.unary_unary( + self._stubs["search_knowledge"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/SearchKnowledge", request_serializer=conversation.SearchKnowledgeRequest.serialize, response_deserializer=conversation.SearchKnowledgeResponse.deserialize, @@ -557,7 +647,7 @@ def search_knowledge( return self._stubs["search_knowledge"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -569,7 +659,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -586,7 +676,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -605,7 +695,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -624,7 +714,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, @@ -641,7 +731,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py index 51eb3b1fd2cb..af1dc5878014 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import conversation as gcd_conversation from google.cloud.dialogflow_v2beta1.types import conversation @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, ConversationsTransport from .grpc import ConversationsGrpcTransport +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.dialogflow.v2beta1.Conversations", + "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.dialogflow.v2beta1.Conversations", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConversationsGrpcAsyncIOTransport(ConversationsTransport): """gRPC AsyncIO backend transport for Conversations. @@ -230,10 +312,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 @@ -288,7 +373,7 @@ def create_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversation" not in self._stubs: - self._stubs["create_conversation"] = self.grpc_channel.unary_unary( + self._stubs["create_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/CreateConversation", request_serializer=gcd_conversation.CreateConversationRequest.serialize, response_deserializer=gcd_conversation.Conversation.deserialize, @@ -318,7 +403,7 @@ def list_conversations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversations" not in self._stubs: - self._stubs["list_conversations"] = self.grpc_channel.unary_unary( + self._stubs["list_conversations"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/ListConversations", request_serializer=conversation.ListConversationsRequest.serialize, response_deserializer=conversation.ListConversationsResponse.deserialize, @@ -346,7 +431,7 @@ def get_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversation" not in self._stubs: - self._stubs["get_conversation"] = self.grpc_channel.unary_unary( + self._stubs["get_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GetConversation", request_serializer=conversation.GetConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -376,7 +461,7 @@ def complete_conversation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "complete_conversation" not in self._stubs: - self._stubs["complete_conversation"] = self.grpc_channel.unary_unary( + self._stubs["complete_conversation"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/CompleteConversation", request_serializer=conversation.CompleteConversationRequest.serialize, response_deserializer=conversation.Conversation.deserialize, @@ -407,7 +492,7 @@ def batch_create_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_messages" not in self._stubs: - self._stubs["batch_create_messages"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/BatchCreateMessages", request_serializer=conversation.BatchCreateMessagesRequest.serialize, response_deserializer=conversation.BatchCreateMessagesResponse.deserialize, @@ -439,7 +524,7 @@ def list_messages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_messages" not in self._stubs: - self._stubs["list_messages"] = self.grpc_channel.unary_unary( + self._stubs["list_messages"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/ListMessages", request_serializer=conversation.ListMessagesRequest.serialize, response_deserializer=conversation.ListMessagesResponse.deserialize, @@ -470,7 +555,9 @@ def suggest_conversation_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_conversation_summary" not in self._stubs: - self._stubs["suggest_conversation_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "suggest_conversation_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/SuggestConversationSummary", request_serializer=gcd_conversation.SuggestConversationSummaryRequest.serialize, response_deserializer=gcd_conversation.SuggestConversationSummaryResponse.deserialize, @@ -500,7 +587,9 @@ def generate_stateless_summary( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_stateless_summary" not in self._stubs: - self._stubs["generate_stateless_summary"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_stateless_summary" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GenerateStatelessSummary", request_serializer=conversation.GenerateStatelessSummaryRequest.serialize, response_deserializer=conversation.GenerateStatelessSummaryResponse.deserialize, @@ -532,7 +621,7 @@ def generate_stateless_suggestion( if "generate_stateless_suggestion" not in self._stubs: self._stubs[ "generate_stateless_suggestion" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/GenerateStatelessSuggestion", request_serializer=conversation.GenerateStatelessSuggestionRequest.serialize, response_deserializer=conversation.GenerateStatelessSuggestionResponse.deserialize, @@ -562,7 +651,7 @@ def search_knowledge( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_knowledge" not in self._stubs: - self._stubs["search_knowledge"] = self.grpc_channel.unary_unary( + self._stubs["search_knowledge"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Conversations/SearchKnowledge", request_serializer=conversation.SearchKnowledgeRequest.serialize, response_deserializer=conversation.SearchKnowledgeResponse.deserialize, @@ -655,7 +744,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: @@ -671,7 +760,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -688,7 +777,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +796,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -726,7 +815,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, @@ -743,7 +832,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-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py index f5e22e8a5df4..57d77e1525a6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/conversations/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 @@ -40,6 +40,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, @@ -152,8 +160,10 @@ def post_suggest_conversation_summary(self, response): def pre_batch_create_messages( self, request: conversation.BatchCreateMessagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.BatchCreateMessagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.BatchCreateMessagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_messages Override in a subclass to manipulate the request or metadata @@ -175,8 +185,11 @@ def post_batch_create_messages( def pre_complete_conversation( self, request: conversation.CompleteConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.CompleteConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.CompleteConversationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for complete_conversation Override in a subclass to manipulate the request or metadata @@ -198,8 +211,11 @@ def post_complete_conversation( def pre_create_conversation( self, request: gcd_conversation.CreateConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_conversation.CreateConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_conversation.CreateConversationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_conversation Override in a subclass to manipulate the request or metadata @@ -221,9 +237,10 @@ def post_create_conversation( def pre_generate_stateless_suggestion( self, request: conversation.GenerateStatelessSuggestionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - conversation.GenerateStatelessSuggestionRequest, Sequence[Tuple[str, str]] + conversation.GenerateStatelessSuggestionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for generate_stateless_suggestion @@ -246,8 +263,11 @@ def post_generate_stateless_suggestion( def pre_generate_stateless_summary( self, request: conversation.GenerateStatelessSummaryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.GenerateStatelessSummaryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.GenerateStatelessSummaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_stateless_summary Override in a subclass to manipulate the request or metadata @@ -269,8 +289,10 @@ def post_generate_stateless_summary( def pre_get_conversation( self, request: conversation.GetConversationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.GetConversationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.GetConversationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_conversation Override in a subclass to manipulate the request or metadata @@ -292,8 +314,10 @@ def post_get_conversation( def pre_list_conversations( self, request: conversation.ListConversationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.ListConversationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.ListConversationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_conversations Override in a subclass to manipulate the request or metadata @@ -315,8 +339,10 @@ def post_list_conversations( def pre_list_messages( self, request: conversation.ListMessagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.ListMessagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.ListMessagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_messages Override in a subclass to manipulate the request or metadata @@ -338,8 +364,10 @@ def post_list_messages( def pre_search_knowledge( self, request: conversation.SearchKnowledgeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[conversation.SearchKnowledgeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + conversation.SearchKnowledgeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_knowledge Override in a subclass to manipulate the request or metadata @@ -361,9 +389,10 @@ def post_search_knowledge( def pre_suggest_conversation_summary( self, request: gcd_conversation.SuggestConversationSummaryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_conversation.SuggestConversationSummaryRequest, Sequence[Tuple[str, str]] + gcd_conversation.SuggestConversationSummaryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for suggest_conversation_summary @@ -386,8 +415,10 @@ def post_suggest_conversation_summary( 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 @@ -409,8 +440,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 @@ -432,8 +465,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -453,8 +488,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -476,8 +513,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -619,7 +658,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]]] = (), ) -> conversation.BatchCreateMessagesResponse: r"""Call the batch create messages method over HTTP. @@ -630,8 +669,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: ~.conversation.BatchCreateMessagesResponse: @@ -643,6 +684,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseBatchCreateMessages._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_messages( request, metadata ) @@ -659,6 +701,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 = 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.dialogflow_v2beta1.ConversationsClient.BatchCreateMessages", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "BatchCreateMessages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._BatchCreateMessages._get_response( self._host, @@ -680,7 +749,31 @@ def __call__( pb_resp = conversation.BatchCreateMessagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_messages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.BatchCreateMessagesResponse.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.dialogflow_v2beta1.ConversationsClient.batch_create_messages", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "BatchCreateMessages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CompleteConversation( @@ -718,7 +811,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]]] = (), ) -> conversation.Conversation: r"""Call the complete conversation method over HTTP. @@ -729,8 +822,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: ~.conversation.Conversation: @@ -747,6 +842,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseCompleteConversation._get_http_options() ) + request, metadata = self._interceptor.pre_complete_conversation( request, metadata ) @@ -763,6 +859,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 = 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.dialogflow_v2beta1.ConversationsClient.CompleteConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "CompleteConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CompleteConversation._get_response( self._host, @@ -784,7 +907,29 @@ def __call__( pb_resp = conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_complete_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.Conversation.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.dialogflow_v2beta1.ConversationsClient.complete_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "CompleteConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversation( @@ -822,7 +967,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]]] = (), ) -> gcd_conversation.Conversation: r"""Call the create conversation method over HTTP. @@ -833,8 +978,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: ~.gcd_conversation.Conversation: @@ -851,6 +998,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseCreateConversation._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversation( request, metadata ) @@ -867,6 +1015,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 = 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.dialogflow_v2beta1.ConversationsClient.CreateConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "CreateConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CreateConversation._get_response( self._host, @@ -888,7 +1063,29 @@ def __call__( pb_resp = gcd_conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_conversation.Conversation.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.dialogflow_v2beta1.ConversationsClient.create_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "CreateConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStatelessSuggestion( @@ -927,7 +1124,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]]] = (), ) -> conversation.GenerateStatelessSuggestionResponse: r"""Call the generate stateless suggestion method over HTTP. @@ -939,8 +1136,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: ~.conversation.GenerateStatelessSuggestionResponse: @@ -952,6 +1151,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGenerateStatelessSuggestion._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stateless_suggestion( request, metadata ) @@ -968,6 +1168,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 = 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.dialogflow_v2beta1.ConversationsClient.GenerateStatelessSuggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GenerateStatelessSuggestion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._GenerateStatelessSuggestion._get_response( @@ -991,7 +1218,33 @@ def __call__( pb_resp = conversation.GenerateStatelessSuggestionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stateless_suggestion(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation.GenerateStatelessSuggestionResponse.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.dialogflow_v2beta1.ConversationsClient.generate_stateless_suggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GenerateStatelessSuggestion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateStatelessSummary( @@ -1030,7 +1283,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]]] = (), ) -> conversation.GenerateStatelessSummaryResponse: r"""Call the generate stateless summary method over HTTP. @@ -1042,8 +1295,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: ~.conversation.GenerateStatelessSummaryResponse: @@ -1055,6 +1310,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGenerateStatelessSummary._get_http_options() ) + request, metadata = self._interceptor.pre_generate_stateless_summary( request, metadata ) @@ -1071,6 +1327,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 = 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.dialogflow_v2beta1.ConversationsClient.GenerateStatelessSummary", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GenerateStatelessSummary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._GenerateStatelessSummary._get_response( @@ -1094,7 +1377,31 @@ def __call__( pb_resp = conversation.GenerateStatelessSummaryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_stateless_summary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + conversation.GenerateStatelessSummaryResponse.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.dialogflow_v2beta1.ConversationsClient.generate_stateless_summary", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GenerateStatelessSummary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversation( @@ -1131,7 +1438,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]]] = (), ) -> conversation.Conversation: r"""Call the get conversation method over HTTP. @@ -1142,8 +1449,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: ~.conversation.Conversation: @@ -1160,6 +1469,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetConversation._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversation( request, metadata ) @@ -1172,6 +1482,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 = 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.dialogflow_v2beta1.ConversationsClient.GetConversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetConversation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetConversation._get_response( self._host, @@ -1192,7 +1529,29 @@ def __call__( pb_resp = conversation.Conversation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.Conversation.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.dialogflow_v2beta1.ConversationsClient.get_conversation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetConversation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversations( @@ -1229,7 +1588,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]]] = (), ) -> conversation.ListConversationsResponse: r"""Call the list conversations method over HTTP. @@ -1240,8 +1599,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: ~.conversation.ListConversationsResponse: @@ -1253,6 +1614,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListConversations._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversations( request, metadata ) @@ -1265,6 +1627,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 = 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.dialogflow_v2beta1.ConversationsClient.ListConversations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListConversations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListConversations._get_response( self._host, @@ -1285,7 +1674,31 @@ def __call__( pb_resp = conversation.ListConversationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.ListConversationsResponse.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.dialogflow_v2beta1.ConversationsClient.list_conversations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListConversations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMessages( @@ -1322,7 +1735,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]]] = (), ) -> conversation.ListMessagesResponse: r"""Call the list messages method over HTTP. @@ -1333,8 +1746,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: ~.conversation.ListMessagesResponse: @@ -1346,6 +1761,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListMessages._get_http_options() ) + request, metadata = self._interceptor.pre_list_messages(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListMessages._get_transcoded_request( http_options, request @@ -1356,6 +1772,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 = 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.dialogflow_v2beta1.ConversationsClient.ListMessages", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListMessages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListMessages._get_response( self._host, @@ -1376,7 +1819,31 @@ def __call__( pb_resp = conversation.ListMessagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_messages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.ListMessagesResponse.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.dialogflow_v2beta1.ConversationsClient.list_messages", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListMessages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchKnowledge( @@ -1414,7 +1881,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]]] = (), ) -> conversation.SearchKnowledgeResponse: r"""Call the search knowledge method over HTTP. @@ -1425,8 +1892,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: ~.conversation.SearchKnowledgeResponse: @@ -1438,6 +1907,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseSearchKnowledge._get_http_options() ) + request, metadata = self._interceptor.pre_search_knowledge( request, metadata ) @@ -1454,6 +1924,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 = 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.dialogflow_v2beta1.ConversationsClient.SearchKnowledge", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "SearchKnowledge", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._SearchKnowledge._get_response( self._host, @@ -1475,7 +1972,31 @@ def __call__( pb_resp = conversation.SearchKnowledgeResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_knowledge(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = conversation.SearchKnowledgeResponse.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.dialogflow_v2beta1.ConversationsClient.search_knowledge", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "SearchKnowledge", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestConversationSummary( @@ -1514,7 +2035,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]]] = (), ) -> gcd_conversation.SuggestConversationSummaryResponse: r"""Call the suggest conversation summary method over HTTP. @@ -1526,8 +2047,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: ~.gcd_conversation.SuggestConversationSummaryResponse: @@ -1539,6 +2062,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseSuggestConversationSummary._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_conversation_summary( request, metadata ) @@ -1555,6 +2079,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 = 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.dialogflow_v2beta1.ConversationsClient.SuggestConversationSummary", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "SuggestConversationSummary", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConversationsRestTransport._SuggestConversationSummary._get_response( @@ -1578,7 +2129,33 @@ def __call__( pb_resp = gcd_conversation.SuggestConversationSummaryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_conversation_summary(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_conversation.SuggestConversationSummaryResponse.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.dialogflow_v2beta1.ConversationsClient.suggest_conversation_summary", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "SuggestConversationSummary", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1721,7 +2298,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. @@ -1731,8 +2308,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. @@ -1741,6 +2320,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1753,6 +2333,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.dialogflow_v2beta1.ConversationsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetLocation._get_response( self._host, @@ -1772,6 +2379,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.dialogflow_v2beta1.ConversationsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1812,7 +2440,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. @@ -1822,8 +2450,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. @@ -1832,6 +2462,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1842,6 +2473,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.dialogflow_v2beta1.ConversationsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListLocations._get_response( self._host, @@ -1861,6 +2519,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.dialogflow_v2beta1.ConversationsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1901,7 +2580,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1911,13 +2590,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 = ( _BaseConversationsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1930,6 +2612,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.dialogflow_v2beta1.ConversationsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._CancelOperation._get_response( self._host, @@ -1985,7 +2694,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1995,8 +2704,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: operations_pb2.Operation: Response from GetOperation method. @@ -2005,6 +2716,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2015,6 +2727,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.dialogflow_v2beta1.ConversationsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._GetOperation._get_response( self._host, @@ -2034,6 +2773,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.ConversationsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2074,7 +2834,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2084,8 +2844,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2094,6 +2856,7 @@ def __call__( http_options = ( _BaseConversationsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseConversationsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2104,6 +2867,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.dialogflow_v2beta1.ConversationsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConversationsRestTransport._ListOperations._get_response( self._host, @@ -2123,6 +2913,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.ConversationsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Conversations", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/async_client.py index af2fdfc043ad..f72cdb39ccbd 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DocumentsTransport from .transports.grpc_asyncio import DocumentsGrpcAsyncIOTransport +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 DocumentsAsyncClient: """Service for managing knowledge @@ -259,6 +269,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.dialogflow_v2beta1.DocumentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "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.dialogflow.v2beta1.Documents", + "credentialsType": None, + }, + ) + async def list_documents( self, request: Optional[Union[document.ListDocumentsRequest, dict]] = None, @@ -266,7 +298,7 @@ async def list_documents( 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.ListDocumentsAsyncPager: r"""Returns the list of all documents of the knowledge base. @@ -315,8 +347,10 @@ async def sample_list_documents(): 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.dialogflow_v2beta1.services.documents.pagers.ListDocumentsAsyncPager: @@ -391,7 +425,7 @@ async def get_document( 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]]] = (), ) -> document.Document: r"""Retrieves the specified document. @@ -438,8 +472,10 @@ async def sample_get_document(): 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.dialogflow_v2beta1.types.Document: @@ -508,7 +544,7 @@ async def create_document( document: Optional[gcd_document.Document] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new document. @@ -582,8 +618,10 @@ async def sample_create_document(): 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.api_core.operation_async.AsyncOperation: @@ -662,7 +700,7 @@ async def import_documents( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Create documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you @@ -724,8 +762,10 @@ async def sample_import_documents(): 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.api_core.operation_async.AsyncOperation: @@ -782,7 +822,7 @@ async def delete_document( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the specified document. @@ -843,8 +883,10 @@ async def sample_delete_document(): 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.api_core.operation_async.AsyncOperation: @@ -924,7 +966,7 @@ async def update_document( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the specified document. @@ -997,8 +1039,10 @@ async def sample_update_document(): 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.api_core.operation_async.AsyncOperation: @@ -1081,7 +1125,7 @@ async def reload_document( gcs_source: Optional[gcs.GcsSource] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the @@ -1159,8 +1203,10 @@ async def sample_reload_document(): 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.api_core.operation_async.AsyncOperation: @@ -1239,7 +1285,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1250,8 +1296,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1292,7 +1340,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1303,8 +1351,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1345,7 +1395,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1360,8 +1410,10 @@ async def cancel_operation( 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: None """ @@ -1398,7 +1450,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. @@ -1409,8 +1461,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. @@ -1451,7 +1505,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. @@ -1462,8 +1516,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-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/client.py index a9156e22856d..c37540d23773 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -587,6 +597,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( @@ -649,6 +663,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.dialogflow_v2beta1.DocumentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "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.dialogflow.v2beta1.Documents", + "credentialsType": None, + }, + ) + def list_documents( self, request: Optional[Union[document.ListDocumentsRequest, dict]] = None, @@ -656,7 +693,7 @@ def list_documents( 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.ListDocumentsPager: r"""Returns the list of all documents of the knowledge base. @@ -705,8 +742,10 @@ def sample_list_documents(): 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.dialogflow_v2beta1.services.documents.pagers.ListDocumentsPager: @@ -778,7 +817,7 @@ def get_document( 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]]] = (), ) -> document.Document: r"""Retrieves the specified document. @@ -825,8 +864,10 @@ def sample_get_document(): 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.dialogflow_v2beta1.types.Document: @@ -892,7 +933,7 @@ def create_document( document: Optional[gcd_document.Document] = 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]]] = (), ) -> operation.Operation: r"""Creates a new document. @@ -966,8 +1007,10 @@ def sample_create_document(): 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.api_core.operation.Operation: @@ -1043,7 +1086,7 @@ def import_documents( *, 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]]] = (), ) -> operation.Operation: r"""Create documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you @@ -1105,8 +1148,10 @@ def sample_import_documents(): 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.api_core.operation.Operation: @@ -1161,7 +1206,7 @@ def delete_document( 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]]] = (), ) -> operation.Operation: r"""Deletes the specified document. @@ -1222,8 +1267,10 @@ def sample_delete_document(): 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.api_core.operation.Operation: @@ -1300,7 +1347,7 @@ def update_document( 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]]] = (), ) -> operation.Operation: r"""Updates the specified document. @@ -1373,8 +1420,10 @@ def sample_update_document(): 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.api_core.operation.Operation: @@ -1454,7 +1503,7 @@ def reload_document( gcs_source: Optional[gcs.GcsSource] = 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]]] = (), ) -> operation.Operation: r"""Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the @@ -1532,8 +1581,10 @@ def sample_reload_document(): 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.api_core.operation.Operation: @@ -1622,7 +1673,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1633,8 +1684,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1675,7 +1728,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1686,8 +1739,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1728,7 +1783,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1743,8 +1798,10 @@ def cancel_operation( 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: None """ @@ -1781,7 +1838,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. @@ -1792,8 +1849,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. @@ -1834,7 +1893,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. @@ -1845,8 +1904,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-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/pagers.py index 56392280de49..10b703891a1e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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 = document.ListDocumentsRequest(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 = document.ListDocumentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py index bbd87ccf6cd0..bfe86c4ee4af 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import document from google.cloud.dialogflow_v2beta1.types import document as gcd_document from .base import DEFAULT_CLIENT_INFO, DocumentsTransport +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.dialogflow.v2beta1.Documents", + "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.dialogflow.v2beta1.Documents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DocumentsGrpcTransport(DocumentsTransport): """gRPC backend transport for Documents. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -275,7 +363,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ListDocuments", request_serializer=document.ListDocumentsRequest.serialize, response_deserializer=document.ListDocumentsResponse.deserialize, @@ -304,7 +392,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/GetDocument", request_serializer=document.GetDocumentRequest.serialize, response_deserializer=document.Document.deserialize, @@ -343,7 +431,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/CreateDocument", request_serializer=gcd_document.CreateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -381,7 +469,7 @@ def import_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_documents" not in self._stubs: - self._stubs["import_documents"] = self.grpc_channel.unary_unary( + self._stubs["import_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ImportDocuments", request_serializer=document.ImportDocumentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -420,7 +508,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/DeleteDocument", request_serializer=document.DeleteDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -459,7 +547,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/UpdateDocument", request_serializer=gcd_document.UpdateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -506,7 +594,7 @@ def reload_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reload_document" not in self._stubs: - self._stubs["reload_document"] = self.grpc_channel.unary_unary( + self._stubs["reload_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ReloadDocument", request_serializer=document.ReloadDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -514,7 +602,7 @@ def reload_document( return self._stubs["reload_document"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -526,7 +614,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -543,7 +631,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -562,7 +650,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -581,7 +669,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, @@ -598,7 +686,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-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py index 244dc9735146..0cd76bc6f3b9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import document from google.cloud.dialogflow_v2beta1.types import document as gcd_document @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, DocumentsTransport from .grpc import DocumentsGrpcTransport +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.dialogflow.v2beta1.Documents", + "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.dialogflow.v2beta1.Documents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DocumentsGrpcAsyncIOTransport(DocumentsTransport): """gRPC AsyncIO backend transport for Documents. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ListDocuments", request_serializer=document.ListDocumentsRequest.serialize, response_deserializer=document.ListDocumentsResponse.deserialize, @@ -316,7 +401,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/GetDocument", request_serializer=document.GetDocumentRequest.serialize, response_deserializer=document.Document.deserialize, @@ -357,7 +442,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/CreateDocument", request_serializer=gcd_document.CreateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def import_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_documents" not in self._stubs: - self._stubs["import_documents"] = self.grpc_channel.unary_unary( + self._stubs["import_documents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ImportDocuments", request_serializer=document.ImportDocumentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -438,7 +523,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/DeleteDocument", request_serializer=document.DeleteDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/UpdateDocument", request_serializer=gcd_document.UpdateDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -528,7 +613,7 @@ def reload_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reload_document" not in self._stubs: - self._stubs["reload_document"] = self.grpc_channel.unary_unary( + self._stubs["reload_document"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Documents/ReloadDocument", request_serializer=document.ReloadDocumentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -606,7 +691,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: @@ -622,7 +707,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -639,7 +724,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -658,7 +743,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -677,7 +762,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, @@ -694,7 +779,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-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py index 0028f3994158..7c7cdb5197dc 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/documents/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 @@ -40,6 +40,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, @@ -128,8 +136,10 @@ def post_update_document(self, response): def pre_create_document( self, request: gcd_document.CreateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_document.CreateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_document.CreateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_document Override in a subclass to manipulate the request or metadata @@ -151,8 +161,8 @@ def post_create_document( def pre_delete_document( self, request: document.DeleteDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.DeleteDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.DeleteDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_document Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_delete_document( return response def pre_get_document( - self, request: document.GetDocumentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[document.GetDocumentRequest, Sequence[Tuple[str, str]]]: + self, + request: document.GetDocumentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.GetDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_document Override in a subclass to manipulate the request or metadata @@ -193,8 +205,10 @@ def post_get_document(self, response: document.Document) -> document.Document: def pre_import_documents( self, request: document.ImportDocumentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ImportDocumentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + document.ImportDocumentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_documents Override in a subclass to manipulate the request or metadata @@ -216,8 +230,8 @@ def post_import_documents( def pre_list_documents( self, request: document.ListDocumentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ListDocumentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.ListDocumentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_documents Override in a subclass to manipulate the request or metadata @@ -239,8 +253,8 @@ def post_list_documents( def pre_reload_document( self, request: document.ReloadDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[document.ReloadDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[document.ReloadDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reload_document Override in a subclass to manipulate the request or metadata @@ -262,8 +276,10 @@ def post_reload_document( def pre_update_document( self, request: gcd_document.UpdateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_document.UpdateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_document.UpdateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_document Override in a subclass to manipulate the request or metadata @@ -285,8 +301,10 @@ def post_update_document( 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 @@ -308,8 +326,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 @@ -331,8 +351,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -352,8 +374,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -375,8 +399,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -577,7 +603,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create document method over HTTP. @@ -588,8 +614,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: ~.operations_pb2.Operation: @@ -602,6 +630,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseCreateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_create_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseCreateDocument._get_transcoded_request( @@ -622,6 +651,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.dialogflow_v2beta1.DocumentsClient.CreateDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "CreateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._CreateDocument._get_response( self._host, @@ -641,7 +697,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_document(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.dialogflow_v2beta1.DocumentsClient.create_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "CreateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDocument( @@ -678,7 +756,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete document method over HTTP. @@ -689,8 +767,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: ~.operations_pb2.Operation: @@ -703,6 +783,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseDeleteDocument._get_http_options() ) + request, metadata = self._interceptor.pre_delete_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseDeleteDocument._get_transcoded_request( @@ -717,6 +798,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.dialogflow_v2beta1.DocumentsClient.DeleteDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "DeleteDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._DeleteDocument._get_response( self._host, @@ -735,7 +843,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_document(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.dialogflow_v2beta1.DocumentsClient.delete_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "DeleteDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDocument(_BaseDocumentsRestTransport._BaseGetDocument, DocumentsRestStub): @@ -770,7 +900,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]]] = (), ) -> document.Document: r"""Call the get document method over HTTP. @@ -781,8 +911,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: ~.document.Document: @@ -801,6 +933,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetDocument._get_http_options() ) + request, metadata = self._interceptor.pre_get_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetDocument._get_transcoded_request( @@ -815,6 +948,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.dialogflow_v2beta1.DocumentsClient.GetDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetDocument._get_response( self._host, @@ -835,7 +995,29 @@ def __call__( pb_resp = document.Document.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = document.Document.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.dialogflow_v2beta1.DocumentsClient.get_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportDocuments( @@ -873,7 +1055,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import documents method over HTTP. @@ -884,8 +1066,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: ~.operations_pb2.Operation: @@ -898,6 +1082,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseImportDocuments._get_http_options() ) + request, metadata = self._interceptor.pre_import_documents( request, metadata ) @@ -918,6 +1103,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.dialogflow_v2beta1.DocumentsClient.ImportDocuments", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ImportDocuments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ImportDocuments._get_response( self._host, @@ -937,7 +1149,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_documents(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.dialogflow_v2beta1.DocumentsClient.import_documents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ImportDocuments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDocuments( @@ -974,7 +1208,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]]] = (), ) -> document.ListDocumentsResponse: r"""Call the list documents method over HTTP. @@ -985,8 +1219,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: ~.document.ListDocumentsResponse: @@ -998,6 +1234,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListDocuments._get_http_options() ) + request, metadata = self._interceptor.pre_list_documents(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListDocuments._get_transcoded_request( @@ -1012,6 +1249,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.dialogflow_v2beta1.DocumentsClient.ListDocuments", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListDocuments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListDocuments._get_response( self._host, @@ -1032,7 +1296,29 @@ def __call__( pb_resp = document.ListDocumentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_documents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = document.ListDocumentsResponse.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.dialogflow_v2beta1.DocumentsClient.list_documents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListDocuments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReloadDocument( @@ -1070,7 +1356,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]]] = (), ) -> operations_pb2.Operation: r"""Call the reload document method over HTTP. @@ -1081,8 +1367,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: ~.operations_pb2.Operation: @@ -1095,6 +1383,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseReloadDocument._get_http_options() ) + request, metadata = self._interceptor.pre_reload_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseReloadDocument._get_transcoded_request( @@ -1115,6 +1404,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.dialogflow_v2beta1.DocumentsClient.ReloadDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ReloadDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ReloadDocument._get_response( self._host, @@ -1134,7 +1450,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reload_document(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.dialogflow_v2beta1.DocumentsClient.reload_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ReloadDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDocument( @@ -1172,7 +1510,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update document method over HTTP. @@ -1183,8 +1521,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: ~.operations_pb2.Operation: @@ -1197,6 +1537,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseUpdateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_update_document(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseUpdateDocument._get_transcoded_request( @@ -1217,6 +1558,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.dialogflow_v2beta1.DocumentsClient.UpdateDocument", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "UpdateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._UpdateDocument._get_response( self._host, @@ -1236,7 +1604,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_document(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.dialogflow_v2beta1.DocumentsClient.update_document", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "UpdateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1331,7 +1721,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. @@ -1341,8 +1731,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. @@ -1351,6 +1743,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1365,6 +1758,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.dialogflow_v2beta1.DocumentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetLocation._get_response( self._host, @@ -1384,6 +1804,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.dialogflow_v2beta1.DocumentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1424,7 +1865,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. @@ -1434,8 +1875,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. @@ -1444,6 +1887,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1458,6 +1902,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.dialogflow_v2beta1.DocumentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListLocations._get_response( self._host, @@ -1477,6 +1948,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.dialogflow_v2beta1.DocumentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1517,7 +2009,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1527,13 +2019,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 = ( _BaseDocumentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1548,6 +2043,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.dialogflow_v2beta1.DocumentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._CancelOperation._get_response( self._host, @@ -1603,7 +2125,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1613,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: operations_pb2.Operation: Response from GetOperation method. @@ -1623,6 +2147,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1637,6 +2162,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.dialogflow_v2beta1.DocumentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._GetOperation._get_response( self._host, @@ -1656,6 +2208,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.DocumentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1696,7 +2269,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1706,8 +2279,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1716,6 +2291,7 @@ def __call__( http_options = ( _BaseDocumentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseDocumentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1730,6 +2306,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.dialogflow_v2beta1.DocumentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DocumentsRestTransport._ListOperations._get_response( self._host, @@ -1749,6 +2352,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.DocumentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Documents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/async_client.py index d290b9aaf5d1..9bc43bad4d4d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport from .transports.grpc_asyncio import EncryptionSpecServiceGrpcAsyncIOTransport +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 EncryptionSpecServiceAsyncClient: """Manages encryption spec settings for Dialogflow and Agent @@ -271,6 +281,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.dialogflow_v2beta1.EncryptionSpecServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "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.dialogflow.v2beta1.EncryptionSpecService", + "credentialsType": None, + }, + ) + async def get_encryption_spec( self, request: Optional[Union[encryption_spec.GetEncryptionSpecRequest, dict]] = None, @@ -278,7 +310,7 @@ async def get_encryption_spec( 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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Gets location-level encryption key specification. @@ -322,8 +354,10 @@ async def sample_get_encryption_spec(): 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.dialogflow_v2beta1.types.EncryptionSpec: @@ -387,7 +421,7 @@ async def initialize_encryption_spec( encryption_spec: Optional[gcd_encryption_spec.EncryptionSpec] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Initializes a location-level encryption key specification. An error will be thrown if the location @@ -448,8 +482,10 @@ async def sample_initialize_encryption_spec(): 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.api_core.operation_async.AsyncOperation: @@ -523,7 +559,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -534,8 +570,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -576,7 +614,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -587,8 +625,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -629,7 +669,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -644,8 +684,10 @@ async def cancel_operation( 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: None """ @@ -682,7 +724,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. @@ -693,8 +735,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. @@ -735,7 +779,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. @@ -746,8 +790,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-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/client.py index a3f6be365713..981a248b573b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -589,6 +599,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( @@ -655,6 +669,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.dialogflow_v2beta1.EncryptionSpecServiceClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "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.dialogflow.v2beta1.EncryptionSpecService", + "credentialsType": None, + }, + ) + def get_encryption_spec( self, request: Optional[Union[encryption_spec.GetEncryptionSpecRequest, dict]] = None, @@ -662,7 +699,7 @@ def get_encryption_spec( 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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Gets location-level encryption key specification. @@ -706,8 +743,10 @@ def sample_get_encryption_spec(): 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.dialogflow_v2beta1.types.EncryptionSpec: @@ -768,7 +807,7 @@ def initialize_encryption_spec( encryption_spec: Optional[gcd_encryption_spec.EncryptionSpec] = 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]]] = (), ) -> operation.Operation: r"""Initializes a location-level encryption key specification. An error will be thrown if the location @@ -829,8 +868,10 @@ def sample_initialize_encryption_spec(): 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.api_core.operation.Operation: @@ -916,7 +957,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -927,8 +968,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -969,7 +1012,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -980,8 +1023,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1022,7 +1067,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1037,8 +1082,10 @@ def cancel_operation( 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: None """ @@ -1075,7 +1122,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. @@ -1086,8 +1133,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. @@ -1128,7 +1177,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. @@ -1139,8 +1188,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-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc.py index d539538ed51b..103bfde3e117 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import encryption_spec as gcd_encryption_spec from google.cloud.dialogflow_v2beta1.types import encryption_spec from .base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport +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.dialogflow.v2beta1.EncryptionSpecService", + "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.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EncryptionSpecServiceGrpcTransport(EncryptionSpecServiceTransport): """gRPC backend transport for EncryptionSpecService. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def get_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_encryption_spec" not in self._stubs: - self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_encryption_spec"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EncryptionSpecService/GetEncryptionSpec", request_serializer=encryption_spec.GetEncryptionSpecRequest.serialize, response_deserializer=encryption_spec.EncryptionSpec.deserialize, @@ -308,7 +396,9 @@ def initialize_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "initialize_encryption_spec" not in self._stubs: - self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs[ + "initialize_encryption_spec" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EncryptionSpecService/InitializeEncryptionSpec", request_serializer=gcd_encryption_spec.InitializeEncryptionSpecRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -316,7 +406,7 @@ def initialize_encryption_spec( return self._stubs["initialize_encryption_spec"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -328,7 +418,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -345,7 +435,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -364,7 +454,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -383,7 +473,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, @@ -400,7 +490,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-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc_asyncio.py index d4a66fef79fc..66be9c1c8c99 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import encryption_spec as gcd_encryption_spec from google.cloud.dialogflow_v2beta1.types import encryption_spec @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, EncryptionSpecServiceTransport from .grpc import EncryptionSpecServiceGrpcTransport +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.dialogflow.v2beta1.EncryptionSpecService", + "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.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EncryptionSpecServiceGrpcAsyncIOTransport(EncryptionSpecServiceTransport): """gRPC AsyncIO backend transport for EncryptionSpecService. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -285,7 +370,7 @@ def get_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_encryption_spec" not in self._stubs: - self._stubs["get_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_encryption_spec"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EncryptionSpecService/GetEncryptionSpec", request_serializer=encryption_spec.GetEncryptionSpecRequest.serialize, response_deserializer=encryption_spec.EncryptionSpec.deserialize, @@ -320,7 +405,9 @@ def initialize_encryption_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "initialize_encryption_spec" not in self._stubs: - self._stubs["initialize_encryption_spec"] = self.grpc_channel.unary_unary( + self._stubs[ + "initialize_encryption_spec" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EncryptionSpecService/InitializeEncryptionSpec", request_serializer=gcd_encryption_spec.InitializeEncryptionSpecRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +460,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: @@ -389,7 +476,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -406,7 +493,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -425,7 +512,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -444,7 +531,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, @@ -461,7 +548,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-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/rest.py index 37312f0a99c6..f0c753f22b1f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/encryption_spec_service/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 @@ -40,6 +40,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, @@ -88,8 +96,11 @@ def post_initialize_encryption_spec(self, response): def pre_get_encryption_spec( self, request: encryption_spec.GetEncryptionSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[encryption_spec.GetEncryptionSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + encryption_spec.GetEncryptionSpecRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_encryption_spec Override in a subclass to manipulate the request or metadata @@ -111,9 +122,10 @@ def post_get_encryption_spec( def pre_initialize_encryption_spec( self, request: gcd_encryption_spec.InitializeEncryptionSpecRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_encryption_spec.InitializeEncryptionSpecRequest, Sequence[Tuple[str, str]] + gcd_encryption_spec.InitializeEncryptionSpecRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for initialize_encryption_spec @@ -136,8 +148,10 @@ def post_initialize_encryption_spec( 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 @@ -159,8 +173,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 @@ -182,8 +198,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -203,8 +221,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -226,8 +246,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -428,7 +450,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]]] = (), ) -> encryption_spec.EncryptionSpec: r"""Call the get encryption spec method over HTTP. @@ -439,8 +461,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: ~.encryption_spec.EncryptionSpec: @@ -453,6 +477,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetEncryptionSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_encryption_spec( request, metadata ) @@ -465,6 +490,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 = 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.dialogflow_v2beta1.EncryptionSpecServiceClient.GetEncryptionSpec", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetEncryptionSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EncryptionSpecServiceRestTransport._GetEncryptionSpec._get_response( @@ -487,7 +539,29 @@ def __call__( pb_resp = encryption_spec.EncryptionSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_encryption_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = encryption_spec.EncryptionSpec.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.dialogflow_v2beta1.EncryptionSpecServiceClient.get_encryption_spec", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetEncryptionSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InitializeEncryptionSpec( @@ -526,7 +600,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]]] = (), ) -> operations_pb2.Operation: r"""Call the initialize encryption spec method over HTTP. @@ -538,8 +612,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: ~.operations_pb2.Operation: @@ -552,6 +628,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseInitializeEncryptionSpec._get_http_options() ) + request, metadata = self._interceptor.pre_initialize_encryption_spec( request, metadata ) @@ -568,6 +645,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.dialogflow_v2beta1.EncryptionSpecServiceClient.InitializeEncryptionSpec", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "InitializeEncryptionSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._InitializeEncryptionSpec._get_response( self._host, @@ -587,7 +691,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_initialize_encryption_spec(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.dialogflow_v2beta1.EncryptionSpecServiceClient.initialize_encryption_spec", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "InitializeEncryptionSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -649,7 +775,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. @@ -659,8 +785,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. @@ -669,6 +797,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -679,6 +808,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.dialogflow_v2beta1.EncryptionSpecServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._GetLocation._get_response( self._host, @@ -698,6 +854,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.dialogflow_v2beta1.EncryptionSpecServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -739,7 +916,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. @@ -749,8 +926,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. @@ -759,6 +938,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -769,6 +949,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.dialogflow_v2beta1.EncryptionSpecServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._ListLocations._get_response( self._host, @@ -788,6 +995,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.dialogflow_v2beta1.EncryptionSpecServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -829,7 +1057,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -839,13 +1067,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 = ( _BaseEncryptionSpecServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -858,6 +1089,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.dialogflow_v2beta1.EncryptionSpecServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EncryptionSpecServiceRestTransport._CancelOperation._get_response( @@ -916,7 +1174,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -926,8 +1184,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: operations_pb2.Operation: Response from GetOperation method. @@ -936,6 +1196,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -946,6 +1207,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.dialogflow_v2beta1.EncryptionSpecServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._GetOperation._get_response( self._host, @@ -965,6 +1253,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.EncryptionSpecServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1006,7 +1315,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1016,8 +1325,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1026,6 +1337,7 @@ def __call__( http_options = ( _BaseEncryptionSpecServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEncryptionSpecServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1036,6 +1348,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.dialogflow_v2beta1.EncryptionSpecServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EncryptionSpecServiceRestTransport._ListOperations._get_response( self._host, @@ -1055,6 +1394,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.EncryptionSpecServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EncryptionSpecService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py index 012c6f576091..5f76c7a0ae8c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EntityTypesTransport from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport +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 EntityTypesAsyncClient: """Service for managing @@ -261,6 +271,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.dialogflow_v2beta1.EntityTypesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "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.dialogflow.v2beta1.EntityTypes", + "credentialsType": None, + }, + ) + async def list_entity_types( self, request: Optional[Union[entity_type.ListEntityTypesRequest, dict]] = None, @@ -269,7 +301,7 @@ async def list_entity_types( language_code: 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.ListEntityTypesAsyncPager: r"""Returns the list of all entity types in the specified agent. @@ -328,8 +360,10 @@ async def sample_list_entity_types(): 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.dialogflow_v2beta1.services.entity_types.pagers.ListEntityTypesAsyncPager: @@ -407,7 +441,7 @@ async def get_entity_type( language_code: 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]]] = (), ) -> entity_type.EntityType: r"""Retrieves the specified entity type. @@ -464,8 +498,10 @@ async def sample_get_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -543,7 +579,7 @@ async def create_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Creates an entity type in the specified agent. @@ -614,8 +650,10 @@ async def sample_create_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -695,7 +733,7 @@ async def update_entity_type( 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Updates the specified entity type. @@ -762,8 +800,10 @@ async def sample_update_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -843,7 +883,7 @@ async def delete_entity_type( 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 the specified entity type. @@ -891,8 +931,10 @@ async def sample_delete_entity_type(): 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 @@ -945,7 +987,7 @@ async def batch_update_entity_types( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates/Creates multiple entity types in the specified agent. @@ -1001,8 +1043,10 @@ async def sample_batch_update_entity_types(): 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.api_core.operation_async.AsyncOperation: @@ -1062,7 +1106,7 @@ async def batch_delete_entity_types( entity_type_names: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes entity types in the specified agent. @@ -1135,8 +1179,10 @@ async def sample_batch_delete_entity_types(): 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.api_core.operation_async.AsyncOperation: @@ -1219,7 +1265,7 @@ async def batch_create_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates multiple new entities in the specified entity type. @@ -1303,8 +1349,10 @@ async def sample_batch_create_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1389,7 +1437,7 @@ async def batch_update_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates or creates multiple entities in the specified entity type. This method does not affect entities in the entity type @@ -1477,8 +1525,10 @@ async def sample_batch_update_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1563,7 +1613,7 @@ async def batch_delete_entities( language_code: 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes entities in the specified entity type. @@ -1647,8 +1697,10 @@ async def sample_batch_delete_entities(): 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.api_core.operation_async.AsyncOperation: @@ -1730,7 +1782,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1741,8 +1793,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1783,7 +1837,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1794,8 +1848,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1836,7 +1892,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1851,8 +1907,10 @@ async def cancel_operation( 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: None """ @@ -1889,7 +1947,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. @@ -1900,8 +1958,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. @@ -1942,7 +2002,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. @@ -1953,8 +2013,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-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/client.py index c72b6070c99b..10d4e67c7fe7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -584,6 +594,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( @@ -646,6 +660,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.dialogflow_v2beta1.EntityTypesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "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.dialogflow.v2beta1.EntityTypes", + "credentialsType": None, + }, + ) + def list_entity_types( self, request: Optional[Union[entity_type.ListEntityTypesRequest, dict]] = None, @@ -654,7 +691,7 @@ def list_entity_types( language_code: 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.ListEntityTypesPager: r"""Returns the list of all entity types in the specified agent. @@ -713,8 +750,10 @@ def sample_list_entity_types(): 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.dialogflow_v2beta1.services.entity_types.pagers.ListEntityTypesPager: @@ -789,7 +828,7 @@ def get_entity_type( language_code: 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]]] = (), ) -> entity_type.EntityType: r"""Retrieves the specified entity type. @@ -846,8 +885,10 @@ def sample_get_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -922,7 +963,7 @@ def create_entity_type( language_code: 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Creates an entity type in the specified agent. @@ -993,8 +1034,10 @@ def sample_create_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -1071,7 +1114,7 @@ def update_entity_type( 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]]] = (), ) -> gcd_entity_type.EntityType: r"""Updates the specified entity type. @@ -1138,8 +1181,10 @@ def sample_update_entity_type(): 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.dialogflow_v2beta1.types.EntityType: @@ -1216,7 +1261,7 @@ def delete_entity_type( 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 the specified entity type. @@ -1264,8 +1309,10 @@ def sample_delete_entity_type(): 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 @@ -1315,7 +1362,7 @@ def batch_update_entity_types( *, 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]]] = (), ) -> operation.Operation: r"""Updates/Creates multiple entity types in the specified agent. @@ -1371,8 +1418,10 @@ def sample_batch_update_entity_types(): 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.api_core.operation.Operation: @@ -1432,7 +1481,7 @@ def batch_delete_entity_types( entity_type_names: 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]]] = (), ) -> operation.Operation: r"""Deletes entity types in the specified agent. @@ -1505,8 +1554,10 @@ def sample_batch_delete_entity_types(): 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.api_core.operation.Operation: @@ -1588,7 +1639,7 @@ def batch_create_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Creates multiple new entities in the specified entity type. @@ -1672,8 +1723,10 @@ def sample_batch_create_entities(): 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.api_core.operation.Operation: @@ -1755,7 +1808,7 @@ def batch_update_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Updates or creates multiple entities in the specified entity type. This method does not affect entities in the entity type @@ -1843,8 +1896,10 @@ def sample_batch_update_entities(): 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.api_core.operation.Operation: @@ -1926,7 +1981,7 @@ def batch_delete_entities( language_code: 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]]] = (), ) -> operation.Operation: r"""Deletes entities in the specified entity type. @@ -2010,8 +2065,10 @@ def sample_batch_delete_entities(): 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.api_core.operation.Operation: @@ -2103,7 +2160,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2114,8 +2171,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2156,7 +2215,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2167,8 +2226,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2209,7 +2270,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2224,8 +2285,10 @@ def cancel_operation( 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: None """ @@ -2262,7 +2325,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. @@ -2273,8 +2336,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. @@ -2315,7 +2380,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. @@ -2326,8 +2391,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-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/pagers.py index e5727ee3e861..d32ccc908f93 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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 = entity_type.ListEntityTypesRequest(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 = entity_type.ListEntityTypesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py index f63da2491cd7..e2ff4e01a2d2 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import entity_type as gcd_entity_type from google.cloud.dialogflow_v2beta1.types import entity_type from .base import DEFAULT_CLIENT_INFO, EntityTypesTransport +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.dialogflow.v2beta1.EntityTypes", + "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.dialogflow.v2beta1.EntityTypes", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EntityTypesGrpcTransport(EntityTypesTransport): """gRPC backend transport for EntityTypes. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def list_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entity_types" not in self._stubs: - self._stubs["list_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/ListEntityTypes", request_serializer=entity_type.ListEntityTypesRequest.serialize, response_deserializer=entity_type.ListEntityTypesResponse.deserialize, @@ -302,7 +390,7 @@ def get_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entity_type" not in self._stubs: - self._stubs["get_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/GetEntityType", request_serializer=entity_type.GetEntityTypeRequest.serialize, response_deserializer=entity_type.EntityType.deserialize, @@ -334,7 +422,7 @@ def create_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entity_type" not in self._stubs: - self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["create_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/CreateEntityType", request_serializer=gcd_entity_type.CreateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -366,7 +454,7 @@ def update_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entity_type" not in self._stubs: - self._stubs["update_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["update_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/UpdateEntityType", request_serializer=gcd_entity_type.UpdateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -396,7 +484,7 @@ def delete_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entity_type" not in self._stubs: - self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["delete_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/DeleteEntityType", request_serializer=entity_type.DeleteEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -438,7 +526,7 @@ def batch_update_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entity_types" not in self._stubs: - self._stubs["batch_update_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntityTypes", request_serializer=entity_type.BatchUpdateEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -480,7 +568,7 @@ def batch_delete_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entity_types" not in self._stubs: - self._stubs["batch_delete_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntityTypes", request_serializer=entity_type.BatchDeleteEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def batch_create_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_entities" not in self._stubs: - self._stubs["batch_create_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchCreateEntities", request_serializer=entity_type.BatchCreateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -562,7 +650,7 @@ def batch_update_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entities" not in self._stubs: - self._stubs["batch_update_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntities", request_serializer=entity_type.BatchUpdateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +690,7 @@ def batch_delete_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entities" not in self._stubs: - self._stubs["batch_delete_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntities", request_serializer=entity_type.BatchDeleteEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +698,7 @@ def batch_delete_entities( return self._stubs["batch_delete_entities"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -622,7 +710,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -639,7 +727,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -658,7 +746,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -677,7 +765,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, @@ -694,7 +782,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-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py index ce1c613e7357..029cb37ca68c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import entity_type as gcd_entity_type from google.cloud.dialogflow_v2beta1.types import entity_type @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, EntityTypesTransport from .grpc import EntityTypesGrpcTransport +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.dialogflow.v2beta1.EntityTypes", + "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.dialogflow.v2beta1.EntityTypes", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EntityTypesGrpcAsyncIOTransport(EntityTypesTransport): """gRPC AsyncIO backend transport for EntityTypes. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -287,7 +372,7 @@ def list_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_entity_types" not in self._stubs: - self._stubs["list_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/ListEntityTypes", request_serializer=entity_type.ListEntityTypesRequest.serialize, response_deserializer=entity_type.ListEntityTypesResponse.deserialize, @@ -315,7 +400,7 @@ def get_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_entity_type" not in self._stubs: - self._stubs["get_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/GetEntityType", request_serializer=entity_type.GetEntityTypeRequest.serialize, response_deserializer=entity_type.EntityType.deserialize, @@ -347,7 +432,7 @@ def create_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_entity_type" not in self._stubs: - self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["create_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/CreateEntityType", request_serializer=gcd_entity_type.CreateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -379,7 +464,7 @@ def update_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_entity_type" not in self._stubs: - self._stubs["update_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["update_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/UpdateEntityType", request_serializer=gcd_entity_type.UpdateEntityTypeRequest.serialize, response_deserializer=gcd_entity_type.EntityType.deserialize, @@ -409,7 +494,7 @@ def delete_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_entity_type" not in self._stubs: - self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["delete_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/DeleteEntityType", request_serializer=entity_type.DeleteEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -451,7 +536,7 @@ def batch_update_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entity_types" not in self._stubs: - self._stubs["batch_update_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntityTypes", request_serializer=entity_type.BatchUpdateEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -493,7 +578,7 @@ def batch_delete_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entity_types" not in self._stubs: - self._stubs["batch_delete_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntityTypes", request_serializer=entity_type.BatchDeleteEntityTypesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +620,7 @@ def batch_create_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_entities" not in self._stubs: - self._stubs["batch_create_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchCreateEntities", request_serializer=entity_type.BatchCreateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -579,7 +664,7 @@ def batch_update_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_entities" not in self._stubs: - self._stubs["batch_update_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchUpdateEntities", request_serializer=entity_type.BatchUpdateEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -621,7 +706,7 @@ def batch_delete_entities( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_entities" not in self._stubs: - self._stubs["batch_delete_entities"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_entities"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.EntityTypes/BatchDeleteEntities", request_serializer=entity_type.BatchDeleteEntitiesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -714,7 +799,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: @@ -730,7 +815,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -747,7 +832,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -766,7 +851,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -785,7 +870,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, @@ -802,7 +887,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-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py index ec2561182637..c1ce60c97a4b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/entity_types/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 @@ -41,6 +41,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, @@ -149,8 +157,10 @@ def post_update_entity_type(self, response): def pre_batch_create_entities( self, request: entity_type.BatchCreateEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchCreateEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchCreateEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_entities Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_batch_create_entities( def pre_batch_delete_entities( self, request: entity_type.BatchDeleteEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchDeleteEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchDeleteEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_entities Override in a subclass to manipulate the request or metadata @@ -195,8 +207,11 @@ def post_batch_delete_entities( def pre_batch_delete_entity_types( self, request: entity_type.BatchDeleteEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchDeleteEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchDeleteEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_delete_entity_types Override in a subclass to manipulate the request or metadata @@ -218,8 +233,10 @@ def post_batch_delete_entity_types( def pre_batch_update_entities( self, request: entity_type.BatchUpdateEntitiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchUpdateEntitiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchUpdateEntitiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_entities Override in a subclass to manipulate the request or metadata @@ -241,8 +258,11 @@ def post_batch_update_entities( def pre_batch_update_entity_types( self, request: entity_type.BatchUpdateEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.BatchUpdateEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.BatchUpdateEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_update_entity_types Override in a subclass to manipulate the request or metadata @@ -264,8 +284,10 @@ def post_batch_update_entity_types( def pre_create_entity_type( self, request: gcd_entity_type.CreateEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_entity_type.CreateEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_entity_type.CreateEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_entity_type Override in a subclass to manipulate the request or metadata @@ -287,8 +309,10 @@ def post_create_entity_type( def pre_delete_entity_type( self, request: entity_type.DeleteEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.DeleteEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.DeleteEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_entity_type Override in a subclass to manipulate the request or metadata @@ -299,8 +323,10 @@ def pre_delete_entity_type( def pre_get_entity_type( self, request: entity_type.GetEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.GetEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.GetEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_entity_type Override in a subclass to manipulate the request or metadata @@ -322,8 +348,10 @@ def post_get_entity_type( def pre_list_entity_types( self, request: entity_type.ListEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[entity_type.ListEntityTypesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + entity_type.ListEntityTypesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_entity_types Override in a subclass to manipulate the request or metadata @@ -345,8 +373,10 @@ def post_list_entity_types( def pre_update_entity_type( self, request: gcd_entity_type.UpdateEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_entity_type.UpdateEntityTypeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_entity_type.UpdateEntityTypeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_entity_type Override in a subclass to manipulate the request or metadata @@ -368,8 +398,10 @@ def post_update_entity_type( 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 @@ -391,8 +423,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 @@ -414,8 +448,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -435,8 +471,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -458,8 +496,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -660,7 +700,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create entities method over HTTP. @@ -671,8 +711,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: ~.operations_pb2.Operation: @@ -685,6 +727,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchCreateEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_entities( request, metadata ) @@ -701,6 +744,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.dialogflow_v2beta1.EntityTypesClient.BatchCreateEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchCreateEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchCreateEntities._get_response( self._host, @@ -720,7 +790,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_entities(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.dialogflow_v2beta1.EntityTypesClient.batch_create_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchCreateEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteEntities( @@ -758,7 +850,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete entities method over HTTP. @@ -769,8 +861,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: ~.operations_pb2.Operation: @@ -783,6 +877,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchDeleteEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_entities( request, metadata ) @@ -799,6 +894,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.dialogflow_v2beta1.EntityTypesClient.BatchDeleteEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchDeleteEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchDeleteEntities._get_response( self._host, @@ -818,7 +940,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_entities(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.dialogflow_v2beta1.EntityTypesClient.batch_delete_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchDeleteEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteEntityTypes( @@ -856,7 +1000,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete entity types method over HTTP. @@ -867,8 +1011,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: ~.operations_pb2.Operation: @@ -881,6 +1027,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchDeleteEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_entity_types( request, metadata ) @@ -897,6 +1044,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.dialogflow_v2beta1.EntityTypesClient.BatchDeleteEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchDeleteEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchDeleteEntityTypes._get_response( self._host, @@ -916,7 +1090,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_entity_types(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.dialogflow_v2beta1.EntityTypesClient.batch_delete_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchDeleteEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateEntities( @@ -954,7 +1150,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update entities method over HTTP. @@ -965,8 +1161,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: ~.operations_pb2.Operation: @@ -979,6 +1177,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchUpdateEntities._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_entities( request, metadata ) @@ -995,6 +1194,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.dialogflow_v2beta1.EntityTypesClient.BatchUpdateEntities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchUpdateEntities", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchUpdateEntities._get_response( self._host, @@ -1014,7 +1240,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_entities(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.dialogflow_v2beta1.EntityTypesClient.batch_update_entities", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchUpdateEntities", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateEntityTypes( @@ -1052,7 +1300,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update entity types method over HTTP. @@ -1063,8 +1311,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: ~.operations_pb2.Operation: @@ -1077,6 +1327,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseBatchUpdateEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_entity_types( request, metadata ) @@ -1093,6 +1344,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.dialogflow_v2beta1.EntityTypesClient.BatchUpdateEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchUpdateEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._BatchUpdateEntityTypes._get_response( self._host, @@ -1112,7 +1390,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_entity_types(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.dialogflow_v2beta1.EntityTypesClient.batch_update_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "BatchUpdateEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEntityType( @@ -1150,7 +1450,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]]] = (), ) -> gcd_entity_type.EntityType: r"""Call the create entity type method over HTTP. @@ -1161,8 +1461,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: ~.gcd_entity_type.EntityType: @@ -1187,6 +1489,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseCreateEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_create_entity_type( request, metadata ) @@ -1203,6 +1506,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 = 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.dialogflow_v2beta1.EntityTypesClient.CreateEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "CreateEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._CreateEntityType._get_response( self._host, @@ -1224,7 +1554,29 @@ def __call__( pb_resp = gcd_entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_entity_type.EntityType.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.dialogflow_v2beta1.EntityTypesClient.create_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "CreateEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEntityType( @@ -1261,7 +1613,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 entity type method over HTTP. @@ -1272,13 +1624,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 = ( _BaseEntityTypesRestTransport._BaseDeleteEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_delete_entity_type( request, metadata ) @@ -1291,6 +1646,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.dialogflow_v2beta1.EntityTypesClient.DeleteEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "DeleteEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._DeleteEntityType._get_response( self._host, @@ -1340,7 +1722,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]]] = (), ) -> entity_type.EntityType: r"""Call the get entity type method over HTTP. @@ -1351,8 +1733,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: ~.entity_type.EntityType: @@ -1377,6 +1761,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_get_entity_type(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseGetEntityType._get_transcoded_request( http_options, request @@ -1389,6 +1774,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.dialogflow_v2beta1.EntityTypesClient.GetEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetEntityType._get_response( self._host, @@ -1409,7 +1821,29 @@ def __call__( pb_resp = entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_type.EntityType.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.dialogflow_v2beta1.EntityTypesClient.get_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEntityTypes( @@ -1446,7 +1880,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]]] = (), ) -> entity_type.ListEntityTypesResponse: r"""Call the list entity types method over HTTP. @@ -1457,8 +1891,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: ~.entity_type.ListEntityTypesResponse: @@ -1470,6 +1906,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_entity_types( request, metadata ) @@ -1482,6 +1919,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 = 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.dialogflow_v2beta1.EntityTypesClient.ListEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListEntityTypes._get_response( self._host, @@ -1502,7 +1966,31 @@ def __call__( pb_resp = entity_type.ListEntityTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_entity_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_type.ListEntityTypesResponse.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.dialogflow_v2beta1.EntityTypesClient.list_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEntityType( @@ -1540,7 +2028,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]]] = (), ) -> gcd_entity_type.EntityType: r"""Call the update entity type method over HTTP. @@ -1551,8 +2039,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: ~.gcd_entity_type.EntityType: @@ -1577,6 +2067,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseUpdateEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_update_entity_type( request, metadata ) @@ -1593,6 +2084,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 = 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.dialogflow_v2beta1.EntityTypesClient.UpdateEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "UpdateEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._UpdateEntityType._get_response( self._host, @@ -1614,7 +2132,29 @@ def __call__( pb_resp = gcd_entity_type.EntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_entity_type.EntityType.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.dialogflow_v2beta1.EntityTypesClient.update_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "UpdateEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1745,7 +2285,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. @@ -1755,8 +2295,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. @@ -1765,6 +2307,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseEntityTypesRestTransport._BaseGetLocation._get_transcoded_request( @@ -1779,6 +2322,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.dialogflow_v2beta1.EntityTypesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetLocation._get_response( self._host, @@ -1798,6 +2368,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.dialogflow_v2beta1.EntityTypesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1838,7 +2429,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. @@ -1848,8 +2439,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. @@ -1858,6 +2451,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1870,6 +2464,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.dialogflow_v2beta1.EntityTypesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListLocations._get_response( self._host, @@ -1889,6 +2510,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.dialogflow_v2beta1.EntityTypesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1929,7 +2571,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1939,13 +2581,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 = ( _BaseEntityTypesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1958,6 +2603,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.dialogflow_v2beta1.EntityTypesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._CancelOperation._get_response( self._host, @@ -2013,7 +2685,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2023,8 +2695,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: operations_pb2.Operation: Response from GetOperation method. @@ -2033,6 +2707,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseEntityTypesRestTransport._BaseGetOperation._get_transcoded_request( @@ -2047,6 +2722,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.dialogflow_v2beta1.EntityTypesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._GetOperation._get_response( self._host, @@ -2066,6 +2768,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.EntityTypesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2106,7 +2829,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2116,8 +2839,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2126,6 +2851,7 @@ def __call__( http_options = ( _BaseEntityTypesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEntityTypesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2136,6 +2862,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.dialogflow_v2beta1.EntityTypesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntityTypesRestTransport._ListOperations._get_response( self._host, @@ -2155,6 +2908,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.EntityTypesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.EntityTypes", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/async_client.py index 38717d2ab829..be71b756065c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport +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 EnvironmentsAsyncClient: """Service for managing @@ -260,6 +270,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.dialogflow_v2beta1.EnvironmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "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.dialogflow.v2beta1.Environments", + "credentialsType": None, + }, + ) + async def list_environments( self, request: Optional[Union[environment.ListEnvironmentsRequest, dict]] = None, @@ -267,7 +299,7 @@ async def list_environments( 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.ListEnvironmentsAsyncPager: r"""Returns the list of all non-draft environments of the specified agent. @@ -316,8 +348,10 @@ async def sample_list_environments(): 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.dialogflow_v2beta1.services.environments.pagers.ListEnvironmentsAsyncPager: @@ -391,7 +425,7 @@ async def get_environment( *, 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]]] = (), ) -> environment.Environment: r"""Retrieves the specified agent environment. @@ -428,8 +462,10 @@ async def sample_get_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -494,7 +530,7 @@ async def create_environment( *, 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]]] = (), ) -> environment.Environment: r"""Creates an agent environment. @@ -532,8 +568,10 @@ async def sample_create_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -598,7 +636,7 @@ async def update_environment( *, 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]]] = (), ) -> environment.Environment: r"""Updates the specified agent environment. @@ -646,8 +684,10 @@ async def sample_update_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -714,7 +754,7 @@ async def delete_environment( *, 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 the specified agent environment. @@ -748,8 +788,10 @@ async def sample_delete_environment(): 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 @@ -786,7 +828,7 @@ async def get_environment_history( *, 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.GetEnvironmentHistoryAsyncPager: r"""Gets the history of the specified environment. @@ -824,8 +866,10 @@ async def sample_get_environment_history(): 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.dialogflow_v2beta1.services.environments.pagers.GetEnvironmentHistoryAsyncPager: @@ -885,7 +929,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -896,8 +940,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -938,7 +984,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -949,8 +995,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -991,7 +1039,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1006,8 +1054,10 @@ async def cancel_operation( 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: None """ @@ -1044,7 +1094,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. @@ -1055,8 +1105,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. @@ -1097,7 +1149,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. @@ -1108,8 +1160,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-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/client.py index 36074b753786..88995506e78c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -613,6 +623,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( @@ -675,6 +689,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.dialogflow_v2beta1.EnvironmentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "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.dialogflow.v2beta1.Environments", + "credentialsType": None, + }, + ) + def list_environments( self, request: Optional[Union[environment.ListEnvironmentsRequest, dict]] = None, @@ -682,7 +719,7 @@ def list_environments( 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.ListEnvironmentsPager: r"""Returns the list of all non-draft environments of the specified agent. @@ -731,8 +768,10 @@ def sample_list_environments(): 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.dialogflow_v2beta1.services.environments.pagers.ListEnvironmentsPager: @@ -803,7 +842,7 @@ def get_environment( *, 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]]] = (), ) -> environment.Environment: r"""Retrieves the specified agent environment. @@ -840,8 +879,10 @@ def sample_get_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -904,7 +945,7 @@ def create_environment( *, 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]]] = (), ) -> environment.Environment: r"""Creates an agent environment. @@ -942,8 +983,10 @@ def sample_create_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -1006,7 +1049,7 @@ def update_environment( *, 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]]] = (), ) -> environment.Environment: r"""Updates the specified agent environment. @@ -1054,8 +1097,10 @@ def sample_update_environment(): 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.dialogflow_v2beta1.types.Environment: @@ -1120,7 +1165,7 @@ def delete_environment( *, 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 the specified agent environment. @@ -1154,8 +1199,10 @@ def sample_delete_environment(): 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 @@ -1190,7 +1237,7 @@ def get_environment_history( *, 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.GetEnvironmentHistoryPager: r"""Gets the history of the specified environment. @@ -1228,8 +1275,10 @@ def sample_get_environment_history(): 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.dialogflow_v2beta1.services.environments.pagers.GetEnvironmentHistoryPager: @@ -1300,7 +1349,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1311,8 +1360,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1353,7 +1404,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1364,8 +1415,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1406,7 +1459,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1421,8 +1474,10 @@ def cancel_operation( 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: None """ @@ -1459,7 +1514,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. @@ -1470,8 +1525,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. @@ -1512,7 +1569,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. @@ -1523,8 +1580,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-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/pagers.py index 958b1a5b1bb3..b58d6596c778 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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 = environment.ListEnvironmentsRequest(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 = environment.ListEnvironmentsRequest(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 = environment.GetEnvironmentHistoryRequest(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 = environment.GetEnvironmentHistoryRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py index 094f957f743f..8c06703833c6 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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 @@ -23,12 +26,90 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import environment from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport +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.dialogflow.v2beta1.Environments", + "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.dialogflow.v2beta1.Environments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcTransport(EnvironmentsTransport): """gRPC backend transport for Environments. @@ -183,7 +264,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 @@ -260,7 +346,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/ListEnvironments", request_serializer=environment.ListEnvironmentsRequest.serialize, response_deserializer=environment.ListEnvironmentsResponse.deserialize, @@ -286,7 +372,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/GetEnvironment", request_serializer=environment.GetEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -312,7 +398,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/CreateEnvironment", request_serializer=environment.CreateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -350,7 +436,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/UpdateEnvironment", request_serializer=environment.UpdateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -376,7 +462,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/DeleteEnvironment", request_serializer=environment.DeleteEnvironmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -404,7 +490,7 @@ def get_environment_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment_history" not in self._stubs: - self._stubs["get_environment_history"] = self.grpc_channel.unary_unary( + self._stubs["get_environment_history"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/GetEnvironmentHistory", request_serializer=environment.GetEnvironmentHistoryRequest.serialize, response_deserializer=environment.EnvironmentHistory.deserialize, @@ -412,7 +498,7 @@ def get_environment_history( return self._stubs["get_environment_history"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -424,7 +510,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -441,7 +527,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +546,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -479,7 +565,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, @@ -496,7 +582,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-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py index 85d9827bf316..5ab5009e960e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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 @@ -25,14 +28,93 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import environment from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .grpc import EnvironmentsGrpcTransport +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.dialogflow.v2beta1.Environments", + "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.dialogflow.v2beta1.Environments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport): """gRPC AsyncIO backend transport for Environments. @@ -230,10 +312,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 @@ -269,7 +354,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/ListEnvironments", request_serializer=environment.ListEnvironmentsRequest.serialize, response_deserializer=environment.ListEnvironmentsResponse.deserialize, @@ -297,7 +382,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/GetEnvironment", request_serializer=environment.GetEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -325,7 +410,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/CreateEnvironment", request_serializer=environment.CreateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -365,7 +450,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/UpdateEnvironment", request_serializer=environment.UpdateEnvironmentRequest.serialize, response_deserializer=environment.Environment.deserialize, @@ -391,7 +476,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/DeleteEnvironment", request_serializer=environment.DeleteEnvironmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -420,7 +505,7 @@ def get_environment_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment_history" not in self._stubs: - self._stubs["get_environment_history"] = self.grpc_channel.unary_unary( + self._stubs["get_environment_history"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Environments/GetEnvironmentHistory", request_serializer=environment.GetEnvironmentHistoryRequest.serialize, response_deserializer=environment.EnvironmentHistory.deserialize, @@ -493,7 +578,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: @@ -509,7 +594,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -526,7 +611,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -545,7 +630,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -564,7 +649,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, @@ -581,7 +666,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-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py index 7bc2c118885a..b58901b74cfe 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/environments/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 @@ -40,6 +40,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, @@ -116,8 +124,10 @@ def post_update_environment(self, response): def pre_create_environment( self, request: environment.CreateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.CreateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.CreateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_environment Override in a subclass to manipulate the request or metadata @@ -139,8 +149,10 @@ def post_create_environment( def pre_delete_environment( self, request: environment.DeleteEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.DeleteEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.DeleteEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_environment Override in a subclass to manipulate the request or metadata @@ -151,8 +163,10 @@ def pre_delete_environment( def pre_get_environment( self, request: environment.GetEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.GetEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_environment Override in a subclass to manipulate the request or metadata @@ -174,8 +188,11 @@ def post_get_environment( def pre_get_environment_history( self, request: environment.GetEnvironmentHistoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.GetEnvironmentHistoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.GetEnvironmentHistoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_environment_history Override in a subclass to manipulate the request or metadata @@ -197,8 +214,10 @@ def post_get_environment_history( def pre_list_environments( self, request: environment.ListEnvironmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.ListEnvironmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.ListEnvironmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_environments Override in a subclass to manipulate the request or metadata @@ -220,8 +239,10 @@ def post_list_environments( def pre_update_environment( self, request: environment.UpdateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environment.UpdateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environment.UpdateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_environment Override in a subclass to manipulate the request or metadata @@ -243,8 +264,10 @@ def post_update_environment( 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 @@ -266,8 +289,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 @@ -289,8 +314,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -310,8 +337,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -333,8 +362,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -476,7 +507,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]]] = (), ) -> environment.Environment: r"""Call the create environment method over HTTP. @@ -487,8 +518,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: ~.environment.Environment: @@ -517,6 +550,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_create_environment( request, metadata ) @@ -533,6 +567,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 = 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.dialogflow_v2beta1.EnvironmentsClient.CreateEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "CreateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CreateEnvironment._get_response( self._host, @@ -554,7 +615,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2beta1.EnvironmentsClient.create_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "CreateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEnvironment( @@ -591,7 +674,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 environment method over HTTP. @@ -602,13 +685,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_environment( request, metadata ) @@ -621,6 +707,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.dialogflow_v2beta1.EnvironmentsClient.DeleteEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "DeleteEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteEnvironment._get_response( self._host, @@ -670,7 +783,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]]] = (), ) -> environment.Environment: r"""Call the get environment method over HTTP. @@ -681,8 +794,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: ~.environment.Environment: @@ -711,6 +826,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_transcoded_request( http_options, request @@ -721,6 +837,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 = 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.dialogflow_v2beta1.EnvironmentsClient.GetEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironment._get_response( self._host, @@ -741,7 +884,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2beta1.EnvironmentsClient.get_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnvironmentHistory( @@ -778,7 +943,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]]] = (), ) -> environment.EnvironmentHistory: r"""Call the get environment history method over HTTP. @@ -789,8 +954,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: ~.environment.EnvironmentHistory: @@ -802,6 +969,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironmentHistory._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment_history( request, metadata ) @@ -814,6 +982,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 = 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.dialogflow_v2beta1.EnvironmentsClient.GetEnvironmentHistory", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetEnvironmentHistory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironmentHistory._get_response( self._host, @@ -834,7 +1029,29 @@ def __call__( pb_resp = environment.EnvironmentHistory.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment_history(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.EnvironmentHistory.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.dialogflow_v2beta1.EnvironmentsClient.get_environment_history", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetEnvironmentHistory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEnvironments( @@ -871,7 +1088,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]]] = (), ) -> environment.ListEnvironmentsResponse: r"""Call the list environments method over HTTP. @@ -882,8 +1099,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: ~.environment.ListEnvironmentsResponse: @@ -895,6 +1114,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListEnvironments._get_http_options() ) + request, metadata = self._interceptor.pre_list_environments( request, metadata ) @@ -907,6 +1127,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 = 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.dialogflow_v2beta1.EnvironmentsClient.ListEnvironments", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListEnvironments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListEnvironments._get_response( self._host, @@ -927,7 +1174,31 @@ def __call__( pb_resp = environment.ListEnvironmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_environments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.ListEnvironmentsResponse.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.dialogflow_v2beta1.EnvironmentsClient.list_environments", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListEnvironments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEnvironment( @@ -965,7 +1236,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]]] = (), ) -> environment.Environment: r"""Call the update environment method over HTTP. @@ -976,8 +1247,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: ~.environment.Environment: @@ -1006,6 +1279,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_update_environment( request, metadata ) @@ -1022,6 +1296,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 = 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.dialogflow_v2beta1.EnvironmentsClient.UpdateEnvironment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "UpdateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._UpdateEnvironment._get_response( self._host, @@ -1043,7 +1344,29 @@ def __call__( pb_resp = environment.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environment.Environment.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.dialogflow_v2beta1.EnvironmentsClient.update_environment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "UpdateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1136,7 +1459,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. @@ -1146,8 +1469,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. @@ -1156,6 +1481,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseEnvironmentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1170,6 +1496,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.dialogflow_v2beta1.EnvironmentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetLocation._get_response( self._host, @@ -1189,6 +1542,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.dialogflow_v2beta1.EnvironmentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1229,7 +1603,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. @@ -1239,8 +1613,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. @@ -1249,6 +1625,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1259,6 +1636,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.dialogflow_v2beta1.EnvironmentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListLocations._get_response( self._host, @@ -1278,6 +1682,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.dialogflow_v2beta1.EnvironmentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1318,7 +1743,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1328,13 +1753,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 = ( _BaseEnvironmentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1347,6 +1775,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.dialogflow_v2beta1.EnvironmentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CancelOperation._get_response( self._host, @@ -1402,7 +1857,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1412,8 +1867,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: operations_pb2.Operation: Response from GetOperation method. @@ -1422,6 +1879,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1434,6 +1892,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.dialogflow_v2beta1.EnvironmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetOperation._get_response( self._host, @@ -1453,6 +1938,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.EnvironmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1493,7 +1999,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1503,8 +2009,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1513,6 +2021,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1523,6 +2032,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.dialogflow_v2beta1.EnvironmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListOperations._get_response( self._host, @@ -1542,6 +2078,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.EnvironmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Environments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py index a9bf31444410..1fddbcb90a96 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, FulfillmentsTransport from .transports.grpc_asyncio import FulfillmentsGrpcAsyncIOTransport +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 FulfillmentsAsyncClient: """Service for managing @@ -256,6 +266,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.dialogflow_v2beta1.FulfillmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "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.dialogflow.v2beta1.Fulfillments", + "credentialsType": None, + }, + ) + async def get_fulfillment( self, request: Optional[Union[fulfillment.GetFulfillmentRequest, dict]] = None, @@ -263,7 +295,7 @@ async def get_fulfillment( 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]]] = (), ) -> fulfillment.Fulfillment: r"""Retrieves the fulfillment. @@ -310,8 +342,10 @@ async def sample_get_fulfillment(): 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.dialogflow_v2beta1.types.Fulfillment: @@ -383,7 +417,7 @@ async def update_fulfillment( 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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Updates the fulfillment. @@ -437,8 +471,10 @@ async def sample_update_fulfillment(): 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.dialogflow_v2beta1.types.Fulfillment: @@ -512,7 +548,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -523,8 +559,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -565,7 +603,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -576,8 +614,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -618,7 +658,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -633,8 +673,10 @@ async def cancel_operation( 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: None """ @@ -671,7 +713,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. @@ -682,8 +724,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. @@ -724,7 +768,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. @@ -735,8 +779,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-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py index 0c1bb1db3562..526df65ae19c 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -575,6 +585,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( @@ -637,6 +651,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.dialogflow_v2beta1.FulfillmentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "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.dialogflow.v2beta1.Fulfillments", + "credentialsType": None, + }, + ) + def get_fulfillment( self, request: Optional[Union[fulfillment.GetFulfillmentRequest, dict]] = None, @@ -644,7 +681,7 @@ def get_fulfillment( 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]]] = (), ) -> fulfillment.Fulfillment: r"""Retrieves the fulfillment. @@ -691,8 +728,10 @@ def sample_get_fulfillment(): 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.dialogflow_v2beta1.types.Fulfillment: @@ -761,7 +800,7 @@ def update_fulfillment( 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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Updates the fulfillment. @@ -815,8 +854,10 @@ def sample_update_fulfillment(): 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.dialogflow_v2beta1.types.Fulfillment: @@ -900,7 +941,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -911,8 +952,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -953,7 +996,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -964,8 +1007,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1006,7 +1051,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1021,8 +1066,10 @@ def cancel_operation( 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: None """ @@ -1059,7 +1106,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. @@ -1070,8 +1117,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. @@ -1112,7 +1161,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. @@ -1123,8 +1172,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-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py index cae48376e3e3..d4952b933568 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment from google.cloud.dialogflow_v2beta1.types import fulfillment from .base import DEFAULT_CLIENT_INFO, FulfillmentsTransport +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.dialogflow.v2beta1.Fulfillments", + "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.dialogflow.v2beta1.Fulfillments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FulfillmentsGrpcTransport(FulfillmentsTransport): """gRPC backend transport for Fulfillments. @@ -183,7 +264,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 @@ -257,7 +343,7 @@ def get_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_fulfillment" not in self._stubs: - self._stubs["get_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["get_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Fulfillments/GetFulfillment", request_serializer=fulfillment.GetFulfillmentRequest.serialize, response_deserializer=fulfillment.Fulfillment.deserialize, @@ -285,7 +371,7 @@ def update_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_fulfillment" not in self._stubs: - self._stubs["update_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["update_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Fulfillments/UpdateFulfillment", request_serializer=gcd_fulfillment.UpdateFulfillmentRequest.serialize, response_deserializer=gcd_fulfillment.Fulfillment.deserialize, @@ -293,7 +379,7 @@ def update_fulfillment( return self._stubs["update_fulfillment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -305,7 +391,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -322,7 +408,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -341,7 +427,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -360,7 +446,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, @@ -377,7 +463,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-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py index 5b7ea86a0390..d74ebcfc88d7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import fulfillment as gcd_fulfillment from google.cloud.dialogflow_v2beta1.types import fulfillment @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, FulfillmentsTransport from .grpc import FulfillmentsGrpcTransport +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.dialogflow.v2beta1.Fulfillments", + "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.dialogflow.v2beta1.Fulfillments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FulfillmentsGrpcAsyncIOTransport(FulfillmentsTransport): """gRPC AsyncIO backend transport for Fulfillments. @@ -230,10 +312,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 @@ -267,7 +352,7 @@ def get_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_fulfillment" not in self._stubs: - self._stubs["get_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["get_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Fulfillments/GetFulfillment", request_serializer=fulfillment.GetFulfillmentRequest.serialize, response_deserializer=fulfillment.Fulfillment.deserialize, @@ -296,7 +381,7 @@ def update_fulfillment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_fulfillment" not in self._stubs: - self._stubs["update_fulfillment"] = self.grpc_channel.unary_unary( + self._stubs["update_fulfillment"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Fulfillments/UpdateFulfillment", request_serializer=gcd_fulfillment.UpdateFulfillmentRequest.serialize, response_deserializer=gcd_fulfillment.Fulfillment.deserialize, @@ -349,7 +434,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: @@ -365,7 +450,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -382,7 +467,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +486,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -420,7 +505,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, @@ -437,7 +522,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-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py index 73fd8fb75625..5e743e3283f7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/fulfillments/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 @@ -40,6 +40,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, @@ -88,8 +96,10 @@ def post_update_fulfillment(self, response): def pre_get_fulfillment( self, request: fulfillment.GetFulfillmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[fulfillment.GetFulfillmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + fulfillment.GetFulfillmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_fulfillment Override in a subclass to manipulate the request or metadata @@ -111,8 +121,11 @@ def post_get_fulfillment( def pre_update_fulfillment( self, request: gcd_fulfillment.UpdateFulfillmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_fulfillment.UpdateFulfillmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_fulfillment.UpdateFulfillmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_fulfillment Override in a subclass to manipulate the request or metadata @@ -134,8 +147,10 @@ def post_update_fulfillment( 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 @@ -157,8 +172,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 @@ -180,8 +197,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -201,8 +220,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -224,8 +245,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -366,7 +389,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]]] = (), ) -> fulfillment.Fulfillment: r"""Call the get fulfillment method over HTTP. @@ -377,8 +400,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: ~.fulfillment.Fulfillment: @@ -400,6 +425,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetFulfillment._get_http_options() ) + request, metadata = self._interceptor.pre_get_fulfillment(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseGetFulfillment._get_transcoded_request( http_options, request @@ -410,6 +436,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 = 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.dialogflow_v2beta1.FulfillmentsClient.GetFulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetFulfillment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetFulfillment._get_response( self._host, @@ -430,7 +483,29 @@ def __call__( pb_resp = fulfillment.Fulfillment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_fulfillment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = fulfillment.Fulfillment.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.dialogflow_v2beta1.FulfillmentsClient.get_fulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetFulfillment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFulfillment( @@ -468,7 +543,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]]] = (), ) -> gcd_fulfillment.Fulfillment: r"""Call the update fulfillment method over HTTP. @@ -479,8 +554,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: ~.gcd_fulfillment.Fulfillment: @@ -502,6 +579,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseUpdateFulfillment._get_http_options() ) + request, metadata = self._interceptor.pre_update_fulfillment( request, metadata ) @@ -518,6 +596,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 = 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.dialogflow_v2beta1.FulfillmentsClient.UpdateFulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "UpdateFulfillment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._UpdateFulfillment._get_response( self._host, @@ -539,7 +644,29 @@ def __call__( pb_resp = gcd_fulfillment.Fulfillment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_fulfillment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_fulfillment.Fulfillment.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.dialogflow_v2beta1.FulfillmentsClient.update_fulfillment", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "UpdateFulfillment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -598,7 +725,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. @@ -608,8 +735,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. @@ -618,6 +747,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseFulfillmentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -632,6 +762,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.dialogflow_v2beta1.FulfillmentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetLocation._get_response( self._host, @@ -651,6 +808,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.dialogflow_v2beta1.FulfillmentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -691,7 +869,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. @@ -701,8 +879,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. @@ -711,6 +891,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -721,6 +902,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.dialogflow_v2beta1.FulfillmentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._ListLocations._get_response( self._host, @@ -740,6 +948,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.dialogflow_v2beta1.FulfillmentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -780,7 +1009,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -790,13 +1019,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 = ( _BaseFulfillmentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -809,6 +1041,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.dialogflow_v2beta1.FulfillmentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._CancelOperation._get_response( self._host, @@ -864,7 +1123,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -874,8 +1133,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: operations_pb2.Operation: Response from GetOperation method. @@ -884,6 +1145,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -896,6 +1158,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.dialogflow_v2beta1.FulfillmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._GetOperation._get_response( self._host, @@ -915,6 +1204,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.FulfillmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -955,7 +1265,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -965,8 +1275,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -975,6 +1287,7 @@ def __call__( http_options = ( _BaseFulfillmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseFulfillmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -985,6 +1298,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.dialogflow_v2beta1.FulfillmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FulfillmentsRestTransport._ListOperations._get_response( self._host, @@ -1004,6 +1344,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.FulfillmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Fulfillments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/async_client.py index 0e540657893b..7115aa143604 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GeneratorsTransport from .transports.grpc_asyncio import GeneratorsGrpcAsyncIOTransport +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 GeneratorsAsyncClient: """Generator Service for LLM powered Agent Assist. This service @@ -259,6 +269,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.dialogflow_v2beta1.GeneratorsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "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.dialogflow.v2beta1.Generators", + "credentialsType": None, + }, + ) + async def create_generator( self, request: Optional[Union[gcd_generator.CreateGeneratorRequest, dict]] = None, @@ -268,7 +300,7 @@ async def create_generator( generator_id: 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]]] = (), ) -> gcd_generator.Generator: r"""Creates a generator. @@ -336,8 +368,10 @@ async def sample_create_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -400,7 +434,7 @@ async def get_generator( 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]]] = (), ) -> generator.Generator: r"""Retrieves a generator. @@ -444,8 +478,10 @@ async def sample_get_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -504,7 +540,7 @@ async def list_generators( 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.ListGeneratorsAsyncPager: r"""Lists generators. @@ -549,8 +585,10 @@ async def sample_list_generators(): 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.dialogflow_v2beta1.services.generators.pagers.ListGeneratorsAsyncPager: @@ -625,7 +663,7 @@ async def delete_generator( 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 generator. @@ -665,8 +703,10 @@ async def sample_delete_generator(): 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 @@ -719,7 +759,7 @@ async def update_generator( 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]]] = (), ) -> gcd_generator.Generator: r"""Updates a generator. @@ -769,8 +809,10 @@ async def sample_update_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -832,7 +874,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -843,8 +885,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -885,7 +929,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -896,8 +940,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -938,7 +984,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -953,8 +999,10 @@ async def cancel_operation( 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: None """ @@ -991,7 +1039,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. @@ -1002,8 +1050,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. @@ -1044,7 +1094,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. @@ -1055,8 +1105,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-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/client.py index 9f6650d1a55c..bf0a5d28b245 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -587,6 +597,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( @@ -649,6 +663,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.dialogflow_v2beta1.GeneratorsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "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.dialogflow.v2beta1.Generators", + "credentialsType": None, + }, + ) + def create_generator( self, request: Optional[Union[gcd_generator.CreateGeneratorRequest, dict]] = None, @@ -658,7 +695,7 @@ def create_generator( generator_id: 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]]] = (), ) -> gcd_generator.Generator: r"""Creates a generator. @@ -726,8 +763,10 @@ def sample_create_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -787,7 +826,7 @@ def get_generator( 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]]] = (), ) -> generator.Generator: r"""Retrieves a generator. @@ -831,8 +870,10 @@ def sample_get_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -888,7 +929,7 @@ def list_generators( 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.ListGeneratorsPager: r"""Lists generators. @@ -933,8 +974,10 @@ def sample_list_generators(): 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.dialogflow_v2beta1.services.generators.pagers.ListGeneratorsPager: @@ -1006,7 +1049,7 @@ def delete_generator( 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 generator. @@ -1046,8 +1089,10 @@ def sample_delete_generator(): 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 @@ -1097,7 +1142,7 @@ def update_generator( 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]]] = (), ) -> gcd_generator.Generator: r"""Updates a generator. @@ -1147,8 +1192,10 @@ def sample_update_generator(): 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.dialogflow_v2beta1.types.Generator: @@ -1220,7 +1267,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1231,8 +1278,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1273,7 +1322,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1284,8 +1333,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1326,7 +1377,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1341,8 +1392,10 @@ def cancel_operation( 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: None """ @@ -1379,7 +1432,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. @@ -1390,8 +1443,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. @@ -1432,7 +1487,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. @@ -1443,8 +1498,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-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/pagers.py index 4a9bf1c4f8c1..2eb10f11470b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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 = generator.ListGeneratorsRequest(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 = generator.ListGeneratorsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc.py index 4a878517f005..582314d2a526 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import generator from google.cloud.dialogflow_v2beta1.types import generator as gcd_generator from .base import DEFAULT_CLIENT_INFO, GeneratorsTransport +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.dialogflow.v2beta1.Generators", + "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.dialogflow.v2beta1.Generators", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GeneratorsGrpcTransport(GeneratorsTransport): """gRPC backend transport for Generators. @@ -187,7 +268,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 @@ -261,7 +347,7 @@ def create_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_generator" not in self._stubs: - self._stubs["create_generator"] = self.grpc_channel.unary_unary( + self._stubs["create_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/CreateGenerator", request_serializer=gcd_generator.CreateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -287,7 +373,7 @@ def get_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_generator" not in self._stubs: - self._stubs["get_generator"] = self.grpc_channel.unary_unary( + self._stubs["get_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/GetGenerator", request_serializer=generator.GetGeneratorRequest.serialize, response_deserializer=generator.Generator.deserialize, @@ -313,7 +399,7 @@ def list_generators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_generators" not in self._stubs: - self._stubs["list_generators"] = self.grpc_channel.unary_unary( + self._stubs["list_generators"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/ListGenerators", request_serializer=generator.ListGeneratorsRequest.serialize, response_deserializer=generator.ListGeneratorsResponse.deserialize, @@ -339,7 +425,7 @@ def delete_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_generator" not in self._stubs: - self._stubs["delete_generator"] = self.grpc_channel.unary_unary( + self._stubs["delete_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/DeleteGenerator", request_serializer=generator.DeleteGeneratorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -365,7 +451,7 @@ def update_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_generator" not in self._stubs: - self._stubs["update_generator"] = self.grpc_channel.unary_unary( + self._stubs["update_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/UpdateGenerator", request_serializer=gcd_generator.UpdateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -373,7 +459,7 @@ def update_generator( return self._stubs["update_generator"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -385,7 +471,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -402,7 +488,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -421,7 +507,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -440,7 +526,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, @@ -457,7 +543,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-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc_asyncio.py index f04b71c2e41e..5dab71e79565 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import generator from google.cloud.dialogflow_v2beta1.types import generator as gcd_generator @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, GeneratorsTransport from .grpc import GeneratorsGrpcTransport +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.dialogflow.v2beta1.Generators", + "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.dialogflow.v2beta1.Generators", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GeneratorsGrpcAsyncIOTransport(GeneratorsTransport): """gRPC AsyncIO backend transport for Generators. @@ -234,10 +316,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 @@ -271,7 +356,7 @@ def create_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_generator" not in self._stubs: - self._stubs["create_generator"] = self.grpc_channel.unary_unary( + self._stubs["create_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/CreateGenerator", request_serializer=gcd_generator.CreateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -297,7 +382,7 @@ def get_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_generator" not in self._stubs: - self._stubs["get_generator"] = self.grpc_channel.unary_unary( + self._stubs["get_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/GetGenerator", request_serializer=generator.GetGeneratorRequest.serialize, response_deserializer=generator.Generator.deserialize, @@ -325,7 +410,7 @@ def list_generators( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_generators" not in self._stubs: - self._stubs["list_generators"] = self.grpc_channel.unary_unary( + self._stubs["list_generators"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/ListGenerators", request_serializer=generator.ListGeneratorsRequest.serialize, response_deserializer=generator.ListGeneratorsResponse.deserialize, @@ -351,7 +436,7 @@ def delete_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_generator" not in self._stubs: - self._stubs["delete_generator"] = self.grpc_channel.unary_unary( + self._stubs["delete_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/DeleteGenerator", request_serializer=generator.DeleteGeneratorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -379,7 +464,7 @@ def update_generator( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_generator" not in self._stubs: - self._stubs["update_generator"] = self.grpc_channel.unary_unary( + self._stubs["update_generator"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Generators/UpdateGenerator", request_serializer=gcd_generator.UpdateGeneratorRequest.serialize, response_deserializer=gcd_generator.Generator.deserialize, @@ -447,7 +532,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: @@ -463,7 +548,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -480,7 +565,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -499,7 +584,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -518,7 +603,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, @@ -535,7 +620,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-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/rest.py index f413e52daa0f..f3cfe2ab4bc9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/generators/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 @@ -41,6 +41,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, @@ -109,8 +117,10 @@ def post_update_generator(self, response): def pre_create_generator( self, request: gcd_generator.CreateGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_generator.CreateGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_generator.CreateGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_generator Override in a subclass to manipulate the request or metadata @@ -132,8 +142,10 @@ def post_create_generator( def pre_delete_generator( self, request: generator.DeleteGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.DeleteGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generator.DeleteGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_generator Override in a subclass to manipulate the request or metadata @@ -144,8 +156,8 @@ def pre_delete_generator( def pre_get_generator( self, request: generator.GetGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.GetGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[generator.GetGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_generator Override in a subclass to manipulate the request or metadata @@ -165,8 +177,10 @@ def post_get_generator(self, response: generator.Generator) -> generator.Generat def pre_list_generators( self, request: generator.ListGeneratorsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generator.ListGeneratorsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generator.ListGeneratorsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_generators Override in a subclass to manipulate the request or metadata @@ -188,8 +202,10 @@ def post_list_generators( def pre_update_generator( self, request: gcd_generator.UpdateGeneratorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_generator.UpdateGeneratorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_generator.UpdateGeneratorRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_generator Override in a subclass to manipulate the request or metadata @@ -211,8 +227,10 @@ def post_update_generator( 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 @@ -234,8 +252,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 @@ -257,8 +277,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -278,8 +300,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -301,8 +325,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -447,7 +473,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]]] = (), ) -> gcd_generator.Generator: r"""Call the create generator method over HTTP. @@ -457,8 +483,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: ~.gcd_generator.Generator: @@ -468,6 +496,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseCreateGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_create_generator( request, metadata ) @@ -484,6 +513,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 = 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.dialogflow_v2beta1.GeneratorsClient.CreateGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "CreateGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._CreateGenerator._get_response( self._host, @@ -505,7 +561,29 @@ def __call__( pb_resp = gcd_generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_generator.Generator.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.dialogflow_v2beta1.GeneratorsClient.create_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "CreateGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGenerator( @@ -542,7 +620,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 generator method over HTTP. @@ -552,13 +630,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 = ( _BaseGeneratorsRestTransport._BaseDeleteGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_delete_generator( request, metadata ) @@ -571,6 +652,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.dialogflow_v2beta1.GeneratorsClient.DeleteGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "DeleteGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._DeleteGenerator._get_response( self._host, @@ -620,7 +728,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]]] = (), ) -> generator.Generator: r"""Call the get generator method over HTTP. @@ -630,8 +738,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: ~.generator.Generator: @@ -641,6 +751,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_get_generator(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetGenerator._get_transcoded_request( @@ -655,6 +766,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.dialogflow_v2beta1.GeneratorsClient.GetGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetGenerator._get_response( self._host, @@ -675,7 +813,29 @@ def __call__( pb_resp = generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generator.Generator.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.dialogflow_v2beta1.GeneratorsClient.get_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGenerators( @@ -712,7 +872,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]]] = (), ) -> generator.ListGeneratorsResponse: r"""Call the list generators method over HTTP. @@ -722,8 +882,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: ~.generator.ListGeneratorsResponse: @@ -733,6 +895,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListGenerators._get_http_options() ) + request, metadata = self._interceptor.pre_list_generators(request, metadata) transcoded_request = _BaseGeneratorsRestTransport._BaseListGenerators._get_transcoded_request( http_options, request @@ -745,6 +908,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.dialogflow_v2beta1.GeneratorsClient.ListGenerators", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListGenerators", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListGenerators._get_response( self._host, @@ -765,7 +955,31 @@ def __call__( pb_resp = generator.ListGeneratorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_generators(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generator.ListGeneratorsResponse.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.dialogflow_v2beta1.GeneratorsClient.list_generators", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListGenerators", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGenerator( @@ -803,7 +1017,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]]] = (), ) -> gcd_generator.Generator: r"""Call the update generator method over HTTP. @@ -813,8 +1027,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: ~.gcd_generator.Generator: @@ -824,6 +1040,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseUpdateGenerator._get_http_options() ) + request, metadata = self._interceptor.pre_update_generator( request, metadata ) @@ -840,6 +1057,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 = 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.dialogflow_v2beta1.GeneratorsClient.UpdateGenerator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "UpdateGenerator", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._UpdateGenerator._get_response( self._host, @@ -861,7 +1105,29 @@ def __call__( pb_resp = gcd_generator.Generator.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_generator(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_generator.Generator.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.dialogflow_v2beta1.GeneratorsClient.update_generator", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "UpdateGenerator", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -942,7 +1208,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. @@ -952,8 +1218,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. @@ -962,6 +1230,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetLocation._get_transcoded_request( @@ -976,6 +1245,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.dialogflow_v2beta1.GeneratorsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetLocation._get_response( self._host, @@ -995,6 +1291,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.dialogflow_v2beta1.GeneratorsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1035,7 +1352,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. @@ -1045,8 +1362,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. @@ -1055,6 +1374,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseListLocations._get_transcoded_request( @@ -1069,6 +1389,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.dialogflow_v2beta1.GeneratorsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListLocations._get_response( self._host, @@ -1088,6 +1435,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.dialogflow_v2beta1.GeneratorsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1128,7 +1496,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1138,13 +1506,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 = ( _BaseGeneratorsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1157,6 +1528,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.dialogflow_v2beta1.GeneratorsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._CancelOperation._get_response( self._host, @@ -1212,7 +1610,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1222,8 +1620,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: operations_pb2.Operation: Response from GetOperation method. @@ -1232,6 +1632,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseGeneratorsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1246,6 +1647,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.dialogflow_v2beta1.GeneratorsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._GetOperation._get_response( self._host, @@ -1265,6 +1693,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.GeneratorsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1305,7 +1754,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1315,8 +1764,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1325,6 +1776,7 @@ def __call__( http_options = ( _BaseGeneratorsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGeneratorsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1337,6 +1789,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.dialogflow_v2beta1.GeneratorsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GeneratorsRestTransport._ListOperations._get_response( self._host, @@ -1356,6 +1835,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.GeneratorsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Generators", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/async_client.py index af47f2afe460..6c2db57eef24 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, IntentsTransport from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport +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 IntentsAsyncClient: """Service for managing @@ -260,6 +270,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.dialogflow_v2beta1.IntentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "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.dialogflow.v2beta1.Intents", + "credentialsType": None, + }, + ) + async def list_intents( self, request: Optional[Union[intent.ListIntentsRequest, dict]] = None, @@ -268,7 +300,7 @@ async def list_intents( language_code: 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.ListIntentsAsyncPager: r"""Returns the list of all intents in the specified agent. @@ -333,8 +365,10 @@ async def sample_list_intents(): 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.dialogflow_v2beta1.services.intents.pagers.ListIntentsAsyncPager: @@ -412,7 +446,7 @@ async def get_intent( language_code: 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]]] = (), ) -> intent.Intent: r"""Retrieves the specified intent. @@ -468,8 +502,10 @@ async def sample_get_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -543,7 +579,7 @@ async def create_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Creates an intent in the specified agent. @@ -613,8 +649,10 @@ async def sample_create_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -690,7 +728,7 @@ async def update_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Updates the specified intent. @@ -756,8 +794,10 @@ async def sample_update_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -833,7 +873,7 @@ async def delete_intent( 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 the specified intent and its direct or indirect followup intents. @@ -885,8 +925,10 @@ async def sample_delete_intent(): 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 @@ -940,7 +982,7 @@ async def batch_update_intents( intent_batch_inline: Optional[intent.IntentBatch] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Updates/Creates multiple intents in the specified agent. @@ -1024,8 +1066,10 @@ async def sample_batch_update_intents(): 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.api_core.operation_async.AsyncOperation: @@ -1101,7 +1145,7 @@ async def batch_delete_intents( intents: Optional[MutableSequence[intent.Intent]] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes intents in the specified agent. @@ -1177,8 +1221,10 @@ async def sample_batch_delete_intents(): 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.api_core.operation_async.AsyncOperation: @@ -1258,7 +1304,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1269,8 +1315,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1311,7 +1359,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1322,8 +1370,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1364,7 +1414,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1379,8 +1429,10 @@ async def cancel_operation( 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: None """ @@ -1417,7 +1469,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. @@ -1428,8 +1480,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. @@ -1470,7 +1524,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. @@ -1481,8 +1535,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-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/client.py index 1bb239ff2788..accac19fc383 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -605,6 +615,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( @@ -667,6 +681,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.dialogflow_v2beta1.IntentsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "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.dialogflow.v2beta1.Intents", + "credentialsType": None, + }, + ) + def list_intents( self, request: Optional[Union[intent.ListIntentsRequest, dict]] = None, @@ -675,7 +712,7 @@ def list_intents( language_code: 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.ListIntentsPager: r"""Returns the list of all intents in the specified agent. @@ -740,8 +777,10 @@ def sample_list_intents(): 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.dialogflow_v2beta1.services.intents.pagers.ListIntentsPager: @@ -816,7 +855,7 @@ def get_intent( language_code: 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]]] = (), ) -> intent.Intent: r"""Retrieves the specified intent. @@ -872,8 +911,10 @@ def sample_get_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -944,7 +985,7 @@ def create_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Creates an intent in the specified agent. @@ -1014,8 +1055,10 @@ def sample_create_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -1088,7 +1131,7 @@ def update_intent( language_code: 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]]] = (), ) -> gcd_intent.Intent: r"""Updates the specified intent. @@ -1154,8 +1197,10 @@ def sample_update_intent(): 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.dialogflow_v2beta1.types.Intent: @@ -1228,7 +1273,7 @@ def delete_intent( 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 the specified intent and its direct or indirect followup intents. @@ -1280,8 +1325,10 @@ def sample_delete_intent(): 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 @@ -1332,7 +1379,7 @@ def batch_update_intents( intent_batch_inline: Optional[intent.IntentBatch] = 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]]] = (), ) -> operation.Operation: r"""Updates/Creates multiple intents in the specified agent. @@ -1416,8 +1463,10 @@ def sample_batch_update_intents(): 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.api_core.operation.Operation: @@ -1490,7 +1539,7 @@ def batch_delete_intents( intents: Optional[MutableSequence[intent.Intent]] = 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]]] = (), ) -> operation.Operation: r"""Deletes intents in the specified agent. @@ -1566,8 +1615,10 @@ def sample_batch_delete_intents(): 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.api_core.operation.Operation: @@ -1657,7 +1708,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1668,8 +1719,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1710,7 +1763,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1721,8 +1774,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1763,7 +1818,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1778,8 +1833,10 @@ def cancel_operation( 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: None """ @@ -1816,7 +1873,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. @@ -1827,8 +1884,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. @@ -1869,7 +1928,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. @@ -1880,8 +1939,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-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/pagers.py index 4d63d9f35338..d7446e536304 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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 = intent.ListIntentsRequest(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 = intent.ListIntentsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py index b37f350014c8..a5801fa83e86 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import intent from google.cloud.dialogflow_v2beta1.types import intent as gcd_intent from .base import DEFAULT_CLIENT_INFO, IntentsTransport +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.dialogflow.v2beta1.Intents", + "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.dialogflow.v2beta1.Intents", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IntentsGrpcTransport(IntentsTransport): """gRPC backend transport for Intents. @@ -185,7 +266,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 @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -274,7 +362,7 @@ def list_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_intents" not in self._stubs: - self._stubs["list_intents"] = self.grpc_channel.unary_unary( + self._stubs["list_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/ListIntents", request_serializer=intent.ListIntentsRequest.serialize, response_deserializer=intent.ListIntentsResponse.deserialize, @@ -298,7 +386,7 @@ def get_intent(self) -> Callable[[intent.GetIntentRequest], intent.Intent]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_intent" not in self._stubs: - self._stubs["get_intent"] = self.grpc_channel.unary_unary( + self._stubs["get_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/GetIntent", request_serializer=intent.GetIntentRequest.serialize, response_deserializer=intent.Intent.deserialize, @@ -328,7 +416,7 @@ def create_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_intent" not in self._stubs: - self._stubs["create_intent"] = self.grpc_channel.unary_unary( + self._stubs["create_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/CreateIntent", request_serializer=gcd_intent.CreateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -358,7 +446,7 @@ def update_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_intent" not in self._stubs: - self._stubs["update_intent"] = self.grpc_channel.unary_unary( + self._stubs["update_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/UpdateIntent", request_serializer=gcd_intent.UpdateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -387,7 +475,7 @@ def delete_intent(self) -> Callable[[intent.DeleteIntentRequest], empty_pb2.Empt # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_intent" not in self._stubs: - self._stubs["delete_intent"] = self.grpc_channel.unary_unary( + self._stubs["delete_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/DeleteIntent", request_serializer=intent.DeleteIntentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -427,7 +515,7 @@ def batch_update_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_intents" not in self._stubs: - self._stubs["batch_update_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/BatchUpdateIntents", request_serializer=intent.BatchUpdateIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -467,7 +555,7 @@ def batch_delete_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_intents" not in self._stubs: - self._stubs["batch_delete_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/BatchDeleteIntents", request_serializer=intent.BatchDeleteIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -475,7 +563,7 @@ def batch_delete_intents( return self._stubs["batch_delete_intents"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -487,7 +575,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -504,7 +592,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +611,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -542,7 +630,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, @@ -559,7 +647,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-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py index fd233fdc3214..ba081af7a575 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import intent from google.cloud.dialogflow_v2beta1.types import intent as gcd_intent @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, IntentsTransport from .grpc import IntentsGrpcTransport +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.dialogflow.v2beta1.Intents", + "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.dialogflow.v2beta1.Intents", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class IntentsGrpcAsyncIOTransport(IntentsTransport): """gRPC AsyncIO backend transport for Intents. @@ -232,10 +314,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 @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def list_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_intents" not in self._stubs: - self._stubs["list_intents"] = self.grpc_channel.unary_unary( + self._stubs["list_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/ListIntents", request_serializer=intent.ListIntentsRequest.serialize, response_deserializer=intent.ListIntentsResponse.deserialize, @@ -310,7 +395,7 @@ def get_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_intent" not in self._stubs: - self._stubs["get_intent"] = self.grpc_channel.unary_unary( + self._stubs["get_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/GetIntent", request_serializer=intent.GetIntentRequest.serialize, response_deserializer=intent.Intent.deserialize, @@ -340,7 +425,7 @@ def create_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_intent" not in self._stubs: - self._stubs["create_intent"] = self.grpc_channel.unary_unary( + self._stubs["create_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/CreateIntent", request_serializer=gcd_intent.CreateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -370,7 +455,7 @@ def update_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_intent" not in self._stubs: - self._stubs["update_intent"] = self.grpc_channel.unary_unary( + self._stubs["update_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/UpdateIntent", request_serializer=gcd_intent.UpdateIntentRequest.serialize, response_deserializer=gcd_intent.Intent.deserialize, @@ -401,7 +486,7 @@ def delete_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_intent" not in self._stubs: - self._stubs["delete_intent"] = self.grpc_channel.unary_unary( + self._stubs["delete_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/DeleteIntent", request_serializer=intent.DeleteIntentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +528,7 @@ def batch_update_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_intents" not in self._stubs: - self._stubs["batch_update_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/BatchUpdateIntents", request_serializer=intent.BatchUpdateIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -485,7 +570,7 @@ def batch_delete_intents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_intents" not in self._stubs: - self._stubs["batch_delete_intents"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_intents"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Intents/BatchDeleteIntents", request_serializer=intent.BatchDeleteIntentsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -563,7 +648,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: @@ -579,7 +664,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -596,7 +681,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -615,7 +700,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -634,7 +719,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, @@ -651,7 +736,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-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py index 5ac5728e0b48..716185442b92 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/intents/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 @@ -41,6 +41,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, @@ -125,8 +133,10 @@ def post_update_intent(self, response): def pre_batch_delete_intents( self, request: intent.BatchDeleteIntentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[intent.BatchDeleteIntentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + intent.BatchDeleteIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_intents Override in a subclass to manipulate the request or metadata @@ -148,8 +158,10 @@ def post_batch_delete_intents( def pre_batch_update_intents( self, request: intent.BatchUpdateIntentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[intent.BatchUpdateIntentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + intent.BatchUpdateIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_update_intents Override in a subclass to manipulate the request or metadata @@ -171,8 +183,8 @@ def post_batch_update_intents( def pre_create_intent( self, request: gcd_intent.CreateIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_intent.CreateIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_intent.CreateIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_intent Override in a subclass to manipulate the request or metadata @@ -190,8 +202,10 @@ def post_create_intent(self, response: gcd_intent.Intent) -> gcd_intent.Intent: return response def pre_delete_intent( - self, request: intent.DeleteIntentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.DeleteIntentRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.DeleteIntentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.DeleteIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_intent Override in a subclass to manipulate the request or metadata @@ -200,8 +214,10 @@ def pre_delete_intent( return request, metadata def pre_get_intent( - self, request: intent.GetIntentRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.GetIntentRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.GetIntentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.GetIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_intent Override in a subclass to manipulate the request or metadata @@ -219,8 +235,10 @@ def post_get_intent(self, response: intent.Intent) -> intent.Intent: return response def pre_list_intents( - self, request: intent.ListIntentsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[intent.ListIntentsRequest, Sequence[Tuple[str, str]]]: + self, + request: intent.ListIntentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[intent.ListIntentsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_intents Override in a subclass to manipulate the request or metadata @@ -242,8 +260,8 @@ def post_list_intents( def pre_update_intent( self, request: gcd_intent.UpdateIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_intent.UpdateIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcd_intent.UpdateIntentRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_intent Override in a subclass to manipulate the request or metadata @@ -263,8 +281,10 @@ def post_update_intent(self, response: gcd_intent.Intent) -> gcd_intent.Intent: 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 @@ -286,8 +306,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 @@ -309,8 +331,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -330,8 +354,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -353,8 +379,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -555,7 +583,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete intents method over HTTP. @@ -566,8 +594,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: ~.operations_pb2.Operation: @@ -580,6 +610,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseBatchDeleteIntents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_intents( request, metadata ) @@ -596,6 +627,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.dialogflow_v2beta1.IntentsClient.BatchDeleteIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "BatchDeleteIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._BatchDeleteIntents._get_response( self._host, @@ -615,7 +673,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_intents(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.dialogflow_v2beta1.IntentsClient.batch_delete_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "BatchDeleteIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateIntents( @@ -653,7 +733,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch update intents method over HTTP. @@ -664,8 +744,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: ~.operations_pb2.Operation: @@ -678,6 +760,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseBatchUpdateIntents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_intents( request, metadata ) @@ -694,6 +777,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.dialogflow_v2beta1.IntentsClient.BatchUpdateIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "BatchUpdateIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._BatchUpdateIntents._get_response( self._host, @@ -713,7 +823,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_intents(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.dialogflow_v2beta1.IntentsClient.batch_update_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "BatchUpdateIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIntent(_BaseIntentsRestTransport._BaseCreateIntent, IntentsRestStub): @@ -749,7 +881,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]]] = (), ) -> gcd_intent.Intent: r"""Call the create intent method over HTTP. @@ -760,8 +892,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: ~.gcd_intent.Intent: @@ -782,6 +916,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseCreateIntent._get_http_options() ) + request, metadata = self._interceptor.pre_create_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseCreateIntent._get_transcoded_request( @@ -800,6 +935,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.dialogflow_v2beta1.IntentsClient.CreateIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "CreateIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._CreateIntent._get_response( self._host, @@ -821,7 +983,29 @@ def __call__( pb_resp = gcd_intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_intent.Intent.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.dialogflow_v2beta1.IntentsClient.create_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "CreateIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteIntent(_BaseIntentsRestTransport._BaseDeleteIntent, IntentsRestStub): @@ -856,7 +1040,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 intent method over HTTP. @@ -867,13 +1051,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 = ( _BaseIntentsRestTransport._BaseDeleteIntent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseDeleteIntent._get_transcoded_request( @@ -888,6 +1075,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.dialogflow_v2beta1.IntentsClient.DeleteIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "DeleteIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._DeleteIntent._get_response( self._host, @@ -935,7 +1149,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]]] = (), ) -> intent.Intent: r"""Call the get intent method over HTTP. @@ -946,8 +1160,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: ~.intent.Intent: @@ -966,6 +1182,7 @@ def __call__( """ http_options = _BaseIntentsRestTransport._BaseGetIntent._get_http_options() + request, metadata = self._interceptor.pre_get_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetIntent._get_transcoded_request( @@ -980,6 +1197,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.dialogflow_v2beta1.IntentsClient.GetIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetIntent._get_response( self._host, @@ -1000,7 +1244,29 @@ def __call__( pb_resp = intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = intent.Intent.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.dialogflow_v2beta1.IntentsClient.get_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIntents(_BaseIntentsRestTransport._BaseListIntents, IntentsRestStub): @@ -1035,7 +1301,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]]] = (), ) -> intent.ListIntentsResponse: r"""Call the list intents method over HTTP. @@ -1046,8 +1312,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: ~.intent.ListIntentsResponse: @@ -1059,6 +1327,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListIntents._get_http_options() ) + request, metadata = self._interceptor.pre_list_intents(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListIntents._get_transcoded_request( @@ -1073,6 +1342,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.dialogflow_v2beta1.IntentsClient.ListIntents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListIntents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListIntents._get_response( self._host, @@ -1093,7 +1389,29 @@ def __call__( pb_resp = intent.ListIntentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_intents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = intent.ListIntentsResponse.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.dialogflow_v2beta1.IntentsClient.list_intents", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListIntents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIntent(_BaseIntentsRestTransport._BaseUpdateIntent, IntentsRestStub): @@ -1129,7 +1447,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]]] = (), ) -> gcd_intent.Intent: r"""Call the update intent method over HTTP. @@ -1140,8 +1458,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: ~.gcd_intent.Intent: @@ -1162,6 +1482,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseUpdateIntent._get_http_options() ) + request, metadata = self._interceptor.pre_update_intent(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseUpdateIntent._get_transcoded_request( @@ -1180,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.dialogflow_v2beta1.IntentsClient.UpdateIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "UpdateIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._UpdateIntent._get_response( self._host, @@ -1201,7 +1549,29 @@ def __call__( pb_resp = gcd_intent.Intent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_intent.Intent.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.dialogflow_v2beta1.IntentsClient.update_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "UpdateIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1292,7 +1662,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. @@ -1302,8 +1672,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. @@ -1312,6 +1684,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1326,6 +1699,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.dialogflow_v2beta1.IntentsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetLocation._get_response( self._host, @@ -1345,6 +1745,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.dialogflow_v2beta1.IntentsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1383,7 +1804,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. @@ -1393,8 +1814,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. @@ -1403,6 +1826,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListLocations._get_transcoded_request( @@ -1417,6 +1841,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.dialogflow_v2beta1.IntentsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListLocations._get_response( self._host, @@ -1436,6 +1887,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.dialogflow_v2beta1.IntentsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1476,7 +1948,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1486,13 +1958,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 = ( _BaseIntentsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1509,6 +1984,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.dialogflow_v2beta1.IntentsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._CancelOperation._get_response( self._host, @@ -1562,7 +2064,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1572,8 +2074,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: operations_pb2.Operation: Response from GetOperation method. @@ -1582,6 +2086,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1596,6 +2101,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.dialogflow_v2beta1.IntentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._GetOperation._get_response( self._host, @@ -1615,6 +2147,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.IntentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1655,7 +2208,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1665,8 +2218,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1675,6 +2230,7 @@ def __call__( http_options = ( _BaseIntentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseIntentsRestTransport._BaseListOperations._get_transcoded_request( @@ -1689,6 +2245,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.dialogflow_v2beta1.IntentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = IntentsRestTransport._ListOperations._get_response( self._host, @@ -1708,6 +2291,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.IntentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Intents", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py index b4d05763ec4a..f9054a2b5201 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport from .transports.grpc_asyncio import KnowledgeBasesGrpcAsyncIOTransport +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 KnowledgeBasesAsyncClient: """Service for managing @@ -263,6 +273,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.dialogflow_v2beta1.KnowledgeBasesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "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.dialogflow.v2beta1.KnowledgeBases", + "credentialsType": None, + }, + ) + async def list_knowledge_bases( self, request: Optional[Union[knowledge_base.ListKnowledgeBasesRequest, dict]] = None, @@ -270,7 +302,7 @@ async def list_knowledge_bases( 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.ListKnowledgeBasesAsyncPager: r"""Returns the list of all knowledge bases of the specified agent. @@ -319,8 +351,10 @@ async def sample_list_knowledge_bases(): 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.dialogflow_v2beta1.services.knowledge_bases.pagers.ListKnowledgeBasesAsyncPager: @@ -395,7 +429,7 @@ async def get_knowledge_base( 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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Retrieves the specified knowledge base. @@ -443,8 +477,10 @@ async def sample_get_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -518,7 +554,7 @@ async def create_knowledge_base( knowledge_base: Optional[gcd_knowledge_base.KnowledgeBase] = 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Creates a knowledge base. @@ -577,8 +613,10 @@ async def sample_create_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -653,7 +691,7 @@ async def delete_knowledge_base( 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 the specified knowledge base. @@ -698,8 +736,10 @@ async def sample_delete_knowledge_base(): 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 @@ -754,7 +794,7 @@ async def update_knowledge_base( 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Updates the specified knowledge base. @@ -812,8 +852,10 @@ async def sample_update_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -887,7 +929,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -898,8 +940,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -940,7 +984,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -951,8 +995,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -993,7 +1039,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1008,8 +1054,10 @@ async def cancel_operation( 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: None """ @@ -1046,7 +1094,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. @@ -1057,8 +1105,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. @@ -1099,7 +1149,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. @@ -1110,8 +1160,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-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py index b9d6fa59061d..673bd67725e7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -582,6 +592,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( @@ -647,6 +661,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.dialogflow_v2beta1.KnowledgeBasesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "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.dialogflow.v2beta1.KnowledgeBases", + "credentialsType": None, + }, + ) + def list_knowledge_bases( self, request: Optional[Union[knowledge_base.ListKnowledgeBasesRequest, dict]] = None, @@ -654,7 +691,7 @@ def list_knowledge_bases( 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.ListKnowledgeBasesPager: r"""Returns the list of all knowledge bases of the specified agent. @@ -703,8 +740,10 @@ def sample_list_knowledge_bases(): 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.dialogflow_v2beta1.services.knowledge_bases.pagers.ListKnowledgeBasesPager: @@ -776,7 +815,7 @@ def get_knowledge_base( 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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Retrieves the specified knowledge base. @@ -824,8 +863,10 @@ def sample_get_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -896,7 +937,7 @@ def create_knowledge_base( knowledge_base: Optional[gcd_knowledge_base.KnowledgeBase] = 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Creates a knowledge base. @@ -955,8 +996,10 @@ def sample_create_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -1028,7 +1071,7 @@ def delete_knowledge_base( 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 the specified knowledge base. @@ -1073,8 +1116,10 @@ def sample_delete_knowledge_base(): 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 @@ -1126,7 +1171,7 @@ def update_knowledge_base( 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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Updates the specified knowledge base. @@ -1184,8 +1229,10 @@ def sample_update_knowledge_base(): 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.dialogflow_v2beta1.types.KnowledgeBase: @@ -1269,7 +1316,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1280,8 +1327,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1322,7 +1371,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1333,8 +1382,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1375,7 +1426,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1390,8 +1441,10 @@ def cancel_operation( 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: None """ @@ -1428,7 +1481,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. @@ -1439,8 +1492,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. @@ -1481,7 +1536,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. @@ -1492,8 +1547,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-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/pagers.py index 35b1a8b79f1a..fe0b874b42c8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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 = knowledge_base.ListKnowledgeBasesRequest(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 = knowledge_base.ListKnowledgeBasesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py index 2d29e2d5c9f4..f471f7a67af8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import knowledge_base as gcd_knowledge_base from google.cloud.dialogflow_v2beta1.types import knowledge_base from .base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport +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.dialogflow.v2beta1.KnowledgeBases", + "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.dialogflow.v2beta1.KnowledgeBases", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class KnowledgeBasesGrpcTransport(KnowledgeBasesTransport): """gRPC backend transport for KnowledgeBases. @@ -184,7 +265,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_knowledge_bases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_knowledge_bases" not in self._stubs: - self._stubs["list_knowledge_bases"] = self.grpc_channel.unary_unary( + self._stubs["list_knowledge_bases"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/ListKnowledgeBases", request_serializer=knowledge_base.ListKnowledgeBasesRequest.serialize, response_deserializer=knowledge_base.ListKnowledgeBasesResponse.deserialize, @@ -295,7 +381,7 @@ def get_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_knowledge_base" not in self._stubs: - self._stubs["get_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["get_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/GetKnowledgeBase", request_serializer=knowledge_base.GetKnowledgeBaseRequest.serialize, response_deserializer=knowledge_base.KnowledgeBase.deserialize, @@ -327,7 +413,7 @@ def create_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_knowledge_base" not in self._stubs: - self._stubs["create_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["create_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/CreateKnowledgeBase", request_serializer=gcd_knowledge_base.CreateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -356,7 +442,7 @@ def delete_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_knowledge_base" not in self._stubs: - self._stubs["delete_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["delete_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/DeleteKnowledgeBase", request_serializer=knowledge_base.DeleteKnowledgeBaseRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -388,7 +474,7 @@ def update_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_knowledge_base" not in self._stubs: - self._stubs["update_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["update_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/UpdateKnowledgeBase", request_serializer=gcd_knowledge_base.UpdateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -396,7 +482,7 @@ def update_knowledge_base( return self._stubs["update_knowledge_base"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -408,7 +494,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -425,7 +511,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -444,7 +530,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -463,7 +549,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, @@ -480,7 +566,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-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py index f62cd644edc7..04e9f3efdeb7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import knowledge_base as gcd_knowledge_base from google.cloud.dialogflow_v2beta1.types import knowledge_base @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, KnowledgeBasesTransport from .grpc import KnowledgeBasesGrpcTransport +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.dialogflow.v2beta1.KnowledgeBases", + "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.dialogflow.v2beta1.KnowledgeBases", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class KnowledgeBasesGrpcAsyncIOTransport(KnowledgeBasesTransport): """gRPC AsyncIO backend transport for KnowledgeBases. @@ -231,10 +313,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 @@ -272,7 +357,7 @@ def list_knowledge_bases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_knowledge_bases" not in self._stubs: - self._stubs["list_knowledge_bases"] = self.grpc_channel.unary_unary( + self._stubs["list_knowledge_bases"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/ListKnowledgeBases", request_serializer=knowledge_base.ListKnowledgeBasesRequest.serialize, response_deserializer=knowledge_base.ListKnowledgeBasesResponse.deserialize, @@ -304,7 +389,7 @@ def get_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_knowledge_base" not in self._stubs: - self._stubs["get_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["get_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/GetKnowledgeBase", request_serializer=knowledge_base.GetKnowledgeBaseRequest.serialize, response_deserializer=knowledge_base.KnowledgeBase.deserialize, @@ -336,7 +421,7 @@ def create_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_knowledge_base" not in self._stubs: - self._stubs["create_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["create_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/CreateKnowledgeBase", request_serializer=gcd_knowledge_base.CreateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -367,7 +452,7 @@ def delete_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_knowledge_base" not in self._stubs: - self._stubs["delete_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["delete_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/DeleteKnowledgeBase", request_serializer=knowledge_base.DeleteKnowledgeBaseRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -399,7 +484,7 @@ def update_knowledge_base( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_knowledge_base" not in self._stubs: - self._stubs["update_knowledge_base"] = self.grpc_channel.unary_unary( + self._stubs["update_knowledge_base"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.KnowledgeBases/UpdateKnowledgeBase", request_serializer=gcd_knowledge_base.UpdateKnowledgeBaseRequest.serialize, response_deserializer=gcd_knowledge_base.KnowledgeBase.deserialize, @@ -467,7 +552,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: @@ -483,7 +568,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -500,7 +585,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +604,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -538,7 +623,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, @@ -555,7 +640,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-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py index 4bb477d76d8c..e83acc480f5f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/knowledge_bases/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 @@ -41,6 +41,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, @@ -109,9 +117,10 @@ def post_update_knowledge_base(self, response): def pre_create_knowledge_base( self, request: gcd_knowledge_base.CreateKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_knowledge_base.CreateKnowledgeBaseRequest, Sequence[Tuple[str, str]] + gcd_knowledge_base.CreateKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_knowledge_base @@ -134,8 +143,11 @@ def post_create_knowledge_base( def pre_delete_knowledge_base( self, request: knowledge_base.DeleteKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.DeleteKnowledgeBaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.DeleteKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_knowledge_base Override in a subclass to manipulate the request or metadata @@ -146,8 +158,10 @@ def pre_delete_knowledge_base( def pre_get_knowledge_base( self, request: knowledge_base.GetKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.GetKnowledgeBaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.GetKnowledgeBaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_knowledge_base Override in a subclass to manipulate the request or metadata @@ -169,8 +183,11 @@ def post_get_knowledge_base( def pre_list_knowledge_bases( self, request: knowledge_base.ListKnowledgeBasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[knowledge_base.ListKnowledgeBasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + knowledge_base.ListKnowledgeBasesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_knowledge_bases Override in a subclass to manipulate the request or metadata @@ -192,9 +209,10 @@ def post_list_knowledge_bases( def pre_update_knowledge_base( self, request: gcd_knowledge_base.UpdateKnowledgeBaseRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcd_knowledge_base.UpdateKnowledgeBaseRequest, Sequence[Tuple[str, str]] + gcd_knowledge_base.UpdateKnowledgeBaseRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_knowledge_base @@ -217,8 +235,10 @@ def post_update_knowledge_base( 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 @@ -240,8 +260,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 @@ -263,8 +285,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -284,8 +308,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -307,8 +333,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -451,7 +479,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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Call the create knowledge base method over HTTP. @@ -462,8 +490,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: ~.gcd_knowledge_base.KnowledgeBase: @@ -485,6 +515,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseCreateKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_create_knowledge_base( request, metadata ) @@ -501,6 +532,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 = 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.dialogflow_v2beta1.KnowledgeBasesClient.CreateKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "CreateKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._CreateKnowledgeBase._get_response( self._host, @@ -522,7 +580,31 @@ def __call__( pb_resp = gcd_knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_knowledge_base.KnowledgeBase.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.dialogflow_v2beta1.KnowledgeBasesClient.create_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "CreateKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteKnowledgeBase( @@ -560,7 +642,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 knowledge base method over HTTP. @@ -571,13 +653,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 = ( _BaseKnowledgeBasesRestTransport._BaseDeleteKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_delete_knowledge_base( request, metadata ) @@ -590,6 +675,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.dialogflow_v2beta1.KnowledgeBasesClient.DeleteKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "DeleteKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._DeleteKnowledgeBase._get_response( self._host, @@ -639,7 +751,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]]] = (), ) -> knowledge_base.KnowledgeBase: r"""Call the get knowledge base method over HTTP. @@ -650,8 +762,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: ~.knowledge_base.KnowledgeBase: @@ -673,6 +787,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_get_knowledge_base( request, metadata ) @@ -685,6 +800,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 = 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.dialogflow_v2beta1.KnowledgeBasesClient.GetKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetKnowledgeBase._get_response( self._host, @@ -705,7 +847,29 @@ def __call__( pb_resp = knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = knowledge_base.KnowledgeBase.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.dialogflow_v2beta1.KnowledgeBasesClient.get_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListKnowledgeBases( @@ -742,7 +906,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]]] = (), ) -> knowledge_base.ListKnowledgeBasesResponse: r"""Call the list knowledge bases method over HTTP. @@ -753,8 +917,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: ~.knowledge_base.ListKnowledgeBasesResponse: @@ -766,6 +932,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListKnowledgeBases._get_http_options() ) + request, metadata = self._interceptor.pre_list_knowledge_bases( request, metadata ) @@ -778,6 +945,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 = 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.dialogflow_v2beta1.KnowledgeBasesClient.ListKnowledgeBases", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListKnowledgeBases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListKnowledgeBases._get_response( self._host, @@ -798,7 +992,31 @@ def __call__( pb_resp = knowledge_base.ListKnowledgeBasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_knowledge_bases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + knowledge_base.ListKnowledgeBasesResponse.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.dialogflow_v2beta1.KnowledgeBasesClient.list_knowledge_bases", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListKnowledgeBases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateKnowledgeBase( @@ -837,7 +1055,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]]] = (), ) -> gcd_knowledge_base.KnowledgeBase: r"""Call the update knowledge base method over HTTP. @@ -848,8 +1066,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: ~.gcd_knowledge_base.KnowledgeBase: @@ -871,6 +1091,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseUpdateKnowledgeBase._get_http_options() ) + request, metadata = self._interceptor.pre_update_knowledge_base( request, metadata ) @@ -887,6 +1108,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 = 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.dialogflow_v2beta1.KnowledgeBasesClient.UpdateKnowledgeBase", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "UpdateKnowledgeBase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._UpdateKnowledgeBase._get_response( self._host, @@ -908,7 +1156,31 @@ def __call__( pb_resp = gcd_knowledge_base.KnowledgeBase.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_knowledge_base(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_knowledge_base.KnowledgeBase.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.dialogflow_v2beta1.KnowledgeBasesClient.update_knowledge_base", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "UpdateKnowledgeBase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1000,7 +1272,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. @@ -1010,8 +1282,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. @@ -1020,6 +1294,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1030,6 +1305,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.dialogflow_v2beta1.KnowledgeBasesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetLocation._get_response( self._host, @@ -1049,6 +1351,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.dialogflow_v2beta1.KnowledgeBasesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1089,7 +1412,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. @@ -1099,8 +1422,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. @@ -1109,6 +1434,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1119,6 +1445,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.dialogflow_v2beta1.KnowledgeBasesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListLocations._get_response( self._host, @@ -1138,6 +1491,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.dialogflow_v2beta1.KnowledgeBasesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1178,7 +1552,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1188,13 +1562,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 = ( _BaseKnowledgeBasesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1207,6 +1584,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.dialogflow_v2beta1.KnowledgeBasesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._CancelOperation._get_response( self._host, @@ -1262,7 +1666,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1272,8 +1676,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: operations_pb2.Operation: Response from GetOperation method. @@ -1282,6 +1688,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1292,6 +1699,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.dialogflow_v2beta1.KnowledgeBasesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._GetOperation._get_response( self._host, @@ -1311,6 +1745,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.KnowledgeBasesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1351,7 +1806,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1361,8 +1816,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1371,6 +1828,7 @@ def __call__( http_options = ( _BaseKnowledgeBasesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseKnowledgeBasesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1381,6 +1839,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.dialogflow_v2beta1.KnowledgeBasesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = KnowledgeBasesRestTransport._ListOperations._get_response( self._host, @@ -1400,6 +1885,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.KnowledgeBasesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.KnowledgeBases", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/async_client.py index 9e37b5a0c63a..789f5ba77886 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 ( AsyncIterable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ParticipantsTransport from .transports.grpc_asyncio import ParticipantsGrpcAsyncIOTransport +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 ParticipantsAsyncClient: """Service for managing @@ -278,6 +288,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.dialogflow_v2beta1.ParticipantsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "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.dialogflow.v2beta1.Participants", + "credentialsType": None, + }, + ) + async def create_participant( self, request: Optional[Union[gcd_participant.CreateParticipantRequest, dict]] = None, @@ -286,7 +318,7 @@ async def create_participant( participant: Optional[gcd_participant.Participant] = 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]]] = (), ) -> gcd_participant.Participant: r"""Creates a new participant in a conversation. @@ -336,8 +368,10 @@ async def sample_create_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -400,7 +434,7 @@ async def get_participant( 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]]] = (), ) -> participant.Participant: r"""Retrieves a conversation participant. @@ -444,8 +478,10 @@ async def sample_get_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -506,7 +542,7 @@ async def list_participants( 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.ListParticipantsAsyncPager: r"""Returns the list of all participants in the specified conversation. @@ -553,8 +589,10 @@ async def sample_list_participants(): 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.dialogflow_v2beta1.services.participants.pagers.ListParticipantsAsyncPager: @@ -630,7 +668,7 @@ async def update_participant( 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]]] = (), ) -> gcd_participant.Participant: r"""Updates the specified participant. @@ -678,8 +716,10 @@ async def sample_update_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -747,7 +787,7 @@ async def analyze_content( event_input: Optional[session.EventInput] = 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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. @@ -816,8 +856,10 @@ async def sample_analyze_content(): 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.dialogflow_v2beta1.types.AnalyzeContentResponse: @@ -887,7 +929,7 @@ def streaming_analyze_content( *, 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]]] = (), ) -> Awaitable[AsyncIterable[participant.StreamingAnalyzeContentResponse]]: r"""Adds a text (e.g., chat) or audio (e.g., phone recording) message from a participant into the conversation. Note: This @@ -998,8 +1040,10 @@ def request_generator(): 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: AsyncIterable[google.cloud.dialogflow_v2beta1.types.StreamingAnalyzeContentResponse]: @@ -1059,7 +1103,7 @@ async def suggest_articles( 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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Gets suggested articles for a participant based on specific historical messages. @@ -1112,8 +1156,10 @@ async def sample_suggest_articles(): 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.dialogflow_v2beta1.types.SuggestArticlesResponse: @@ -1174,7 +1220,7 @@ async def suggest_faq_answers( 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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Gets suggested faq answers for a participant based on specific historical messages. @@ -1220,8 +1266,10 @@ async def sample_suggest_faq_answers(): 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.dialogflow_v2beta1.types.SuggestFaqAnswersResponse: @@ -1282,7 +1330,7 @@ async def suggest_smart_replies( 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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Gets smart replies for a participant based on specific historical messages. @@ -1328,8 +1376,10 @@ async def sample_suggest_smart_replies(): 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.dialogflow_v2beta1.types.SuggestSmartRepliesResponse: @@ -1391,7 +1441,7 @@ async def suggest_knowledge_assist( *, 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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Gets knowledge assist suggestions based on historical messages. @@ -1429,8 +1479,10 @@ async def sample_suggest_knowledge_assist(): 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.dialogflow_v2beta1.types.SuggestKnowledgeAssistResponse: @@ -1476,7 +1528,7 @@ async def list_suggestions( *, 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.ListSuggestionsAsyncPager: r"""Deprecated: Use inline suggestion, event based suggestion or Suggestion\* API instead. See @@ -1532,8 +1584,10 @@ async def sample_list_suggestions(): 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.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsAsyncPager: @@ -1597,7 +1651,7 @@ async def compile_suggestion( *, 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]]] = (), ) -> participant.CompileSuggestionResponse: r"""Deprecated. use [SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles] @@ -1647,8 +1701,10 @@ async def sample_compile_suggestion(): 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.dialogflow_v2beta1.types.CompileSuggestionResponse: @@ -1699,7 +1755,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1710,8 +1766,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1752,7 +1810,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1763,8 +1821,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1805,7 +1865,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1820,8 +1880,10 @@ async def cancel_operation( 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: None """ @@ -1858,7 +1920,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. @@ -1869,8 +1931,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. @@ -1911,7 +1975,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. @@ -1922,8 +1986,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-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/client.py index 5c70dcc50ff2..861e727822b8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -734,6 +744,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( @@ -796,6 +810,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.dialogflow_v2beta1.ParticipantsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "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.dialogflow.v2beta1.Participants", + "credentialsType": None, + }, + ) + def create_participant( self, request: Optional[Union[gcd_participant.CreateParticipantRequest, dict]] = None, @@ -804,7 +841,7 @@ def create_participant( participant: Optional[gcd_participant.Participant] = 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]]] = (), ) -> gcd_participant.Participant: r"""Creates a new participant in a conversation. @@ -854,8 +891,10 @@ def sample_create_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -915,7 +954,7 @@ def get_participant( 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]]] = (), ) -> participant.Participant: r"""Retrieves a conversation participant. @@ -959,8 +998,10 @@ def sample_get_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -1018,7 +1059,7 @@ def list_participants( 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.ListParticipantsPager: r"""Returns the list of all participants in the specified conversation. @@ -1065,8 +1106,10 @@ def sample_list_participants(): 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.dialogflow_v2beta1.services.participants.pagers.ListParticipantsPager: @@ -1139,7 +1182,7 @@ def update_participant( 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]]] = (), ) -> gcd_participant.Participant: r"""Updates the specified participant. @@ -1187,8 +1230,10 @@ def sample_update_participant(): 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.dialogflow_v2beta1.types.Participant: @@ -1253,7 +1298,7 @@ def analyze_content( event_input: Optional[session.EventInput] = 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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. @@ -1322,8 +1367,10 @@ def sample_analyze_content(): 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.dialogflow_v2beta1.types.AnalyzeContentResponse: @@ -1388,7 +1435,7 @@ def streaming_analyze_content( *, 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]]] = (), ) -> Iterable[participant.StreamingAnalyzeContentResponse]: r"""Adds a text (e.g., chat) or audio (e.g., phone recording) message from a participant into the conversation. Note: This @@ -1499,8 +1546,10 @@ def request_generator(): 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: Iterable[google.cloud.dialogflow_v2beta1.types.StreamingAnalyzeContentResponse]: @@ -1560,7 +1609,7 @@ def suggest_articles( 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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Gets suggested articles for a participant based on specific historical messages. @@ -1613,8 +1662,10 @@ def sample_suggest_articles(): 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.dialogflow_v2beta1.types.SuggestArticlesResponse: @@ -1672,7 +1723,7 @@ def suggest_faq_answers( 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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Gets suggested faq answers for a participant based on specific historical messages. @@ -1718,8 +1769,10 @@ def sample_suggest_faq_answers(): 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.dialogflow_v2beta1.types.SuggestFaqAnswersResponse: @@ -1777,7 +1830,7 @@ def suggest_smart_replies( 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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Gets smart replies for a participant based on specific historical messages. @@ -1823,8 +1876,10 @@ def sample_suggest_smart_replies(): 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.dialogflow_v2beta1.types.SuggestSmartRepliesResponse: @@ -1883,7 +1938,7 @@ def suggest_knowledge_assist( *, 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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Gets knowledge assist suggestions based on historical messages. @@ -1921,8 +1976,10 @@ def sample_suggest_knowledge_assist(): 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.dialogflow_v2beta1.types.SuggestKnowledgeAssistResponse: @@ -1966,7 +2023,7 @@ def list_suggestions( *, 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.ListSuggestionsPager: r"""Deprecated: Use inline suggestion, event based suggestion or Suggestion\* API instead. See @@ -2022,8 +2079,10 @@ def sample_list_suggestions(): 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.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsPager: @@ -2085,7 +2144,7 @@ def compile_suggestion( *, 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]]] = (), ) -> participant.CompileSuggestionResponse: r"""Deprecated. use [SuggestArticles][google.cloud.dialogflow.v2beta1.Participants.SuggestArticles] @@ -2135,8 +2194,10 @@ def sample_compile_suggestion(): 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.dialogflow_v2beta1.types.CompileSuggestionResponse: @@ -2197,7 +2258,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -2208,8 +2269,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -2250,7 +2313,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -2261,8 +2324,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -2303,7 +2368,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -2318,8 +2383,10 @@ def cancel_operation( 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: None """ @@ -2356,7 +2423,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. @@ -2367,8 +2434,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. @@ -2409,7 +2478,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. @@ -2420,8 +2489,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-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/pagers.py index 8e7873ca7062..3fd9d8dcd085 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 = participant.ListParticipantsRequest(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 = participant.ListParticipantsRequest(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 = participant.ListSuggestionsRequest(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 = participant.ListSuggestionsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py index 44deb110c219..38ee5d2dabf7 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import participant as gcd_participant from google.cloud.dialogflow_v2beta1.types import participant from .base import DEFAULT_CLIENT_INFO, ParticipantsTransport +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.dialogflow.v2beta1.Participants", + "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.dialogflow.v2beta1.Participants", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParticipantsGrpcTransport(ParticipantsTransport): """gRPC backend transport for Participants. @@ -183,7 +264,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 @@ -259,7 +345,7 @@ def create_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_participant" not in self._stubs: - self._stubs["create_participant"] = self.grpc_channel.unary_unary( + self._stubs["create_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/CreateParticipant", request_serializer=gcd_participant.CreateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -285,7 +371,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/GetParticipant", request_serializer=participant.GetParticipantRequest.serialize, response_deserializer=participant.Participant.deserialize, @@ -314,7 +400,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/ListParticipants", request_serializer=participant.ListParticipantsRequest.serialize, response_deserializer=participant.ListParticipantsResponse.deserialize, @@ -342,7 +428,7 @@ def update_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_participant" not in self._stubs: - self._stubs["update_participant"] = self.grpc_channel.unary_unary( + self._stubs["update_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/UpdateParticipant", request_serializer=gcd_participant.UpdateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -375,7 +461,7 @@ def analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_content" not in self._stubs: - self._stubs["analyze_content"] = self.grpc_channel.unary_unary( + self._stubs["analyze_content"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/AnalyzeContent", request_serializer=gcd_participant.AnalyzeContentRequest.serialize, response_deserializer=gcd_participant.AnalyzeContentResponse.deserialize, @@ -418,7 +504,9 @@ def streaming_analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_analyze_content" not in self._stubs: - self._stubs["streaming_analyze_content"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_analyze_content" + ] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2beta1.Participants/StreamingAnalyzeContent", request_serializer=participant.StreamingAnalyzeContentRequest.serialize, response_deserializer=participant.StreamingAnalyzeContentResponse.deserialize, @@ -454,7 +542,7 @@ def suggest_articles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_articles" not in self._stubs: - self._stubs["suggest_articles"] = self.grpc_channel.unary_unary( + self._stubs["suggest_articles"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestArticles", request_serializer=participant.SuggestArticlesRequest.serialize, response_deserializer=participant.SuggestArticlesResponse.deserialize, @@ -483,7 +571,7 @@ def suggest_faq_answers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_faq_answers" not in self._stubs: - self._stubs["suggest_faq_answers"] = self.grpc_channel.unary_unary( + self._stubs["suggest_faq_answers"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestFaqAnswers", request_serializer=participant.SuggestFaqAnswersRequest.serialize, response_deserializer=participant.SuggestFaqAnswersResponse.deserialize, @@ -513,7 +601,7 @@ def suggest_smart_replies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_smart_replies" not in self._stubs: - self._stubs["suggest_smart_replies"] = self.grpc_channel.unary_unary( + self._stubs["suggest_smart_replies"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestSmartReplies", request_serializer=participant.SuggestSmartRepliesRequest.serialize, response_deserializer=participant.SuggestSmartRepliesResponse.deserialize, @@ -543,7 +631,7 @@ def suggest_knowledge_assist( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_knowledge_assist" not in self._stubs: - self._stubs["suggest_knowledge_assist"] = self.grpc_channel.unary_unary( + self._stubs["suggest_knowledge_assist"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestKnowledgeAssist", request_serializer=participant.SuggestKnowledgeAssistRequest.serialize, response_deserializer=participant.SuggestKnowledgeAssistResponse.deserialize, @@ -590,7 +678,7 @@ def list_suggestions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_suggestions" not in self._stubs: - self._stubs["list_suggestions"] = self.grpc_channel.unary_unary( + self._stubs["list_suggestions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/ListSuggestions", request_serializer=participant.ListSuggestionsRequest.serialize, response_deserializer=participant.ListSuggestionsResponse.deserialize, @@ -632,7 +720,7 @@ def compile_suggestion( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compile_suggestion" not in self._stubs: - self._stubs["compile_suggestion"] = self.grpc_channel.unary_unary( + self._stubs["compile_suggestion"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/CompileSuggestion", request_serializer=participant.CompileSuggestionRequest.serialize, response_deserializer=participant.CompileSuggestionResponse.deserialize, @@ -640,7 +728,7 @@ def compile_suggestion( return self._stubs["compile_suggestion"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -652,7 +740,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -669,7 +757,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -688,7 +776,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -707,7 +795,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, @@ -724,7 +812,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-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py index 853eafbe4e03..5751becf618a 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import participant as gcd_participant from google.cloud.dialogflow_v2beta1.types import participant @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, ParticipantsTransport from .grpc import ParticipantsGrpcTransport +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.dialogflow.v2beta1.Participants", + "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.dialogflow.v2beta1.Participants", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ParticipantsGrpcAsyncIOTransport(ParticipantsTransport): """gRPC AsyncIO backend transport for Participants. @@ -230,10 +312,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 @@ -268,7 +353,7 @@ def create_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_participant" not in self._stubs: - self._stubs["create_participant"] = self.grpc_channel.unary_unary( + self._stubs["create_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/CreateParticipant", request_serializer=gcd_participant.CreateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -296,7 +381,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/GetParticipant", request_serializer=participant.GetParticipantRequest.serialize, response_deserializer=participant.Participant.deserialize, @@ -326,7 +411,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/ListParticipants", request_serializer=participant.ListParticipantsRequest.serialize, response_deserializer=participant.ListParticipantsResponse.deserialize, @@ -355,7 +440,7 @@ def update_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_participant" not in self._stubs: - self._stubs["update_participant"] = self.grpc_channel.unary_unary( + self._stubs["update_participant"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/UpdateParticipant", request_serializer=gcd_participant.UpdateParticipantRequest.serialize, response_deserializer=gcd_participant.Participant.deserialize, @@ -389,7 +474,7 @@ def analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_content" not in self._stubs: - self._stubs["analyze_content"] = self.grpc_channel.unary_unary( + self._stubs["analyze_content"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/AnalyzeContent", request_serializer=gcd_participant.AnalyzeContentRequest.serialize, response_deserializer=gcd_participant.AnalyzeContentResponse.deserialize, @@ -432,7 +517,9 @@ def streaming_analyze_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_analyze_content" not in self._stubs: - self._stubs["streaming_analyze_content"] = self.grpc_channel.stream_stream( + self._stubs[ + "streaming_analyze_content" + ] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2beta1.Participants/StreamingAnalyzeContent", request_serializer=participant.StreamingAnalyzeContentRequest.serialize, response_deserializer=participant.StreamingAnalyzeContentResponse.deserialize, @@ -469,7 +556,7 @@ def suggest_articles( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_articles" not in self._stubs: - self._stubs["suggest_articles"] = self.grpc_channel.unary_unary( + self._stubs["suggest_articles"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestArticles", request_serializer=participant.SuggestArticlesRequest.serialize, response_deserializer=participant.SuggestArticlesResponse.deserialize, @@ -499,7 +586,7 @@ def suggest_faq_answers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_faq_answers" not in self._stubs: - self._stubs["suggest_faq_answers"] = self.grpc_channel.unary_unary( + self._stubs["suggest_faq_answers"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestFaqAnswers", request_serializer=participant.SuggestFaqAnswersRequest.serialize, response_deserializer=participant.SuggestFaqAnswersResponse.deserialize, @@ -529,7 +616,7 @@ def suggest_smart_replies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_smart_replies" not in self._stubs: - self._stubs["suggest_smart_replies"] = self.grpc_channel.unary_unary( + self._stubs["suggest_smart_replies"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestSmartReplies", request_serializer=participant.SuggestSmartRepliesRequest.serialize, response_deserializer=participant.SuggestSmartRepliesResponse.deserialize, @@ -559,7 +646,7 @@ def suggest_knowledge_assist( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "suggest_knowledge_assist" not in self._stubs: - self._stubs["suggest_knowledge_assist"] = self.grpc_channel.unary_unary( + self._stubs["suggest_knowledge_assist"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/SuggestKnowledgeAssist", request_serializer=participant.SuggestKnowledgeAssistRequest.serialize, response_deserializer=participant.SuggestKnowledgeAssistResponse.deserialize, @@ -607,7 +694,7 @@ def list_suggestions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_suggestions" not in self._stubs: - self._stubs["list_suggestions"] = self.grpc_channel.unary_unary( + self._stubs["list_suggestions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/ListSuggestions", request_serializer=participant.ListSuggestionsRequest.serialize, response_deserializer=participant.ListSuggestionsResponse.deserialize, @@ -650,7 +737,7 @@ def compile_suggestion( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "compile_suggestion" not in self._stubs: - self._stubs["compile_suggestion"] = self.grpc_channel.unary_unary( + self._stubs["compile_suggestion"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Participants/CompileSuggestion", request_serializer=participant.CompileSuggestionRequest.serialize, response_deserializer=participant.CompileSuggestionResponse.deserialize, @@ -762,7 +849,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: @@ -778,7 +865,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -795,7 +882,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -814,7 +901,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -833,7 +920,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, @@ -850,7 +937,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-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py index f5cb9d44ff58..fba5d657fc34 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/participants/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 @@ -40,6 +40,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, @@ -160,8 +168,10 @@ def post_update_participant(self, response): def pre_analyze_content( self, request: gcd_participant.AnalyzeContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.AnalyzeContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.AnalyzeContentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for analyze_content Override in a subclass to manipulate the request or metadata @@ -183,8 +193,10 @@ def post_analyze_content( def pre_compile_suggestion( self, request: participant.CompileSuggestionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.CompileSuggestionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.CompileSuggestionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for compile_suggestion Override in a subclass to manipulate the request or metadata @@ -206,8 +218,11 @@ def post_compile_suggestion( def pre_create_participant( self, request: gcd_participant.CreateParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.CreateParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.CreateParticipantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_participant Override in a subclass to manipulate the request or metadata @@ -229,8 +244,10 @@ def post_create_participant( def pre_get_participant( self, request: participant.GetParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.GetParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.GetParticipantRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_participant Override in a subclass to manipulate the request or metadata @@ -252,8 +269,10 @@ def post_get_participant( def pre_list_participants( self, request: participant.ListParticipantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.ListParticipantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.ListParticipantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participants Override in a subclass to manipulate the request or metadata @@ -275,8 +294,10 @@ def post_list_participants( def pre_list_suggestions( self, request: participant.ListSuggestionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.ListSuggestionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.ListSuggestionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_suggestions Override in a subclass to manipulate the request or metadata @@ -298,8 +319,10 @@ def post_list_suggestions( def pre_suggest_articles( self, request: participant.SuggestArticlesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestArticlesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestArticlesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_articles Override in a subclass to manipulate the request or metadata @@ -321,8 +344,10 @@ def post_suggest_articles( def pre_suggest_faq_answers( self, request: participant.SuggestFaqAnswersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestFaqAnswersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestFaqAnswersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_faq_answers Override in a subclass to manipulate the request or metadata @@ -344,8 +369,11 @@ def post_suggest_faq_answers( def pre_suggest_knowledge_assist( self, request: participant.SuggestKnowledgeAssistRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestKnowledgeAssistRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestKnowledgeAssistRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for suggest_knowledge_assist Override in a subclass to manipulate the request or metadata @@ -367,8 +395,10 @@ def post_suggest_knowledge_assist( def pre_suggest_smart_replies( self, request: participant.SuggestSmartRepliesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[participant.SuggestSmartRepliesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + participant.SuggestSmartRepliesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for suggest_smart_replies Override in a subclass to manipulate the request or metadata @@ -390,8 +420,11 @@ def post_suggest_smart_replies( def pre_update_participant( self, request: gcd_participant.UpdateParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_participant.UpdateParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_participant.UpdateParticipantRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_participant Override in a subclass to manipulate the request or metadata @@ -413,8 +446,10 @@ def post_update_participant( 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 @@ -436,8 +471,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 @@ -459,8 +496,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -480,8 +519,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -503,8 +544,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -646,7 +689,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]]] = (), ) -> gcd_participant.AnalyzeContentResponse: r"""Call the analyze content method over HTTP. @@ -657,8 +700,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: ~.gcd_participant.AnalyzeContentResponse: @@ -670,6 +715,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseAnalyzeContent._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_content(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseAnalyzeContent._get_transcoded_request( http_options, request @@ -684,6 +730,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 = 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.dialogflow_v2beta1.ParticipantsClient.AnalyzeContent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "AnalyzeContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._AnalyzeContent._get_response( self._host, @@ -705,7 +778,31 @@ def __call__( pb_resp = gcd_participant.AnalyzeContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.AnalyzeContentResponse.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.dialogflow_v2beta1.ParticipantsClient.analyze_content", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "AnalyzeContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CompileSuggestion( @@ -743,7 +840,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]]] = (), ) -> participant.CompileSuggestionResponse: r"""Call the compile suggestion method over HTTP. @@ -754,8 +851,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: ~.participant.CompileSuggestionResponse: @@ -767,6 +866,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseCompileSuggestion._get_http_options() ) + request, metadata = self._interceptor.pre_compile_suggestion( request, metadata ) @@ -783,6 +883,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 = 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.dialogflow_v2beta1.ParticipantsClient.CompileSuggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "CompileSuggestion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._CompileSuggestion._get_response( self._host, @@ -804,7 +931,31 @@ def __call__( pb_resp = participant.CompileSuggestionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_compile_suggestion(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.CompileSuggestionResponse.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.dialogflow_v2beta1.ParticipantsClient.compile_suggestion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "CompileSuggestion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateParticipant( @@ -842,7 +993,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]]] = (), ) -> gcd_participant.Participant: r"""Call the create participant method over HTTP. @@ -853,8 +1004,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: ~.gcd_participant.Participant: @@ -866,6 +1019,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseCreateParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_create_participant( request, metadata ) @@ -882,6 +1036,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 = 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.dialogflow_v2beta1.ParticipantsClient.CreateParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "CreateParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._CreateParticipant._get_response( self._host, @@ -903,7 +1084,29 @@ def __call__( pb_resp = gcd_participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.Participant.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.dialogflow_v2beta1.ParticipantsClient.create_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "CreateParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipant( @@ -940,7 +1143,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]]] = (), ) -> participant.Participant: r"""Call the get participant method over HTTP. @@ -951,8 +1154,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: ~.participant.Participant: @@ -964,6 +1169,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseGetParticipant._get_transcoded_request( http_options, request @@ -974,6 +1180,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 = 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.dialogflow_v2beta1.ParticipantsClient.GetParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetParticipant._get_response( self._host, @@ -994,7 +1227,29 @@ def __call__( pb_resp = participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.Participant.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.dialogflow_v2beta1.ParticipantsClient.get_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipants( @@ -1031,7 +1286,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]]] = (), ) -> participant.ListParticipantsResponse: r"""Call the list participants method over HTTP. @@ -1042,8 +1297,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: ~.participant.ListParticipantsResponse: @@ -1055,6 +1312,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListParticipants._get_http_options() ) + request, metadata = self._interceptor.pre_list_participants( request, metadata ) @@ -1067,6 +1325,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 = 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.dialogflow_v2beta1.ParticipantsClient.ListParticipants", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListParticipants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListParticipants._get_response( self._host, @@ -1087,7 +1372,31 @@ def __call__( pb_resp = participant.ListParticipantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.ListParticipantsResponse.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.dialogflow_v2beta1.ParticipantsClient.list_participants", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListParticipants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSuggestions( @@ -1124,7 +1433,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]]] = (), ) -> participant.ListSuggestionsResponse: r"""Call the list suggestions method over HTTP. @@ -1135,8 +1444,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: ~.participant.ListSuggestionsResponse: @@ -1148,6 +1459,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListSuggestions._get_http_options() ) + request, metadata = self._interceptor.pre_list_suggestions( request, metadata ) @@ -1160,6 +1472,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 = 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.dialogflow_v2beta1.ParticipantsClient.ListSuggestions", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListSuggestions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListSuggestions._get_response( self._host, @@ -1180,7 +1519,31 @@ def __call__( pb_resp = participant.ListSuggestionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_suggestions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.ListSuggestionsResponse.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.dialogflow_v2beta1.ParticipantsClient.list_suggestions", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListSuggestions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingAnalyzeContent( @@ -1196,7 +1559,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingAnalyzeContent is not available over REST transport" @@ -1237,7 +1600,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]]] = (), ) -> participant.SuggestArticlesResponse: r"""Call the suggest articles method over HTTP. @@ -1248,8 +1611,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: ~.participant.SuggestArticlesResponse: @@ -1261,6 +1626,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestArticles._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_articles( request, metadata ) @@ -1277,6 +1643,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 = 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.dialogflow_v2beta1.ParticipantsClient.SuggestArticles", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestArticles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestArticles._get_response( self._host, @@ -1298,7 +1691,31 @@ def __call__( pb_resp = participant.SuggestArticlesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_articles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestArticlesResponse.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.dialogflow_v2beta1.ParticipantsClient.suggest_articles", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestArticles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestFaqAnswers( @@ -1336,7 +1753,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]]] = (), ) -> participant.SuggestFaqAnswersResponse: r"""Call the suggest faq answers method over HTTP. @@ -1347,8 +1764,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: ~.participant.SuggestFaqAnswersResponse: @@ -1360,6 +1779,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestFaqAnswers._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_faq_answers( request, metadata ) @@ -1376,6 +1796,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 = 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.dialogflow_v2beta1.ParticipantsClient.SuggestFaqAnswers", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestFaqAnswers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestFaqAnswers._get_response( self._host, @@ -1397,7 +1844,31 @@ def __call__( pb_resp = participant.SuggestFaqAnswersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_faq_answers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestFaqAnswersResponse.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.dialogflow_v2beta1.ParticipantsClient.suggest_faq_answers", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestFaqAnswers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestKnowledgeAssist( @@ -1435,7 +1906,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]]] = (), ) -> participant.SuggestKnowledgeAssistResponse: r"""Call the suggest knowledge assist method over HTTP. @@ -1446,8 +1917,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: ~.participant.SuggestKnowledgeAssistResponse: @@ -1459,6 +1932,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestKnowledgeAssist._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_knowledge_assist( request, metadata ) @@ -1475,6 +1949,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 = 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.dialogflow_v2beta1.ParticipantsClient.SuggestKnowledgeAssist", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestKnowledgeAssist", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestKnowledgeAssist._get_response( self._host, @@ -1496,7 +1997,31 @@ def __call__( pb_resp = participant.SuggestKnowledgeAssistResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_knowledge_assist(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + participant.SuggestKnowledgeAssistResponse.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.dialogflow_v2beta1.ParticipantsClient.suggest_knowledge_assist", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestKnowledgeAssist", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SuggestSmartReplies( @@ -1534,7 +2059,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]]] = (), ) -> participant.SuggestSmartRepliesResponse: r"""Call the suggest smart replies method over HTTP. @@ -1545,8 +2070,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: ~.participant.SuggestSmartRepliesResponse: @@ -1558,6 +2085,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseSuggestSmartReplies._get_http_options() ) + request, metadata = self._interceptor.pre_suggest_smart_replies( request, metadata ) @@ -1574,6 +2102,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 = 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.dialogflow_v2beta1.ParticipantsClient.SuggestSmartReplies", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestSmartReplies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._SuggestSmartReplies._get_response( self._host, @@ -1595,7 +2150,31 @@ def __call__( pb_resp = participant.SuggestSmartRepliesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_suggest_smart_replies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = participant.SuggestSmartRepliesResponse.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.dialogflow_v2beta1.ParticipantsClient.suggest_smart_replies", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "SuggestSmartReplies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateParticipant( @@ -1633,7 +2212,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]]] = (), ) -> gcd_participant.Participant: r"""Call the update participant method over HTTP. @@ -1644,8 +2223,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: ~.gcd_participant.Participant: @@ -1657,6 +2238,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseUpdateParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_update_participant( request, metadata ) @@ -1673,6 +2255,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 = 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.dialogflow_v2beta1.ParticipantsClient.UpdateParticipant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "UpdateParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._UpdateParticipant._get_response( self._host, @@ -1694,7 +2303,29 @@ def __call__( pb_resp = gcd_participant.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_participant.Participant.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.dialogflow_v2beta1.ParticipantsClient.update_participant", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "UpdateParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1856,7 +2487,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. @@ -1866,8 +2497,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. @@ -1876,6 +2509,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseParticipantsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1890,6 +2524,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.dialogflow_v2beta1.ParticipantsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetLocation._get_response( self._host, @@ -1909,6 +2570,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.dialogflow_v2beta1.ParticipantsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1949,7 +2631,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. @@ -1959,8 +2641,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. @@ -1969,6 +2653,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1979,6 +2664,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.dialogflow_v2beta1.ParticipantsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListLocations._get_response( self._host, @@ -1998,6 +2710,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.dialogflow_v2beta1.ParticipantsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2038,7 +2771,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -2048,13 +2781,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 = ( _BaseParticipantsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2067,6 +2803,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.dialogflow_v2beta1.ParticipantsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._CancelOperation._get_response( self._host, @@ -2122,7 +2885,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -2132,8 +2895,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: operations_pb2.Operation: Response from GetOperation method. @@ -2142,6 +2907,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2154,6 +2920,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.dialogflow_v2beta1.ParticipantsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._GetOperation._get_response( self._host, @@ -2173,6 +2966,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.ParticipantsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2213,7 +3027,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2223,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -2233,6 +3049,7 @@ def __call__( http_options = ( _BaseParticipantsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseParticipantsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2243,6 +3060,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.dialogflow_v2beta1.ParticipantsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ParticipantsRestTransport._ListOperations._get_response( self._host, @@ -2262,6 +3106,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.ParticipantsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Participants", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py index f27b68888011..fc23fd5bf22b 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport from .transports.grpc_asyncio import SessionEntityTypesGrpcAsyncIOTransport +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 SessionEntityTypesAsyncClient: """Service for managing @@ -272,6 +282,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.dialogflow_v2beta1.SessionEntityTypesAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "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.dialogflow.v2beta1.SessionEntityTypes", + "credentialsType": None, + }, + ) + async def list_session_entity_types( self, request: Optional[ @@ -281,7 +313,7 @@ async def list_session_entity_types( 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.ListSessionEntityTypesAsyncPager: r"""Returns the list of all session entity types in the specified session. @@ -340,8 +372,10 @@ async def sample_list_session_entity_types(): 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.dialogflow_v2beta1.services.session_entity_types.pagers.ListSessionEntityTypesAsyncPager: @@ -418,7 +452,7 @@ async def get_session_entity_type( 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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. @@ -476,8 +510,10 @@ async def sample_get_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -549,7 +585,7 @@ async def create_session_entity_type( session_entity_type: Optional[gcd_session_entity_type.SessionEntityType] = 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. @@ -617,8 +653,10 @@ async def sample_create_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -694,7 +732,7 @@ async def update_session_entity_type( 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. @@ -748,8 +786,10 @@ async def sample_update_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -826,7 +866,7 @@ async def delete_session_entity_type( 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 the specified session entity type. @@ -881,8 +921,10 @@ async def sample_delete_session_entity_type(): 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 @@ -933,7 +975,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -944,8 +986,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -986,7 +1030,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -997,8 +1041,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1039,7 +1085,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1054,8 +1100,10 @@ async def cancel_operation( 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: None """ @@ -1092,7 +1140,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. @@ -1103,8 +1151,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. @@ -1145,7 +1195,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. @@ -1156,8 +1206,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-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py index c425ed1b4f59..ff6e0f3b08ee 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -592,6 +602,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( @@ -658,6 +672,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.dialogflow_v2beta1.SessionEntityTypesClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "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.dialogflow.v2beta1.SessionEntityTypes", + "credentialsType": None, + }, + ) + def list_session_entity_types( self, request: Optional[ @@ -667,7 +704,7 @@ def list_session_entity_types( 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.ListSessionEntityTypesPager: r"""Returns the list of all session entity types in the specified session. @@ -726,8 +763,10 @@ def sample_list_session_entity_types(): 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.dialogflow_v2beta1.services.session_entity_types.pagers.ListSessionEntityTypesPager: @@ -803,7 +842,7 @@ def get_session_entity_type( 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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. @@ -861,8 +900,10 @@ def sample_get_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -931,7 +972,7 @@ def create_session_entity_type( session_entity_type: Optional[gcd_session_entity_type.SessionEntityType] = 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Creates a session entity type. @@ -999,8 +1040,10 @@ def sample_create_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -1075,7 +1118,7 @@ def update_session_entity_type( 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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. @@ -1129,8 +1172,10 @@ def sample_update_session_entity_type(): 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.dialogflow_v2beta1.types.SessionEntityType: @@ -1206,7 +1251,7 @@ def delete_session_entity_type( 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 the specified session entity type. @@ -1261,8 +1306,10 @@ def sample_delete_session_entity_type(): 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 @@ -1325,7 +1372,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1336,8 +1383,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1378,7 +1427,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1389,8 +1438,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1431,7 +1482,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1446,8 +1497,10 @@ def cancel_operation( 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: None """ @@ -1484,7 +1537,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. @@ -1495,8 +1548,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. @@ -1537,7 +1592,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. @@ -1548,8 +1603,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-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/pagers.py index dd756313dc51..a03d1b5acad9 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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 = session_entity_type.ListSessionEntityTypesRequest(request) @@ -143,7 +145,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. @@ -157,8 +159,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 = session_entity_type.ListSessionEntityTypesRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py index 28a1cd698235..b1b26406fc39 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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 @@ -23,7 +26,10 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import ( session_entity_type as gcd_session_entity_type, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport +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.dialogflow.v2beta1.SessionEntityTypes", + "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.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionEntityTypesGrpcTransport(SessionEntityTypesTransport): """gRPC backend transport for SessionEntityTypes. @@ -186,7 +267,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 @@ -267,7 +353,7 @@ def list_session_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_session_entity_types" not in self._stubs: - self._stubs["list_session_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_session_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/ListSessionEntityTypes", request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, @@ -300,7 +386,7 @@ def get_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_session_entity_type" not in self._stubs: - self._stubs["get_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_session_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/GetSessionEntityType", request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, response_deserializer=session_entity_type.SessionEntityType.deserialize, @@ -336,7 +422,9 @@ def create_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_session_entity_type" not in self._stubs: - self._stubs["create_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/CreateSessionEntityType", request_serializer=gcd_session_entity_type.CreateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -369,7 +457,9 @@ def update_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_session_entity_type" not in self._stubs: - self._stubs["update_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/UpdateSessionEntityType", request_serializer=gcd_session_entity_type.UpdateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -401,7 +491,9 @@ def delete_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_session_entity_type" not in self._stubs: - self._stubs["delete_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/DeleteSessionEntityType", request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -409,7 +501,7 @@ def delete_session_entity_type( return self._stubs["delete_session_entity_type"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -421,7 +513,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -438,7 +530,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -457,7 +549,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -476,7 +568,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, @@ -493,7 +585,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-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py index e9f404886738..e435818e85c8 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import ( session_entity_type as gcd_session_entity_type, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, SessionEntityTypesTransport from .grpc import SessionEntityTypesGrpcTransport +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.dialogflow.v2beta1.SessionEntityTypes", + "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.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionEntityTypesGrpcAsyncIOTransport(SessionEntityTypesTransport): """gRPC AsyncIO backend transport for SessionEntityTypes. @@ -233,10 +315,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 @@ -275,7 +360,7 @@ def list_session_entity_types( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_session_entity_types" not in self._stubs: - self._stubs["list_session_entity_types"] = self.grpc_channel.unary_unary( + self._stubs["list_session_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/ListSessionEntityTypes", request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, @@ -308,7 +393,7 @@ def get_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_session_entity_type" not in self._stubs: - self._stubs["get_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs["get_session_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/GetSessionEntityType", request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, response_deserializer=session_entity_type.SessionEntityType.deserialize, @@ -344,7 +429,9 @@ def create_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_session_entity_type" not in self._stubs: - self._stubs["create_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/CreateSessionEntityType", request_serializer=gcd_session_entity_type.CreateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -377,7 +464,9 @@ def update_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_session_entity_type" not in self._stubs: - self._stubs["update_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/UpdateSessionEntityType", request_serializer=gcd_session_entity_type.UpdateSessionEntityTypeRequest.serialize, response_deserializer=gcd_session_entity_type.SessionEntityType.deserialize, @@ -409,7 +498,9 @@ def delete_session_entity_type( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_session_entity_type" not in self._stubs: - self._stubs["delete_session_entity_type"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_session_entity_type" + ] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SessionEntityTypes/DeleteSessionEntityType", request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -477,7 +568,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: @@ -493,7 +584,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -510,7 +601,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -529,7 +620,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -548,7 +639,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, @@ -565,7 +656,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-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py index b8b46ecf6a91..f5a1e75a7c76 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/session_entity_types/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 @@ -43,6 +43,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, @@ -111,10 +119,10 @@ def post_update_session_entity_type(self, response): def pre_create_session_entity_type( self, request: gcd_session_entity_type.CreateSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_session_entity_type.CreateSessionEntityTypeRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_session_entity_type @@ -137,9 +145,10 @@ def post_create_session_entity_type( def pre_delete_session_entity_type( self, request: session_entity_type.DeleteSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.DeleteSessionEntityTypeRequest, Sequence[Tuple[str, str]] + session_entity_type.DeleteSessionEntityTypeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_session_entity_type @@ -151,9 +160,10 @@ def pre_delete_session_entity_type( def pre_get_session_entity_type( self, request: session_entity_type.GetSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.GetSessionEntityTypeRequest, Sequence[Tuple[str, str]] + session_entity_type.GetSessionEntityTypeRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_session_entity_type @@ -176,9 +186,10 @@ def post_get_session_entity_type( def pre_list_session_entity_types( self, request: session_entity_type.ListSessionEntityTypesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - session_entity_type.ListSessionEntityTypesRequest, Sequence[Tuple[str, str]] + session_entity_type.ListSessionEntityTypesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_session_entity_types @@ -201,10 +212,10 @@ def post_list_session_entity_types( def pre_update_session_entity_type( self, request: gcd_session_entity_type.UpdateSessionEntityTypeRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcd_session_entity_type.UpdateSessionEntityTypeRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_session_entity_type @@ -227,8 +238,10 @@ def post_update_session_entity_type( 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 @@ -250,8 +263,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 @@ -273,8 +288,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -294,8 +311,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -317,8 +336,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -461,7 +482,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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Call the create session entity type method over HTTP. @@ -473,8 +494,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: ~.gcd_session_entity_type.SessionEntityType: @@ -494,6 +517,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseCreateSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_create_session_entity_type( request, metadata ) @@ -510,6 +534,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 = 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.dialogflow_v2beta1.SessionEntityTypesClient.CreateSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "CreateSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._CreateSessionEntityType._get_response( @@ -533,7 +584,31 @@ def __call__( pb_resp = gcd_session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_session_entity_type.SessionEntityType.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.dialogflow_v2beta1.SessionEntityTypesClient.create_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "CreateSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSessionEntityType( @@ -571,7 +646,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 session entity type method over HTTP. @@ -583,13 +658,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 = ( _BaseSessionEntityTypesRestTransport._BaseDeleteSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_delete_session_entity_type( request, metadata ) @@ -602,6 +680,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.dialogflow_v2beta1.SessionEntityTypesClient.DeleteSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "DeleteSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._DeleteSessionEntityType._get_response( @@ -654,7 +759,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]]] = (), ) -> session_entity_type.SessionEntityType: r"""Call the get session entity type method over HTTP. @@ -665,8 +770,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: ~.session_entity_type.SessionEntityType: @@ -686,6 +793,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_get_session_entity_type( request, metadata ) @@ -698,6 +806,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 = 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.dialogflow_v2beta1.SessionEntityTypesClient.GetSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._GetSessionEntityType._get_response( @@ -720,7 +855,31 @@ def __call__( pb_resp = session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = session_entity_type.SessionEntityType.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.dialogflow_v2beta1.SessionEntityTypesClient.get_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSessionEntityTypes( @@ -758,7 +917,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]]] = (), ) -> session_entity_type.ListSessionEntityTypesResponse: r"""Call the list session entity types method over HTTP. @@ -769,8 +928,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: ~.session_entity_type.ListSessionEntityTypesResponse: @@ -782,6 +943,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListSessionEntityTypes._get_http_options() ) + request, metadata = self._interceptor.pre_list_session_entity_types( request, metadata ) @@ -794,6 +956,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 = 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.dialogflow_v2beta1.SessionEntityTypesClient.ListSessionEntityTypes", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListSessionEntityTypes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._ListSessionEntityTypes._get_response( @@ -816,7 +1005,33 @@ def __call__( pb_resp = session_entity_type.ListSessionEntityTypesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_session_entity_types(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + session_entity_type.ListSessionEntityTypesResponse.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.dialogflow_v2beta1.SessionEntityTypesClient.list_session_entity_types", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListSessionEntityTypes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSessionEntityType( @@ -855,7 +1070,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]]] = (), ) -> gcd_session_entity_type.SessionEntityType: r"""Call the update session entity type method over HTTP. @@ -867,8 +1082,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: ~.gcd_session_entity_type.SessionEntityType: @@ -888,6 +1105,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseUpdateSessionEntityType._get_http_options() ) + request, metadata = self._interceptor.pre_update_session_entity_type( request, metadata ) @@ -904,6 +1122,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 = 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.dialogflow_v2beta1.SessionEntityTypesClient.UpdateSessionEntityType", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "UpdateSessionEntityType", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( SessionEntityTypesRestTransport._UpdateSessionEntityType._get_response( @@ -927,7 +1172,31 @@ def __call__( pb_resp = gcd_session_entity_type.SessionEntityType.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_session_entity_type(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gcd_session_entity_type.SessionEntityType.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.dialogflow_v2beta1.SessionEntityTypesClient.update_session_entity_type", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "UpdateSessionEntityType", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1023,7 +1292,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. @@ -1033,8 +1302,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. @@ -1043,6 +1314,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1053,6 +1325,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.dialogflow_v2beta1.SessionEntityTypesClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._GetLocation._get_response( self._host, @@ -1072,6 +1371,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.dialogflow_v2beta1.SessionEntityTypesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1113,7 +1433,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. @@ -1123,8 +1443,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. @@ -1133,6 +1455,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1143,6 +1466,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.dialogflow_v2beta1.SessionEntityTypesClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._ListLocations._get_response( self._host, @@ -1162,6 +1512,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.dialogflow_v2beta1.SessionEntityTypesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1203,7 +1574,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1213,13 +1584,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 = ( _BaseSessionEntityTypesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1232,6 +1606,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.dialogflow_v2beta1.SessionEntityTypesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._CancelOperation._get_response( self._host, @@ -1288,7 +1689,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1298,8 +1699,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: operations_pb2.Operation: Response from GetOperation method. @@ -1308,6 +1711,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1318,6 +1722,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.dialogflow_v2beta1.SessionEntityTypesClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._GetOperation._get_response( self._host, @@ -1337,6 +1768,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.SessionEntityTypesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1378,7 +1830,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1388,8 +1840,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1398,6 +1852,7 @@ def __call__( http_options = ( _BaseSessionEntityTypesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseSessionEntityTypesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1408,6 +1863,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.dialogflow_v2beta1.SessionEntityTypesClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionEntityTypesRestTransport._ListOperations._get_response( self._host, @@ -1427,6 +1909,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.SessionEntityTypesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SessionEntityTypes", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py index 3bec6b55386c..c40996d732bc 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/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 ( AsyncIterable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SessionsTransport from .transports.grpc_asyncio import SessionsGrpcAsyncIOTransport +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 SessionsAsyncClient: """A service used for session interactions. @@ -270,6 +280,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.dialogflow_v2beta1.SessionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "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.dialogflow.v2beta1.Sessions", + "credentialsType": None, + }, + ) + async def detect_intent( self, request: Optional[Union[gcd_session.DetectIntentRequest, dict]] = None, @@ -278,7 +310,7 @@ async def detect_intent( query_input: Optional[gcd_session.QueryInput] = 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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, @@ -381,8 +413,10 @@ async def sample_detect_intent(): 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.dialogflow_v2beta1.types.DetectIntentResponse: @@ -444,7 +478,7 @@ def streaming_detect_intent( *, 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]]] = (), ) -> Awaitable[AsyncIterable[session.StreamingDetectIntentResponse]]: r"""Processes a natural language query in audio format in a streaming fashion and returns structured, actionable data as a @@ -551,8 +585,10 @@ def request_generator(): 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: AsyncIterable[google.cloud.dialogflow_v2beta1.types.StreamingDetectIntentResponse]: @@ -603,7 +639,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -614,8 +650,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -656,7 +694,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -667,8 +705,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -709,7 +749,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -724,8 +764,10 @@ async def cancel_operation( 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: None """ @@ -762,7 +804,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. @@ -773,8 +815,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. @@ -815,7 +859,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. @@ -826,8 +870,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/client.py index 7386ad85cdb5..2958f1cd9a2f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -689,6 +699,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( @@ -751,6 +765,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.dialogflow_v2beta1.SessionsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "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.dialogflow.v2beta1.Sessions", + "credentialsType": None, + }, + ) + def detect_intent( self, request: Optional[Union[gcd_session.DetectIntentRequest, dict]] = None, @@ -759,7 +796,7 @@ def detect_intent( query_input: Optional[gcd_session.QueryInput] = 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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, @@ -862,8 +899,10 @@ def sample_detect_intent(): 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.dialogflow_v2beta1.types.DetectIntentResponse: @@ -922,7 +961,7 @@ def streaming_detect_intent( *, 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]]] = (), ) -> Iterable[session.StreamingDetectIntentResponse]: r"""Processes a natural language query in audio format in a streaming fashion and returns structured, actionable data as a @@ -1029,8 +1068,10 @@ def request_generator(): 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: Iterable[google.cloud.dialogflow_v2beta1.types.StreamingDetectIntentResponse]: @@ -1092,7 +1133,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1103,8 +1144,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1145,7 +1188,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1156,8 +1199,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1198,7 +1243,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1213,8 +1258,10 @@ def cancel_operation( 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: None """ @@ -1251,7 +1298,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. @@ -1262,8 +1309,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. @@ -1304,7 +1353,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. @@ -1315,8 +1364,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py index 75d997ded158..5af50a135379 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/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 @@ -22,13 +25,91 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import session from google.cloud.dialogflow_v2beta1.types import session as gcd_session from .base import DEFAULT_CLIENT_INFO, SessionsTransport +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.dialogflow.v2beta1.Sessions", + "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.dialogflow.v2beta1.Sessions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionsGrpcTransport(SessionsTransport): """gRPC backend transport for Sessions. @@ -185,7 +266,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 @@ -273,7 +359,7 @@ def detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_intent" not in self._stubs: - self._stubs["detect_intent"] = self.grpc_channel.unary_unary( + self._stubs["detect_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Sessions/DetectIntent", request_serializer=gcd_session.DetectIntentRequest.serialize, response_deserializer=gcd_session.DetectIntentResponse.deserialize, @@ -316,7 +402,7 @@ def streaming_detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_detect_intent" not in self._stubs: - self._stubs["streaming_detect_intent"] = self.grpc_channel.stream_stream( + self._stubs["streaming_detect_intent"] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2beta1.Sessions/StreamingDetectIntent", request_serializer=session.StreamingDetectIntentRequest.serialize, response_deserializer=session.StreamingDetectIntentResponse.deserialize, @@ -324,7 +410,7 @@ def streaming_detect_intent( return self._stubs["streaming_detect_intent"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -336,7 +422,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -353,7 +439,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -372,7 +458,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -391,7 +477,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, @@ -408,7 +494,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py index 12cb187cbbbb..193f3dcd31aa 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/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 @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import session from google.cloud.dialogflow_v2beta1.types import session as gcd_session @@ -33,6 +39,82 @@ from .base import DEFAULT_CLIENT_INFO, SessionsTransport from .grpc import SessionsGrpcTransport +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.dialogflow.v2beta1.Sessions", + "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.dialogflow.v2beta1.Sessions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SessionsGrpcAsyncIOTransport(SessionsTransport): """gRPC AsyncIO backend transport for Sessions. @@ -232,10 +314,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 @@ -283,7 +368,7 @@ def detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detect_intent" not in self._stubs: - self._stubs["detect_intent"] = self.grpc_channel.unary_unary( + self._stubs["detect_intent"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Sessions/DetectIntent", request_serializer=gcd_session.DetectIntentRequest.serialize, response_deserializer=gcd_session.DetectIntentResponse.deserialize, @@ -327,7 +412,7 @@ def streaming_detect_intent( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "streaming_detect_intent" not in self._stubs: - self._stubs["streaming_detect_intent"] = self.grpc_channel.stream_stream( + self._stubs["streaming_detect_intent"] = self._logged_channel.stream_stream( "/google.cloud.dialogflow.v2beta1.Sessions/StreamingDetectIntent", request_serializer=session.StreamingDetectIntentRequest.serialize, response_deserializer=session.StreamingDetectIntentResponse.deserialize, @@ -389,7 +474,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: @@ -405,7 +490,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -422,7 +507,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -441,7 +526,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -460,7 +545,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, @@ -477,7 +562,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py index 7a140b709c4a..45054242c57a 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sessions/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 @@ -40,6 +40,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, @@ -80,8 +88,10 @@ def post_detect_intent(self, response): def pre_detect_intent( self, request: gcd_session.DetectIntentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_session.DetectIntentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_session.DetectIntentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for detect_intent Override in a subclass to manipulate the request or metadata @@ -103,8 +113,10 @@ def post_detect_intent( 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 @@ -126,8 +138,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 @@ -149,8 +163,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -170,8 +186,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -193,8 +211,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -336,7 +356,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]]] = (), ) -> gcd_session.DetectIntentResponse: r"""Call the detect intent method over HTTP. @@ -346,8 +366,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: ~.gcd_session.DetectIntentResponse: @@ -359,6 +381,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseDetectIntent._get_http_options() ) + request, metadata = self._interceptor.pre_detect_intent(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseDetectIntent._get_transcoded_request( @@ -377,6 +400,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.dialogflow_v2beta1.SessionsClient.DetectIntent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "DetectIntent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._DetectIntent._get_response( self._host, @@ -398,7 +448,31 @@ def __call__( pb_resp = gcd_session.DetectIntentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detect_intent(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_session.DetectIntentResponse.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.dialogflow_v2beta1.SessionsClient.detect_intent", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "DetectIntent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamingDetectIntent( @@ -413,7 +487,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]]] = (), ) -> rest_streaming.ResponseIterator: raise NotImplementedError( "Method StreamingDetectIntent is not available over REST transport" @@ -473,7 +547,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. @@ -483,8 +557,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. @@ -493,6 +569,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseGetLocation._get_transcoded_request( @@ -507,6 +584,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.dialogflow_v2beta1.SessionsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._GetLocation._get_response( self._host, @@ -526,6 +630,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.dialogflow_v2beta1.SessionsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -566,7 +691,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. @@ -576,8 +701,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. @@ -586,6 +713,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseListLocations._get_transcoded_request( @@ -600,6 +728,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.dialogflow_v2beta1.SessionsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._ListLocations._get_response( self._host, @@ -619,6 +774,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.dialogflow_v2beta1.SessionsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -659,7 +835,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -669,13 +845,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 = ( _BaseSessionsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -692,6 +871,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.dialogflow_v2beta1.SessionsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._CancelOperation._get_response( self._host, @@ -745,7 +951,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -755,8 +961,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: operations_pb2.Operation: Response from GetOperation method. @@ -765,6 +973,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -779,6 +988,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.dialogflow_v2beta1.SessionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._GetOperation._get_response( self._host, @@ -798,6 +1034,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.SessionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -838,7 +1095,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -848,8 +1105,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -858,6 +1117,7 @@ def __call__( http_options = ( _BaseSessionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSessionsRestTransport._BaseListOperations._get_transcoded_request( @@ -872,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 = 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.dialogflow_v2beta1.SessionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SessionsRestTransport._ListOperations._get_response( self._host, @@ -891,6 +1178,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.SessionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Sessions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/async_client.py index cb1b71f25e80..69ec1a64054d 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SipTrunksTransport from .transports.grpc_asyncio import SipTrunksGrpcAsyncIOTransport +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 SipTrunksAsyncClient: """Service for managing @@ -255,6 +265,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.dialogflow_v2beta1.SipTrunksAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "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.dialogflow.v2beta1.SipTrunks", + "credentialsType": None, + }, + ) + async def create_sip_trunk( self, request: Optional[Union[gcd_sip_trunk.CreateSipTrunkRequest, dict]] = None, @@ -263,7 +295,7 @@ async def create_sip_trunk( sip_trunk: Optional[gcd_sip_trunk.SipTrunk] = 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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Creates a SipTrunk for a specified location. @@ -317,8 +349,10 @@ async def sample_create_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -383,7 +417,7 @@ async def delete_sip_trunk( 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 specified SipTrunk. @@ -424,8 +458,10 @@ async def sample_delete_sip_trunk(): 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 @@ -477,7 +513,7 @@ async def list_sip_trunks( 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.ListSipTrunksAsyncPager: r"""Returns a list of SipTrunks in the specified location. @@ -523,8 +559,10 @@ async def sample_list_sip_trunks(): 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.dialogflow_v2beta1.services.sip_trunks.pagers.ListSipTrunksAsyncPager: @@ -599,7 +637,7 @@ async def get_sip_trunk( 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]]] = (), ) -> sip_trunk.SipTrunk: r"""Retrieves the specified SipTrunk. @@ -643,8 +681,10 @@ async def sample_get_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -708,7 +748,7 @@ async def update_sip_trunk( 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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Updates the specified SipTrunk. @@ -761,8 +801,10 @@ async def sample_update_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -828,7 +870,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -839,8 +881,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -881,7 +925,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -892,8 +936,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -934,7 +980,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -949,8 +995,10 @@ async def cancel_operation( 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: None """ @@ -987,7 +1035,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. @@ -998,8 +1046,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. @@ -1040,7 +1090,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. @@ -1051,8 +1101,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/client.py index 607e4143b1ac..dd081205f989 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -583,6 +593,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( @@ -645,6 +659,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.dialogflow_v2beta1.SipTrunksClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "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.dialogflow.v2beta1.SipTrunks", + "credentialsType": None, + }, + ) + def create_sip_trunk( self, request: Optional[Union[gcd_sip_trunk.CreateSipTrunkRequest, dict]] = None, @@ -653,7 +690,7 @@ def create_sip_trunk( sip_trunk: Optional[gcd_sip_trunk.SipTrunk] = 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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Creates a SipTrunk for a specified location. @@ -707,8 +744,10 @@ def sample_create_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -770,7 +809,7 @@ def delete_sip_trunk( 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 specified SipTrunk. @@ -811,8 +850,10 @@ def sample_delete_sip_trunk(): 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 @@ -861,7 +902,7 @@ def list_sip_trunks( 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.ListSipTrunksPager: r"""Returns a list of SipTrunks in the specified location. @@ -907,8 +948,10 @@ def sample_list_sip_trunks(): 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.dialogflow_v2beta1.services.sip_trunks.pagers.ListSipTrunksPager: @@ -980,7 +1023,7 @@ def get_sip_trunk( 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]]] = (), ) -> sip_trunk.SipTrunk: r"""Retrieves the specified SipTrunk. @@ -1024,8 +1067,10 @@ def sample_get_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -1086,7 +1131,7 @@ def update_sip_trunk( 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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Updates the specified SipTrunk. @@ -1139,8 +1184,10 @@ def sample_update_sip_trunk(): 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.dialogflow_v2beta1.types.SipTrunk: @@ -1216,7 +1263,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1227,8 +1274,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1269,7 +1318,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1280,8 +1329,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1322,7 +1373,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1337,8 +1388,10 @@ def cancel_operation( 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: None """ @@ -1375,7 +1428,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. @@ -1386,8 +1439,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. @@ -1428,7 +1483,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. @@ -1439,8 +1494,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/pagers.py index 5ae29fd99f86..c6e2764f0f79 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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 = sip_trunk.ListSipTrunksRequest(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 = sip_trunk.ListSipTrunksRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc.py index e74874402f61..915528c695ef 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import sip_trunk from google.cloud.dialogflow_v2beta1.types import sip_trunk as gcd_sip_trunk from .base import DEFAULT_CLIENT_INFO, SipTrunksTransport +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.dialogflow.v2beta1.SipTrunks", + "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.dialogflow.v2beta1.SipTrunks", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SipTrunksGrpcTransport(SipTrunksTransport): """gRPC backend transport for SipTrunks. @@ -184,7 +265,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 @@ -258,7 +344,7 @@ def create_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_sip_trunk" not in self._stubs: - self._stubs["create_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["create_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/CreateSipTrunk", request_serializer=gcd_sip_trunk.CreateSipTrunkRequest.serialize, response_deserializer=gcd_sip_trunk.SipTrunk.deserialize, @@ -284,7 +370,7 @@ def delete_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_sip_trunk" not in self._stubs: - self._stubs["delete_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["delete_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/DeleteSipTrunk", request_serializer=sip_trunk.DeleteSipTrunkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -311,7 +397,7 @@ def list_sip_trunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sip_trunks" not in self._stubs: - self._stubs["list_sip_trunks"] = self.grpc_channel.unary_unary( + self._stubs["list_sip_trunks"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/ListSipTrunks", request_serializer=sip_trunk.ListSipTrunksRequest.serialize, response_deserializer=sip_trunk.ListSipTrunksResponse.deserialize, @@ -337,7 +423,7 @@ def get_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_sip_trunk" not in self._stubs: - self._stubs["get_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["get_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/GetSipTrunk", request_serializer=sip_trunk.GetSipTrunkRequest.serialize, response_deserializer=sip_trunk.SipTrunk.deserialize, @@ -363,7 +449,7 @@ def update_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_sip_trunk" not in self._stubs: - self._stubs["update_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["update_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/UpdateSipTrunk", request_serializer=gcd_sip_trunk.UpdateSipTrunkRequest.serialize, response_deserializer=gcd_sip_trunk.SipTrunk.deserialize, @@ -371,7 +457,7 @@ def update_sip_trunk( return self._stubs["update_sip_trunk"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -383,7 +469,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -400,7 +486,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +505,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -438,7 +524,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, @@ -455,7 +541,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc_asyncio.py index 17f0adc5960e..9d408326344e 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import sip_trunk from google.cloud.dialogflow_v2beta1.types import sip_trunk as gcd_sip_trunk @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, SipTrunksTransport from .grpc import SipTrunksGrpcTransport +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.dialogflow.v2beta1.SipTrunks", + "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.dialogflow.v2beta1.SipTrunks", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SipTrunksGrpcAsyncIOTransport(SipTrunksTransport): """gRPC AsyncIO backend transport for SipTrunks. @@ -231,10 +313,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 @@ -268,7 +353,7 @@ def create_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_sip_trunk" not in self._stubs: - self._stubs["create_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["create_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/CreateSipTrunk", request_serializer=gcd_sip_trunk.CreateSipTrunkRequest.serialize, response_deserializer=gcd_sip_trunk.SipTrunk.deserialize, @@ -294,7 +379,7 @@ def delete_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_sip_trunk" not in self._stubs: - self._stubs["delete_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["delete_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/DeleteSipTrunk", request_serializer=sip_trunk.DeleteSipTrunkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -323,7 +408,7 @@ def list_sip_trunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_sip_trunks" not in self._stubs: - self._stubs["list_sip_trunks"] = self.grpc_channel.unary_unary( + self._stubs["list_sip_trunks"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/ListSipTrunks", request_serializer=sip_trunk.ListSipTrunksRequest.serialize, response_deserializer=sip_trunk.ListSipTrunksResponse.deserialize, @@ -349,7 +434,7 @@ def get_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_sip_trunk" not in self._stubs: - self._stubs["get_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["get_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/GetSipTrunk", request_serializer=sip_trunk.GetSipTrunkRequest.serialize, response_deserializer=sip_trunk.SipTrunk.deserialize, @@ -377,7 +462,7 @@ def update_sip_trunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_sip_trunk" not in self._stubs: - self._stubs["update_sip_trunk"] = self.grpc_channel.unary_unary( + self._stubs["update_sip_trunk"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.SipTrunks/UpdateSipTrunk", request_serializer=gcd_sip_trunk.UpdateSipTrunkRequest.serialize, response_deserializer=gcd_sip_trunk.SipTrunk.deserialize, @@ -445,7 +530,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: @@ -461,7 +546,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -478,7 +563,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -497,7 +582,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -516,7 +601,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, @@ -533,7 +618,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-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/rest.py index 32228f0bb2f0..c140a7e67b7f 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/sip_trunks/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 @@ -41,6 +41,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, @@ -109,8 +117,10 @@ def post_update_sip_trunk(self, response): def pre_create_sip_trunk( self, request: gcd_sip_trunk.CreateSipTrunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_sip_trunk.CreateSipTrunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_sip_trunk.CreateSipTrunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_sip_trunk Override in a subclass to manipulate the request or metadata @@ -132,8 +142,10 @@ def post_create_sip_trunk( def pre_delete_sip_trunk( self, request: sip_trunk.DeleteSipTrunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[sip_trunk.DeleteSipTrunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + sip_trunk.DeleteSipTrunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_sip_trunk Override in a subclass to manipulate the request or metadata @@ -142,8 +154,10 @@ def pre_delete_sip_trunk( return request, metadata def pre_get_sip_trunk( - self, request: sip_trunk.GetSipTrunkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[sip_trunk.GetSipTrunkRequest, Sequence[Tuple[str, str]]]: + self, + request: sip_trunk.GetSipTrunkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sip_trunk.GetSipTrunkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_sip_trunk Override in a subclass to manipulate the request or metadata @@ -163,8 +177,8 @@ def post_get_sip_trunk(self, response: sip_trunk.SipTrunk) -> sip_trunk.SipTrunk def pre_list_sip_trunks( self, request: sip_trunk.ListSipTrunksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[sip_trunk.ListSipTrunksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sip_trunk.ListSipTrunksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_sip_trunks Override in a subclass to manipulate the request or metadata @@ -186,8 +200,10 @@ def post_list_sip_trunks( def pre_update_sip_trunk( self, request: gcd_sip_trunk.UpdateSipTrunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_sip_trunk.UpdateSipTrunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_sip_trunk.UpdateSipTrunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_sip_trunk Override in a subclass to manipulate the request or metadata @@ -209,8 +225,10 @@ def post_update_sip_trunk( 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 @@ -232,8 +250,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 @@ -255,8 +275,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -276,8 +298,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -299,8 +323,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -442,7 +468,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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Call the create sip trunk method over HTTP. @@ -453,8 +479,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: ~.gcd_sip_trunk.SipTrunk: @@ -468,6 +496,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseCreateSipTrunk._get_http_options() ) + request, metadata = self._interceptor.pre_create_sip_trunk( request, metadata ) @@ -490,6 +519,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.dialogflow_v2beta1.SipTrunksClient.CreateSipTrunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "CreateSipTrunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._CreateSipTrunk._get_response( self._host, @@ -511,7 +567,29 @@ def __call__( pb_resp = gcd_sip_trunk.SipTrunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_sip_trunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_sip_trunk.SipTrunk.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.dialogflow_v2beta1.SipTrunksClient.create_sip_trunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "CreateSipTrunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSipTrunk( @@ -548,7 +626,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 sip trunk method over HTTP. @@ -559,13 +637,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 = ( _BaseSipTrunksRestTransport._BaseDeleteSipTrunk._get_http_options() ) + request, metadata = self._interceptor.pre_delete_sip_trunk( request, metadata ) @@ -582,6 +663,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.dialogflow_v2beta1.SipTrunksClient.DeleteSipTrunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "DeleteSipTrunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._DeleteSipTrunk._get_response( self._host, @@ -629,7 +737,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]]] = (), ) -> sip_trunk.SipTrunk: r"""Call the get sip trunk method over HTTP. @@ -640,8 +748,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: ~.sip_trunk.SipTrunk: @@ -655,6 +765,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseGetSipTrunk._get_http_options() ) + request, metadata = self._interceptor.pre_get_sip_trunk(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseGetSipTrunk._get_transcoded_request( @@ -669,6 +780,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.dialogflow_v2beta1.SipTrunksClient.GetSipTrunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetSipTrunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._GetSipTrunk._get_response( self._host, @@ -689,7 +827,29 @@ def __call__( pb_resp = sip_trunk.SipTrunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_sip_trunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sip_trunk.SipTrunk.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.dialogflow_v2beta1.SipTrunksClient.get_sip_trunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetSipTrunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSipTrunks( @@ -726,7 +886,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]]] = (), ) -> sip_trunk.ListSipTrunksResponse: r"""Call the list sip trunks method over HTTP. @@ -737,8 +897,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: ~.sip_trunk.ListSipTrunksResponse: @@ -750,6 +912,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseListSipTrunks._get_http_options() ) + request, metadata = self._interceptor.pre_list_sip_trunks(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseListSipTrunks._get_transcoded_request( @@ -764,6 +927,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.dialogflow_v2beta1.SipTrunksClient.ListSipTrunks", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListSipTrunks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._ListSipTrunks._get_response( self._host, @@ -784,7 +974,29 @@ def __call__( pb_resp = sip_trunk.ListSipTrunksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sip_trunks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sip_trunk.ListSipTrunksResponse.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.dialogflow_v2beta1.SipTrunksClient.list_sip_trunks", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListSipTrunks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSipTrunk( @@ -822,7 +1034,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]]] = (), ) -> gcd_sip_trunk.SipTrunk: r"""Call the update sip trunk method over HTTP. @@ -833,8 +1045,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: ~.gcd_sip_trunk.SipTrunk: @@ -848,6 +1062,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseUpdateSipTrunk._get_http_options() ) + request, metadata = self._interceptor.pre_update_sip_trunk( request, metadata ) @@ -870,6 +1085,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.dialogflow_v2beta1.SipTrunksClient.UpdateSipTrunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "UpdateSipTrunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._UpdateSipTrunk._get_response( self._host, @@ -891,7 +1133,29 @@ def __call__( pb_resp = gcd_sip_trunk.SipTrunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_sip_trunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_sip_trunk.SipTrunk.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.dialogflow_v2beta1.SipTrunksClient.update_sip_trunk", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "UpdateSipTrunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -970,7 +1234,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. @@ -980,8 +1244,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. @@ -990,6 +1256,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseGetLocation._get_transcoded_request( @@ -1004,6 +1271,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.dialogflow_v2beta1.SipTrunksClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._GetLocation._get_response( self._host, @@ -1023,6 +1317,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.dialogflow_v2beta1.SipTrunksAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1063,7 +1378,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. @@ -1073,8 +1388,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. @@ -1083,6 +1400,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseListLocations._get_transcoded_request( @@ -1097,6 +1415,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.dialogflow_v2beta1.SipTrunksClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._ListLocations._get_response( self._host, @@ -1116,6 +1461,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.dialogflow_v2beta1.SipTrunksAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1156,7 +1522,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1166,13 +1532,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 = ( _BaseSipTrunksRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1187,6 +1556,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.dialogflow_v2beta1.SipTrunksClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._CancelOperation._get_response( self._host, @@ -1242,7 +1638,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1252,8 +1648,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: operations_pb2.Operation: Response from GetOperation method. @@ -1262,6 +1660,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseGetOperation._get_transcoded_request( @@ -1276,6 +1675,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.dialogflow_v2beta1.SipTrunksClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._GetOperation._get_response( self._host, @@ -1295,6 +1721,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.SipTrunksAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1335,7 +1782,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1345,8 +1792,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1355,6 +1804,7 @@ def __call__( http_options = ( _BaseSipTrunksRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseSipTrunksRestTransport._BaseListOperations._get_transcoded_request( @@ -1369,6 +1819,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.dialogflow_v2beta1.SipTrunksClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SipTrunksRestTransport._ListOperations._get_response( self._host, @@ -1388,6 +1865,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.SipTrunksAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.SipTrunks", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/async_client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/async_client.py index 48a023727b1f..48de0062f9de 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/async_client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VersionsTransport from .transports.grpc_asyncio import VersionsGrpcAsyncIOTransport +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 VersionsAsyncClient: """Service for managing @@ -254,6 +264,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.dialogflow_v2beta1.VersionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "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.dialogflow.v2beta1.Versions", + "credentialsType": None, + }, + ) + async def list_versions( self, request: Optional[Union[version.ListVersionsRequest, dict]] = None, @@ -261,7 +293,7 @@ async def list_versions( 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.ListVersionsAsyncPager: r"""Returns the list of all versions of the specified agent. @@ -310,8 +342,10 @@ async def sample_list_versions(): 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.dialogflow_v2beta1.services.versions.pagers.ListVersionsAsyncPager: @@ -386,7 +420,7 @@ async def get_version( 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]]] = (), ) -> version.Version: r"""Retrieves the specified agent version. @@ -432,8 +466,10 @@ async def sample_get_version(): 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.dialogflow_v2beta1.types.Version: @@ -514,7 +550,7 @@ async def create_version( version: Optional[gcd_version.Version] = 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]]] = (), ) -> gcd_version.Version: r"""Creates an agent version. @@ -569,8 +605,10 @@ async def sample_create_version(): 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.dialogflow_v2beta1.types.Version: @@ -653,7 +691,7 @@ async def update_version( 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]]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. @@ -710,8 +748,10 @@ async def sample_update_version(): 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.dialogflow_v2beta1.types.Version: @@ -795,7 +835,7 @@ async def delete_version( 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"""Delete the specified agent version. @@ -839,8 +879,10 @@ async def sample_delete_version(): 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 list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -902,8 +944,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -944,7 +988,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -955,8 +999,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -997,7 +1043,7 @@ async def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1012,8 +1058,10 @@ async def cancel_operation( 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: None """ @@ -1050,7 +1098,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. @@ -1061,8 +1109,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. @@ -1103,7 +1153,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. @@ -1114,8 +1164,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-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/client.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/client.py index 5411c336a081..34c71f34b62a 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/client.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -581,6 +591,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( @@ -643,6 +657,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.dialogflow_v2beta1.VersionsClient`.", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "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.dialogflow.v2beta1.Versions", + "credentialsType": None, + }, + ) + def list_versions( self, request: Optional[Union[version.ListVersionsRequest, dict]] = None, @@ -650,7 +687,7 @@ def list_versions( 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.ListVersionsPager: r"""Returns the list of all versions of the specified agent. @@ -699,8 +736,10 @@ def sample_list_versions(): 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.dialogflow_v2beta1.services.versions.pagers.ListVersionsPager: @@ -772,7 +811,7 @@ def get_version( 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]]] = (), ) -> version.Version: r"""Retrieves the specified agent version. @@ -818,8 +857,10 @@ def sample_get_version(): 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.dialogflow_v2beta1.types.Version: @@ -897,7 +938,7 @@ def create_version( version: Optional[gcd_version.Version] = 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]]] = (), ) -> gcd_version.Version: r"""Creates an agent version. @@ -952,8 +993,10 @@ def sample_create_version(): 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.dialogflow_v2beta1.types.Version: @@ -1033,7 +1076,7 @@ def update_version( 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]]] = (), ) -> gcd_version.Version: r"""Updates the specified agent version. @@ -1090,8 +1133,10 @@ def sample_update_version(): 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.dialogflow_v2beta1.types.Version: @@ -1172,7 +1217,7 @@ def delete_version( 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"""Delete the specified agent version. @@ -1216,8 +1261,10 @@ def sample_delete_version(): 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 @@ -1278,7 +1325,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1289,8 +1336,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1331,7 +1380,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1342,8 +1391,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1384,7 +1435,7 @@ def cancel_operation( *, 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"""Starts asynchronous cancellation on a long-running operation. @@ -1399,8 +1450,10 @@ def cancel_operation( 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: None """ @@ -1437,7 +1490,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. @@ -1448,8 +1501,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. @@ -1490,7 +1545,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. @@ -1501,8 +1556,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-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/pagers.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/pagers.py index e635db1fc3ca..084efee1f5be 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/pagers.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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 = version.ListVersionsRequest(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 = version.ListVersionsRequest(request) diff --git a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py index c4a9168ca32f..95afe035f694 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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 @@ -23,13 +26,91 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import version from google.cloud.dialogflow_v2beta1.types import version as gcd_version from .base import DEFAULT_CLIENT_INFO, VersionsTransport +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.dialogflow.v2beta1.Versions", + "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.dialogflow.v2beta1.Versions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcTransport(VersionsTransport): """gRPC backend transport for Versions. @@ -184,7 +265,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 @@ -259,7 +345,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -283,7 +369,7 @@ def get_version(self) -> Callable[[version.GetVersionRequest], version.Version]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -312,7 +398,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/CreateVersion", request_serializer=gcd_version.CreateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -343,7 +429,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/UpdateVersion", request_serializer=gcd_version.UpdateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -369,7 +455,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -377,7 +463,7 @@ def delete_version( return self._stubs["delete_version"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -389,7 +475,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -406,7 +492,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -425,7 +511,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -444,7 +530,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, @@ -461,7 +547,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-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py index 3e8eba4ce38a..222872b5b953 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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 @@ -25,8 +28,11 @@ from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_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.dialogflow_v2beta1.types import version from google.cloud.dialogflow_v2beta1.types import version as gcd_version @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, VersionsTransport from .grpc import VersionsGrpcTransport +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.dialogflow.v2beta1.Versions", + "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.dialogflow.v2beta1.Versions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcAsyncIOTransport(VersionsTransport): """gRPC AsyncIO backend transport for Versions. @@ -231,10 +313,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 @@ -269,7 +354,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -295,7 +380,7 @@ def get_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -324,7 +409,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/CreateVersion", request_serializer=gcd_version.CreateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -355,7 +440,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/UpdateVersion", request_serializer=gcd_version.UpdateVersionRequest.serialize, response_deserializer=gcd_version.Version.deserialize, @@ -381,7 +466,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.cloud.dialogflow.v2beta1.Versions/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -449,7 +534,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: @@ -465,7 +550,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -482,7 +567,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -501,7 +586,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -520,7 +605,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, @@ -537,7 +622,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-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py index 458909231f79..3151e778e1ae 100644 --- a/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/transports/rest.py +++ b/packages/google-cloud-dialogflow/google/cloud/dialogflow_v2beta1/services/versions/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 @@ -41,6 +41,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, @@ -109,8 +117,10 @@ def post_update_version(self, response): def pre_create_version( self, request: gcd_version.CreateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_version.CreateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_version.CreateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_version Override in a subclass to manipulate the request or metadata @@ -128,8 +138,10 @@ def post_create_version(self, response: gcd_version.Version) -> gcd_version.Vers return response def pre_delete_version( - self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.DeleteVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -138,8 +150,10 @@ def pre_delete_version( return request, metadata def pre_get_version( - self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.GetVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -157,8 +171,10 @@ def post_get_version(self, response: version.Version) -> version.Version: return response def pre_list_versions( - self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: + self, + request: version.ListVersionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -180,8 +196,10 @@ def post_list_versions( def pre_update_version( self, request: gcd_version.UpdateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcd_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcd_version.UpdateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_version Override in a subclass to manipulate the request or metadata @@ -201,8 +219,10 @@ def post_update_version(self, response: gcd_version.Version) -> gcd_version.Vers 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 @@ -224,8 +244,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 @@ -247,8 +269,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -268,8 +292,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -291,8 +317,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -434,7 +462,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]]] = (), ) -> gcd_version.Version: r"""Call the create version method over HTTP. @@ -445,8 +473,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: ~.gcd_version.Version: @@ -475,6 +505,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseCreateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_create_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseCreateVersion._get_transcoded_request( @@ -493,6 +524,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.dialogflow_v2beta1.VersionsClient.CreateVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "CreateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._CreateVersion._get_response( self._host, @@ -514,7 +572,29 @@ def __call__( pb_resp = gcd_version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_version.Version.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.dialogflow_v2beta1.VersionsClient.create_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "CreateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteVersion( @@ -551,7 +631,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 version method over HTTP. @@ -562,13 +642,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 = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_transcoded_request( @@ -583,6 +666,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.dialogflow_v2beta1.VersionsClient.DeleteVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._DeleteVersion._get_response( self._host, @@ -630,7 +740,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]]] = (), ) -> version.Version: r"""Call the get version method over HTTP. @@ -641,8 +751,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: ~.version.Version: @@ -671,6 +783,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetVersion._get_transcoded_request( @@ -685,6 +798,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.dialogflow_v2beta1.VersionsClient.GetVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetVersion._get_response( self._host, @@ -705,7 +845,29 @@ def __call__( pb_resp = version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.Version.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.dialogflow_v2beta1.VersionsClient.get_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions(_BaseVersionsRestTransport._BaseListVersions, VersionsRestStub): @@ -740,7 +902,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]]] = (), ) -> version.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -751,8 +913,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: ~.version.ListVersionsResponse: @@ -764,6 +928,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListVersions._get_transcoded_request( @@ -778,6 +943,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.dialogflow_v2beta1.VersionsClient.ListVersions", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListVersions._get_response( self._host, @@ -798,7 +990,29 @@ def __call__( pb_resp = version.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.ListVersionsResponse.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.dialogflow_v2beta1.VersionsClient.list_versions", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVersion( @@ -836,7 +1050,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]]] = (), ) -> gcd_version.Version: r"""Call the update version method over HTTP. @@ -847,8 +1061,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: ~.gcd_version.Version: @@ -877,6 +1093,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_transcoded_request( @@ -895,6 +1112,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.dialogflow_v2beta1.VersionsClient.UpdateVersion", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "UpdateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._UpdateVersion._get_response( self._host, @@ -916,7 +1160,29 @@ def __call__( pb_resp = gcd_version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcd_version.Version.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.dialogflow_v2beta1.VersionsClient.update_version", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "UpdateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -993,7 +1259,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. @@ -1003,8 +1269,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. @@ -1013,6 +1281,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetLocation._get_transcoded_request( @@ -1027,6 +1296,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.dialogflow_v2beta1.VersionsClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetLocation._get_response( self._host, @@ -1046,6 +1342,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.dialogflow_v2beta1.VersionsAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1086,7 +1403,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. @@ -1096,8 +1413,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. @@ -1106,6 +1425,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListLocations._get_transcoded_request( @@ -1120,6 +1440,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.dialogflow_v2beta1.VersionsClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListLocations._get_response( self._host, @@ -1139,6 +1486,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.dialogflow_v2beta1.VersionsAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1179,7 +1547,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1189,13 +1557,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 = ( _BaseVersionsRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1212,6 +1583,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.dialogflow_v2beta1.VersionsClient.CancelOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._CancelOperation._get_response( self._host, @@ -1265,7 +1663,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1275,8 +1673,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: operations_pb2.Operation: Response from GetOperation method. @@ -1285,6 +1685,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetOperation._get_transcoded_request( @@ -1299,6 +1700,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.dialogflow_v2beta1.VersionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetOperation._get_response( self._host, @@ -1318,6 +1746,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.dialogflow_v2beta1.VersionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1358,7 +1807,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1368,8 +1817,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1378,6 +1829,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListOperations._get_transcoded_request( @@ -1392,6 +1844,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.dialogflow_v2beta1.VersionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListOperations._get_response( self._host, @@ -1411,6 +1890,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.dialogflow_v2beta1.VersionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.dialogflow.v2beta1.Versions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json index 6d9a85a7eb23..7319fdfb442c 100644 --- a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json +++ b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.36.0" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent" @@ -124,7 +124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent" @@ -202,7 +202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -282,7 +282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -363,7 +363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Agent", @@ -443,7 +443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Agent", @@ -520,7 +520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ValidationResult", @@ -596,7 +596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ValidationResult", @@ -673,7 +673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -749,7 +749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -826,7 +826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -902,7 +902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -983,7 +983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.agents.pagers.SearchAgentsAsyncPager", @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.agents.pagers.SearchAgentsPager", @@ -1144,7 +1144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Agent", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Agent", @@ -1305,7 +1305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1385,7 +1385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1466,7 +1466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.answer_records.pagers.ListAnswerRecordsAsyncPager", @@ -1546,7 +1546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.answer_records.pagers.ListAnswerRecordsPager", @@ -1631,7 +1631,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.AnswerRecord", @@ -1715,7 +1715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.AnswerRecord", @@ -1800,7 +1800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -1884,7 +1884,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -1965,7 +1965,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_all_contexts" @@ -2042,7 +2042,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_all_contexts" @@ -2120,7 +2120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_context" @@ -2197,7 +2197,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_context" @@ -2275,7 +2275,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -2355,7 +2355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -2436,7 +2436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.contexts.pagers.ListContextsAsyncPager", @@ -2516,7 +2516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.contexts.pagers.ListContextsPager", @@ -2601,7 +2601,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -2685,7 +2685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Context", @@ -2770,7 +2770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2854,7 +2854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2935,7 +2935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3015,7 +3015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3096,7 +3096,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationDataset", @@ -3176,7 +3176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationDataset", @@ -3253,7 +3253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3329,7 +3329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3410,7 +3410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_datasets.pagers.ListConversationDatasetsAsyncPager", @@ -3490,7 +3490,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_datasets.pagers.ListConversationDatasetsPager", @@ -3575,7 +3575,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3659,7 +3659,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3744,7 +3744,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3828,7 +3828,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3909,7 +3909,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3989,7 +3989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4066,7 +4066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4142,7 +4142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4223,7 +4223,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationModelEvaluation", @@ -4303,7 +4303,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationModelEvaluation", @@ -4384,7 +4384,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationModel", @@ -4464,7 +4464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationModel", @@ -4545,7 +4545,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_models.pagers.ListConversationModelEvaluationsAsyncPager", @@ -4625,7 +4625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_models.pagers.ListConversationModelEvaluationsPager", @@ -4706,7 +4706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_models.pagers.ListConversationModelsAsyncPager", @@ -4786,7 +4786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_models.pagers.ListConversationModelsPager", @@ -4863,7 +4863,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4939,7 +4939,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5028,7 +5028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5116,7 +5116,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5201,7 +5201,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -5285,7 +5285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -5366,7 +5366,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversation_profile" @@ -5443,7 +5443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversation_profile" @@ -5521,7 +5521,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -5601,7 +5601,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -5682,7 +5682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_profiles.pagers.ListConversationProfilesAsyncPager", @@ -5762,7 +5762,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversation_profiles.pagers.ListConversationProfilesPager", @@ -5851,7 +5851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5939,7 +5939,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6024,7 +6024,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -6108,7 +6108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.ConversationProfile", @@ -6189,7 +6189,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6269,7 +6269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6354,7 +6354,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6438,7 +6438,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6515,7 +6515,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.GenerateStatelessSuggestionResponse", @@ -6591,7 +6591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.GenerateStatelessSuggestionResponse", @@ -6668,7 +6668,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.GenerateStatelessSummaryResponse", @@ -6744,7 +6744,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.GenerateStatelessSummaryResponse", @@ -6825,7 +6825,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6905,7 +6905,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Conversation", @@ -6986,7 +6986,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversations.pagers.ListConversationsAsyncPager", @@ -7066,7 +7066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversations.pagers.ListConversationsPager", @@ -7147,7 +7147,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversations.pagers.ListMessagesAsyncPager", @@ -7227,7 +7227,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.conversations.pagers.ListMessagesPager", @@ -7304,7 +7304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SearchKnowledgeResponse", @@ -7380,7 +7380,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SearchKnowledgeResponse", @@ -7461,7 +7461,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestConversationSummaryResponse", @@ -7541,7 +7541,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestConversationSummaryResponse", @@ -7626,7 +7626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7710,7 +7710,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7791,7 +7791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7871,7 +7871,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7948,7 +7948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8024,7 +8024,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8105,7 +8105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Document", @@ -8185,7 +8185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Document", @@ -8262,7 +8262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8338,7 +8338,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8419,7 +8419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.documents.pagers.ListDocumentsAsyncPager", @@ -8499,7 +8499,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.documents.pagers.ListDocumentsPager", @@ -8584,7 +8584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8668,7 +8668,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8753,7 +8753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -8837,7 +8837,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8918,7 +8918,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EncryptionSpec", @@ -8998,7 +8998,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EncryptionSpec", @@ -9079,7 +9079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9159,7 +9159,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9248,7 +9248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9336,7 +9336,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9425,7 +9425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9513,7 +9513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9598,7 +9598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9682,7 +9682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9771,7 +9771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -9859,7 +9859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -9936,7 +9936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -10012,7 +10012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -10101,7 +10101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10189,7 +10189,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10270,7 +10270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_entity_type" @@ -10347,7 +10347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_entity_type" @@ -10429,7 +10429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10513,7 +10513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10598,7 +10598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.entity_types.pagers.ListEntityTypesAsyncPager", @@ -10682,7 +10682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.entity_types.pagers.ListEntityTypesPager", @@ -10767,7 +10767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10851,7 +10851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.EntityType", @@ -10928,7 +10928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11004,7 +11004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11081,7 +11081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_environment" @@ -11154,7 +11154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_environment" @@ -11228,7 +11228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.environments.pagers.GetEnvironmentHistoryAsyncPager", @@ -11304,7 +11304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.environments.pagers.GetEnvironmentHistoryPager", @@ -11381,7 +11381,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11457,7 +11457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11538,7 +11538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.environments.pagers.ListEnvironmentsAsyncPager", @@ -11618,7 +11618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.environments.pagers.ListEnvironmentsPager", @@ -11695,7 +11695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11771,7 +11771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Environment", @@ -11852,7 +11852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Fulfillment", @@ -11932,7 +11932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Fulfillment", @@ -12017,7 +12017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Fulfillment", @@ -12101,7 +12101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Fulfillment", @@ -12190,7 +12190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -12278,7 +12278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -12359,7 +12359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_generator" @@ -12436,7 +12436,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_generator" @@ -12514,7 +12514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -12594,7 +12594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -12675,7 +12675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.generators.pagers.ListGeneratorsAsyncPager", @@ -12755,7 +12755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.generators.pagers.ListGeneratorsPager", @@ -12840,7 +12840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -12924,7 +12924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Generator", @@ -13009,7 +13009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13093,7 +13093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13182,7 +13182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -13270,7 +13270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -13359,7 +13359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -13447,7 +13447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -13528,7 +13528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_intent" @@ -13605,7 +13605,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_intent" @@ -13687,7 +13687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -13771,7 +13771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -13856,7 +13856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.intents.pagers.ListIntentsAsyncPager", @@ -13940,7 +13940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.intents.pagers.ListIntentsPager", @@ -14029,7 +14029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -14117,7 +14117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Intent", @@ -14202,7 +14202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -14286,7 +14286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -14367,7 +14367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_knowledge_base" @@ -14444,7 +14444,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_knowledge_base" @@ -14522,7 +14522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -14602,7 +14602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -14683,7 +14683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.knowledge_bases.pagers.ListKnowledgeBasesAsyncPager", @@ -14763,7 +14763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.knowledge_bases.pagers.ListKnowledgeBasesPager", @@ -14848,7 +14848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -14932,7 +14932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.KnowledgeBase", @@ -15021,7 +15021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.AnalyzeContentResponse", @@ -15109,7 +15109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.AnalyzeContentResponse", @@ -15194,7 +15194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -15278,7 +15278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -15359,7 +15359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -15439,7 +15439,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -15520,7 +15520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.participants.pagers.ListParticipantsAsyncPager", @@ -15600,7 +15600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.participants.pagers.ListParticipantsPager", @@ -15677,7 +15677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2.types.StreamingAnalyzeContentResponse]", @@ -15753,7 +15753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2.types.StreamingAnalyzeContentResponse]", @@ -15834,7 +15834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestArticlesResponse", @@ -15914,7 +15914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestArticlesResponse", @@ -15995,7 +15995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestFaqAnswersResponse", @@ -16075,7 +16075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestFaqAnswersResponse", @@ -16152,7 +16152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestKnowledgeAssistResponse", @@ -16228,7 +16228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestKnowledgeAssistResponse", @@ -16309,7 +16309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestSmartRepliesResponse", @@ -16389,7 +16389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SuggestSmartRepliesResponse", @@ -16474,7 +16474,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -16558,7 +16558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Participant", @@ -16643,7 +16643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -16727,7 +16727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -16808,7 +16808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_session_entity_type" @@ -16885,7 +16885,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_session_entity_type" @@ -16963,7 +16963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -17043,7 +17043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -17124,7 +17124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.session_entity_types.pagers.ListSessionEntityTypesAsyncPager", @@ -17204,7 +17204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.session_entity_types.pagers.ListSessionEntityTypesPager", @@ -17289,7 +17289,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -17373,7 +17373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.SessionEntityType", @@ -17458,7 +17458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.DetectIntentResponse", @@ -17542,7 +17542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.DetectIntentResponse", @@ -17619,7 +17619,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2.types.StreamingDetectIntentResponse]", @@ -17695,7 +17695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2.types.StreamingDetectIntentResponse]", @@ -17780,7 +17780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", @@ -17864,7 +17864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", @@ -17945,7 +17945,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_version" @@ -18022,7 +18022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_version" @@ -18100,7 +18100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", @@ -18180,7 +18180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", @@ -18261,7 +18261,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.versions.pagers.ListVersionsAsyncPager", @@ -18341,7 +18341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.services.versions.pagers.ListVersionsPager", @@ -18426,7 +18426,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", @@ -18510,7 +18510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2.types.Version", diff --git a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json index d5d9080268c4..9da05b9adb39 100644 --- a/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json +++ b/packages/google-cloud-dialogflow/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.v2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-dialogflow", - "version": "2.36.0" + "version": "0.1.0" }, "snippets": [ { @@ -47,7 +47,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent" @@ -124,7 +124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_agent" @@ -202,7 +202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -282,7 +282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -363,7 +363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Agent", @@ -443,7 +443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Agent", @@ -520,7 +520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ValidationResult", @@ -596,7 +596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ValidationResult", @@ -673,7 +673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -749,7 +749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -826,7 +826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -902,7 +902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -983,7 +983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.agents.pagers.SearchAgentsAsyncPager", @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.agents.pagers.SearchAgentsPager", @@ -1144,7 +1144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Agent", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Agent", @@ -1305,7 +1305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1385,7 +1385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1462,7 +1462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnswerRecord", @@ -1538,7 +1538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnswerRecord", @@ -1619,7 +1619,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.answer_records.pagers.ListAnswerRecordsAsyncPager", @@ -1699,7 +1699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.answer_records.pagers.ListAnswerRecordsPager", @@ -1784,7 +1784,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnswerRecord", @@ -1868,7 +1868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnswerRecord", @@ -1953,7 +1953,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2037,7 +2037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2118,7 +2118,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_all_contexts" @@ -2195,7 +2195,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_all_contexts" @@ -2273,7 +2273,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_context" @@ -2350,7 +2350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_context" @@ -2428,7 +2428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2508,7 +2508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2589,7 +2589,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.contexts.pagers.ListContextsAsyncPager", @@ -2669,7 +2669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.contexts.pagers.ListContextsPager", @@ -2754,7 +2754,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2838,7 +2838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Context", @@ -2927,7 +2927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3015,7 +3015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3100,7 +3100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -3184,7 +3184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -3265,7 +3265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversation_profile" @@ -3342,7 +3342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversation_profile" @@ -3420,7 +3420,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -3500,7 +3500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -3581,7 +3581,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversation_profiles.pagers.ListConversationProfilesAsyncPager", @@ -3661,7 +3661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversation_profiles.pagers.ListConversationProfilesPager", @@ -3750,7 +3750,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3838,7 +3838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3923,7 +3923,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -4007,7 +4007,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.ConversationProfile", @@ -4092,7 +4092,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.BatchCreateMessagesResponse", @@ -4176,7 +4176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.BatchCreateMessagesResponse", @@ -4257,7 +4257,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -4337,7 +4337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -4422,7 +4422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -4506,7 +4506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -4583,7 +4583,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.GenerateStatelessSuggestionResponse", @@ -4659,7 +4659,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.GenerateStatelessSuggestionResponse", @@ -4736,7 +4736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.GenerateStatelessSummaryResponse", @@ -4812,7 +4812,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.GenerateStatelessSummaryResponse", @@ -4893,7 +4893,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -4973,7 +4973,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Conversation", @@ -5054,7 +5054,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversations.pagers.ListConversationsAsyncPager", @@ -5134,7 +5134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversations.pagers.ListConversationsPager", @@ -5215,7 +5215,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversations.pagers.ListMessagesAsyncPager", @@ -5295,7 +5295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.conversations.pagers.ListMessagesPager", @@ -5372,7 +5372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeResponse", @@ -5448,7 +5448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SearchKnowledgeResponse", @@ -5529,7 +5529,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse", @@ -5609,7 +5609,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestConversationSummaryResponse", @@ -5694,7 +5694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5778,7 +5778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5859,7 +5859,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5939,7 +5939,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6020,7 +6020,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Document", @@ -6100,7 +6100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Document", @@ -6177,7 +6177,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6253,7 +6253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6334,7 +6334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.documents.pagers.ListDocumentsAsyncPager", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.documents.pagers.ListDocumentsPager", @@ -6499,7 +6499,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6583,7 +6583,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6668,7 +6668,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6752,7 +6752,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6833,7 +6833,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EncryptionSpec", @@ -6913,7 +6913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EncryptionSpec", @@ -6994,7 +6994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7074,7 +7074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7163,7 +7163,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7251,7 +7251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7340,7 +7340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7428,7 +7428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7513,7 +7513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7597,7 +7597,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7686,7 +7686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7774,7 +7774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -7851,7 +7851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7927,7 +7927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -8016,7 +8016,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8104,7 +8104,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8185,7 +8185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_entity_type" @@ -8262,7 +8262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_entity_type" @@ -8344,7 +8344,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8428,7 +8428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8513,7 +8513,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.entity_types.pagers.ListEntityTypesAsyncPager", @@ -8597,7 +8597,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.entity_types.pagers.ListEntityTypesPager", @@ -8686,7 +8686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8774,7 +8774,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.EntityType", @@ -8851,7 +8851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -8927,7 +8927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -9004,7 +9004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_environment" @@ -9077,7 +9077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_environment" @@ -9151,7 +9151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.environments.pagers.GetEnvironmentHistoryAsyncPager", @@ -9227,7 +9227,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.environments.pagers.GetEnvironmentHistoryPager", @@ -9304,7 +9304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -9380,7 +9380,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -9461,7 +9461,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.environments.pagers.ListEnvironmentsAsyncPager", @@ -9541,7 +9541,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.environments.pagers.ListEnvironmentsPager", @@ -9618,7 +9618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -9694,7 +9694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Environment", @@ -9775,7 +9775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Fulfillment", @@ -9855,7 +9855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Fulfillment", @@ -9940,7 +9940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Fulfillment", @@ -10024,7 +10024,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Fulfillment", @@ -10113,7 +10113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10201,7 +10201,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10282,7 +10282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_generator" @@ -10359,7 +10359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_generator" @@ -10437,7 +10437,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10517,7 +10517,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10598,7 +10598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.generators.pagers.ListGeneratorsAsyncPager", @@ -10678,7 +10678,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.generators.pagers.ListGeneratorsPager", @@ -10763,7 +10763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10847,7 +10847,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Generator", @@ -10932,7 +10932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11016,7 +11016,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11105,7 +11105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -11193,7 +11193,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -11282,7 +11282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -11370,7 +11370,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -11451,7 +11451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_intent" @@ -11528,7 +11528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_intent" @@ -11610,7 +11610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -11694,7 +11694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -11779,7 +11779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.intents.pagers.ListIntentsAsyncPager", @@ -11863,7 +11863,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.intents.pagers.ListIntentsPager", @@ -11952,7 +11952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -12040,7 +12040,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Intent", @@ -12125,7 +12125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12209,7 +12209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12290,7 +12290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_knowledge_base" @@ -12367,7 +12367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_knowledge_base" @@ -12445,7 +12445,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12525,7 +12525,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12606,7 +12606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.knowledge_bases.pagers.ListKnowledgeBasesAsyncPager", @@ -12686,7 +12686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.knowledge_bases.pagers.ListKnowledgeBasesPager", @@ -12771,7 +12771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12855,7 +12855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.KnowledgeBase", @@ -12948,7 +12948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnalyzeContentResponse", @@ -13040,7 +13040,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.AnalyzeContentResponse", @@ -13117,7 +13117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.CompileSuggestionResponse", @@ -13193,7 +13193,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.CompileSuggestionResponse", @@ -13278,7 +13278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -13362,7 +13362,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -13443,7 +13443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -13523,7 +13523,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -13604,7 +13604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.participants.pagers.ListParticipantsAsyncPager", @@ -13684,7 +13684,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.participants.pagers.ListParticipantsPager", @@ -13761,7 +13761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsAsyncPager", @@ -13837,7 +13837,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.participants.pagers.ListSuggestionsPager", @@ -13914,7 +13914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2beta1.types.StreamingAnalyzeContentResponse]", @@ -13990,7 +13990,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2beta1.types.StreamingAnalyzeContentResponse]", @@ -14071,7 +14071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestArticlesResponse", @@ -14151,7 +14151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestArticlesResponse", @@ -14232,7 +14232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestFaqAnswersResponse", @@ -14312,7 +14312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestFaqAnswersResponse", @@ -14389,7 +14389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestKnowledgeAssistResponse", @@ -14465,7 +14465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestKnowledgeAssistResponse", @@ -14546,7 +14546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestSmartRepliesResponse", @@ -14626,7 +14626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SuggestSmartRepliesResponse", @@ -14711,7 +14711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -14795,7 +14795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Participant", @@ -14880,7 +14880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -14964,7 +14964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -15045,7 +15045,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_session_entity_type" @@ -15122,7 +15122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_session_entity_type" @@ -15200,7 +15200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -15280,7 +15280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -15361,7 +15361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.session_entity_types.pagers.ListSessionEntityTypesAsyncPager", @@ -15441,7 +15441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.session_entity_types.pagers.ListSessionEntityTypesPager", @@ -15526,7 +15526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -15610,7 +15610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SessionEntityType", @@ -15695,7 +15695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.DetectIntentResponse", @@ -15779,7 +15779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.DetectIntentResponse", @@ -15856,7 +15856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2beta1.types.StreamingDetectIntentResponse]", @@ -15932,7 +15932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.dialogflow_v2beta1.types.StreamingDetectIntentResponse]", @@ -16017,7 +16017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16101,7 +16101,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16182,7 +16182,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_sip_trunk" @@ -16259,7 +16259,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_sip_trunk" @@ -16337,7 +16337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16417,7 +16417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16498,7 +16498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.sip_trunks.pagers.ListSipTrunksAsyncPager", @@ -16578,7 +16578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.sip_trunks.pagers.ListSipTrunksPager", @@ -16663,7 +16663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16747,7 +16747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.SipTrunk", @@ -16832,7 +16832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", @@ -16916,7 +16916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", @@ -16997,7 +16997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_version" @@ -17074,7 +17074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_version" @@ -17152,7 +17152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", @@ -17232,7 +17232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", @@ -17313,7 +17313,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.versions.pagers.ListVersionsAsyncPager", @@ -17393,7 +17393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.services.versions.pagers.ListVersionsPager", @@ -17478,7 +17478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", @@ -17562,7 +17562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.dialogflow_v2beta1.types.Version", diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_agents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_agents.py index b31827b8bd22..aced1370e2d5 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_agents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_agents.py @@ -4069,6 +4069,7 @@ def test_get_agent_rest_required_fields(request_type=agent.GetAgentRequest): 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_agent(request) @@ -4114,6 +4115,7 @@ def test_get_agent_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_agent(**mock_args) @@ -4239,6 +4241,7 @@ def test_set_agent_rest_required_fields(request_type=gcd_agent.SetAgentRequest): 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_agent(request) @@ -4284,6 +4287,7 @@ def test_set_agent_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_agent(**mock_args) @@ -4408,6 +4412,7 @@ def test_delete_agent_rest_required_fields(request_type=agent.DeleteAgentRequest 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_agent(request) @@ -4451,6 +4456,7 @@ def test_delete_agent_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_agent(**mock_args) @@ -4585,6 +4591,7 @@ def test_search_agents_rest_required_fields(request_type=agent.SearchAgentsReque 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.search_agents(request) @@ -4638,6 +4645,7 @@ def test_search_agents_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.search_agents(**mock_args) @@ -4828,6 +4836,7 @@ def test_train_agent_rest_required_fields(request_type=agent.TrainAgentRequest): 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.train_agent(request) @@ -4871,6 +4880,7 @@ def test_train_agent_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.train_agent(**mock_args) @@ -5004,6 +5014,7 @@ def test_export_agent_rest_required_fields(request_type=agent.ExportAgentRequest 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.export_agent(request) @@ -5055,6 +5066,7 @@ def test_export_agent_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.export_agent(**mock_args) @@ -5184,6 +5196,7 @@ def test_import_agent_rest_required_fields(request_type=agent.ImportAgentRequest 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.import_agent(request) @@ -5303,6 +5316,7 @@ def test_restore_agent_rest_required_fields(request_type=agent.RestoreAgentReque 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.restore_agent(request) @@ -5429,6 +5443,7 @@ def test_get_validation_result_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_validation_result(request) @@ -6036,6 +6051,7 @@ def test_get_agent_rest_bad_request(request_type=agent.GetAgentRequest): 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_agent(request) @@ -6082,6 +6098,7 @@ def test_get_agent_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_agent(request) # Establish that the response is the type that we expect. @@ -6131,6 +6148,7 @@ def test_get_agent_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 = agent.Agent.to_json(agent.Agent()) req.return_value.content = return_value @@ -6173,6 +6191,7 @@ def test_set_agent_rest_bad_request(request_type=gcd_agent.SetAgentRequest): 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_agent(request) @@ -6303,6 +6322,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.set_agent(request) # Establish that the response is the type that we expect. @@ -6352,6 +6372,7 @@ def test_set_agent_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 = gcd_agent.Agent.to_json(gcd_agent.Agent()) req.return_value.content = return_value @@ -6394,6 +6415,7 @@ def test_delete_agent_rest_bad_request(request_type=agent.DeleteAgentRequest): 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_agent(request) @@ -6424,6 +6446,7 @@ def test_delete_agent_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_agent(request) # Establish that the response is the type that we expect. @@ -6456,6 +6479,7 @@ def test_delete_agent_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 = agent.DeleteAgentRequest() metadata = [ @@ -6494,6 +6518,7 @@ def test_search_agents_rest_bad_request(request_type=agent.SearchAgentsRequest): 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.search_agents(request) @@ -6529,6 +6554,7 @@ def test_search_agents_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.search_agents(request) # Establish that the response is the type that we expect. @@ -6565,6 +6591,7 @@ def test_search_agents_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 = agent.SearchAgentsResponse.to_json(agent.SearchAgentsResponse()) req.return_value.content = return_value @@ -6607,6 +6634,7 @@ def test_train_agent_rest_bad_request(request_type=agent.TrainAgentRequest): 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.train_agent(request) @@ -6637,6 +6665,7 @@ def test_train_agent_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.train_agent(request) # Establish that the response is the type that we expect. @@ -6674,6 +6703,7 @@ def test_train_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6716,6 +6746,7 @@ def test_export_agent_rest_bad_request(request_type=agent.ExportAgentRequest): 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.export_agent(request) @@ -6746,6 +6777,7 @@ def test_export_agent_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.export_agent(request) # Establish that the response is the type that we expect. @@ -6783,6 +6815,7 @@ def test_export_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6825,6 +6858,7 @@ def test_import_agent_rest_bad_request(request_type=agent.ImportAgentRequest): 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.import_agent(request) @@ -6855,6 +6889,7 @@ def test_import_agent_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.import_agent(request) # Establish that the response is the type that we expect. @@ -6892,6 +6927,7 @@ def test_import_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6934,6 +6970,7 @@ def test_restore_agent_rest_bad_request(request_type=agent.RestoreAgentRequest): 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.restore_agent(request) @@ -6964,6 +7001,7 @@ def test_restore_agent_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.restore_agent(request) # Establish that the response is the type that we expect. @@ -7001,6 +7039,7 @@ def test_restore_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7045,6 +7084,7 @@ def test_get_validation_result_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_validation_result(request) @@ -7078,6 +7118,7 @@ def test_get_validation_result_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_validation_result(request) # Establish that the response is the type that we expect. @@ -7115,6 +7156,7 @@ def test_get_validation_result_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 = validation_result.ValidationResult.to_json( validation_result.ValidationResult() ) @@ -7161,6 +7203,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) @@ -7191,6 +7234,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) @@ -7219,6 +7263,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) @@ -7249,6 +7294,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) @@ -7279,6 +7325,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7309,6 +7356,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7339,6 +7387,7 @@ def test_get_operation_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.get_operation(request) @@ -7369,6 +7418,7 @@ def test_get_operation_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_operation(request) @@ -7397,6 +7447,7 @@ def test_list_operations_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_operations(request) @@ -7427,6 +7478,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_answer_records.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_answer_records.py index 1f44e1447d4f..ce401ed83240 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_answer_records.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_answer_records.py @@ -2075,6 +2075,7 @@ def test_list_answer_records_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.list_answer_records(request) @@ -2129,6 +2130,7 @@ def test_list_answer_records_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_answer_records(**mock_args) @@ -2323,6 +2325,7 @@ def test_update_answer_record_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.update_answer_record(request) @@ -2379,6 +2382,7 @@ def test_update_answer_record_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_answer_record(**mock_args) @@ -2661,6 +2665,7 @@ def test_list_answer_records_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.list_answer_records(request) @@ -2696,6 +2701,7 @@ def test_list_answer_records_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_answer_records(request) # Establish that the response is the type that we expect. @@ -2736,6 +2742,7 @@ def test_list_answer_records_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 = answer_record.ListAnswerRecordsResponse.to_json( answer_record.ListAnswerRecordsResponse() ) @@ -2782,6 +2789,7 @@ def test_update_answer_record_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.update_answer_record(request) @@ -3144,6 +3152,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_answer_record(request) # Establish that the response is the type that we expect. @@ -3184,6 +3193,7 @@ def test_update_answer_record_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 = gcd_answer_record.AnswerRecord.to_json( gcd_answer_record.AnswerRecord() ) @@ -3230,6 +3240,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) @@ -3260,6 +3271,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) @@ -3288,6 +3300,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) @@ -3318,6 +3331,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) @@ -3348,6 +3362,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -3378,6 +3393,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -3408,6 +3424,7 @@ def test_get_operation_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.get_operation(request) @@ -3438,6 +3455,7 @@ def test_get_operation_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_operation(request) @@ -3466,6 +3484,7 @@ def test_list_operations_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_operations(request) @@ -3496,6 +3515,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_contexts.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_contexts.py index feff4fc95e5e..43fdefbc3c57 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_contexts.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_contexts.py @@ -3263,6 +3263,7 @@ def test_list_contexts_rest_required_fields(request_type=context.ListContextsReq 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_contexts(request) @@ -3316,6 +3317,7 @@ def test_list_contexts_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_contexts(**mock_args) @@ -3506,6 +3508,7 @@ def test_get_context_rest_required_fields(request_type=context.GetContextRequest 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_context(request) @@ -3553,6 +3556,7 @@ def test_get_context_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_context(**mock_args) @@ -3685,6 +3689,7 @@ def test_create_context_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.create_context(request) @@ -3739,6 +3744,7 @@ def test_create_context_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_context(**mock_args) @@ -3869,6 +3875,7 @@ def test_update_context_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.update_context(request) @@ -3919,6 +3926,7 @@ def test_update_context_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_context(**mock_args) @@ -4046,6 +4054,7 @@ def test_delete_context_rest_required_fields(request_type=context.DeleteContextR 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_context(request) @@ -4091,6 +4100,7 @@ def test_delete_context_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_context(**mock_args) @@ -4223,6 +4233,7 @@ def test_delete_all_contexts_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.delete_all_contexts(request) @@ -4266,6 +4277,7 @@ def test_delete_all_contexts_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_all_contexts(**mock_args) @@ -4728,6 +4740,7 @@ def test_list_contexts_rest_bad_request(request_type=context.ListContextsRequest 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_contexts(request) @@ -4763,6 +4776,7 @@ def test_list_contexts_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_contexts(request) # Establish that the response is the type that we expect. @@ -4799,6 +4813,7 @@ def test_list_contexts_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 = context.ListContextsResponse.to_json( context.ListContextsResponse() ) @@ -4843,6 +4858,7 @@ def test_get_context_rest_bad_request(request_type=context.GetContextRequest): 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_context(request) @@ -4879,6 +4895,7 @@ def test_get_context_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_context(request) # Establish that the response is the type that we expect. @@ -4916,6 +4933,7 @@ def test_get_context_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 = context.Context.to_json(context.Context()) req.return_value.content = return_value @@ -4958,6 +4976,7 @@ def test_create_context_rest_bad_request(request_type=gcd_context.CreateContextR 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_context(request) @@ -5066,6 +5085,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_context(request) # Establish that the response is the type that we expect. @@ -5105,6 +5125,7 @@ def test_create_context_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 = gcd_context.Context.to_json(gcd_context.Context()) req.return_value.content = return_value @@ -5149,6 +5170,7 @@ def test_update_context_rest_bad_request(request_type=gcd_context.UpdateContextR 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_context(request) @@ -5259,6 +5281,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_context(request) # Establish that the response is the type that we expect. @@ -5298,6 +5321,7 @@ def test_update_context_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 = gcd_context.Context.to_json(gcd_context.Context()) req.return_value.content = return_value @@ -5340,6 +5364,7 @@ def test_delete_context_rest_bad_request(request_type=context.DeleteContextReque 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_context(request) @@ -5370,6 +5395,7 @@ def test_delete_context_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_context(request) # Establish that the response is the type that we expect. @@ -5402,6 +5428,7 @@ def test_delete_context_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 = context.DeleteContextRequest() metadata = [ @@ -5442,6 +5469,7 @@ def test_delete_all_contexts_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.delete_all_contexts(request) @@ -5472,6 +5500,7 @@ def test_delete_all_contexts_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_all_contexts(request) # Establish that the response is the type that we expect. @@ -5506,6 +5535,7 @@ def test_delete_all_contexts_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 = context.DeleteAllContextsRequest() metadata = [ @@ -5546,6 +5576,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) @@ -5576,6 +5607,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) @@ -5604,6 +5636,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) @@ -5634,6 +5667,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) @@ -5664,6 +5698,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5694,6 +5729,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5724,6 +5760,7 @@ def test_get_operation_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.get_operation(request) @@ -5754,6 +5791,7 @@ def test_get_operation_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_operation(request) @@ -5782,6 +5820,7 @@ def test_list_operations_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_operations(request) @@ -5812,6 +5851,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py index 3ffa7d3b3507..a7e9c4b55913 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_datasets.py @@ -3138,6 +3138,7 @@ def test_create_conversation_dataset_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.create_conversation_dataset(request) @@ -3192,6 +3193,7 @@ def test_create_conversation_dataset_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_conversation_dataset(**mock_args) @@ -3331,6 +3333,7 @@ def test_get_conversation_dataset_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_conversation_dataset(request) @@ -3376,6 +3379,7 @@ def test_get_conversation_dataset_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_conversation_dataset(**mock_args) @@ -3520,6 +3524,7 @@ def test_list_conversation_datasets_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.list_conversation_datasets(request) @@ -3575,6 +3580,7 @@ def test_list_conversation_datasets_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_conversation_datasets(**mock_args) @@ -3777,6 +3783,7 @@ def test_delete_conversation_dataset_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.delete_conversation_dataset(request) @@ -3822,6 +3829,7 @@ def test_delete_conversation_dataset_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.delete_conversation_dataset(**mock_args) @@ -3960,6 +3968,7 @@ def test_import_conversation_data_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.import_conversation_data(request) @@ -4392,6 +4401,7 @@ def test_create_conversation_dataset_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.create_conversation_dataset(request) @@ -4504,6 +4514,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_conversation_dataset(request) # Establish that the response is the type that we expect. @@ -4547,6 +4558,7 @@ def test_create_conversation_dataset_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -4591,6 +4603,7 @@ def test_get_conversation_dataset_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_conversation_dataset(request) @@ -4631,6 +4644,7 @@ def test_get_conversation_dataset_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_conversation_dataset(request) # Establish that the response is the type that we expect. @@ -4676,6 +4690,7 @@ def test_get_conversation_dataset_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 = conversation_dataset.ConversationDataset.to_json( conversation_dataset.ConversationDataset() ) @@ -4722,6 +4737,7 @@ def test_list_conversation_datasets_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.list_conversation_datasets(request) @@ -4759,6 +4775,7 @@ def test_list_conversation_datasets_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_conversation_datasets(request) # Establish that the response is the type that we expect. @@ -4800,6 +4817,7 @@ def test_list_conversation_datasets_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 = conversation_dataset.ListConversationDatasetsResponse.to_json( conversation_dataset.ListConversationDatasetsResponse() ) @@ -4848,6 +4866,7 @@ def test_delete_conversation_dataset_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.delete_conversation_dataset(request) @@ -4880,6 +4899,7 @@ def test_delete_conversation_dataset_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.delete_conversation_dataset(request) # Establish that the response is the type that we expect. @@ -4923,6 +4943,7 @@ def test_delete_conversation_dataset_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -4967,6 +4988,7 @@ def test_import_conversation_data_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.import_conversation_data(request) @@ -4997,6 +5019,7 @@ def test_import_conversation_data_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.import_conversation_data(request) # Establish that the response is the type that we expect. @@ -5038,6 +5061,7 @@ def test_import_conversation_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5082,6 +5106,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) @@ -5112,6 +5137,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) @@ -5140,6 +5166,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) @@ -5170,6 +5197,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) @@ -5200,6 +5228,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5230,6 +5259,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5260,6 +5290,7 @@ def test_get_operation_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.get_operation(request) @@ -5290,6 +5321,7 @@ def test_get_operation_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_operation(request) @@ -5318,6 +5350,7 @@ def test_list_operations_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_operations(request) @@ -5348,6 +5381,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_models.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_models.py index 4688723fb4ac..3a2f483d9d78 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_models.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_models.py @@ -4650,6 +4650,7 @@ def test_create_conversation_model_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.create_conversation_model(request) @@ -4696,6 +4697,7 @@ def test_create_conversation_model_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_conversation_model(**mock_args) @@ -4834,6 +4836,7 @@ def test_get_conversation_model_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_conversation_model(request) @@ -4879,6 +4882,7 @@ def test_get_conversation_model_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_conversation_model(**mock_args) @@ -5023,6 +5027,7 @@ def test_list_conversation_models_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.list_conversation_models(request) @@ -5078,6 +5083,7 @@ def test_list_conversation_models_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_conversation_models(**mock_args) @@ -5278,6 +5284,7 @@ def test_delete_conversation_model_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.delete_conversation_model(request) @@ -5321,6 +5328,7 @@ def test_delete_conversation_model_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.delete_conversation_model(**mock_args) @@ -5458,6 +5466,7 @@ def test_deploy_conversation_model_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.deploy_conversation_model(request) @@ -5584,6 +5593,7 @@ def test_undeploy_conversation_model_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.undeploy_conversation_model(request) @@ -5710,6 +5720,7 @@ def test_get_conversation_model_evaluation_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_conversation_model_evaluation(request) @@ -5759,6 +5770,7 @@ def test_get_conversation_model_evaluation_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_conversation_model_evaluation(**mock_args) @@ -5908,6 +5920,7 @@ def test_list_conversation_model_evaluations_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.list_conversation_model_evaluations(request) @@ -5965,6 +5978,7 @@ def test_list_conversation_model_evaluations_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_conversation_model_evaluations(**mock_args) @@ -6174,6 +6188,7 @@ def test_create_conversation_model_evaluation_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.create_conversation_model_evaluation(request) @@ -6232,6 +6247,7 @@ def test_create_conversation_model_evaluation_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_conversation_model_evaluation(**mock_args) @@ -6881,6 +6897,7 @@ def test_create_conversation_model_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.create_conversation_model(request) @@ -6992,6 +7009,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_conversation_model(request) # Establish that the response is the type that we expect. @@ -7033,6 +7051,7 @@ def test_create_conversation_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7077,6 +7096,7 @@ def test_get_conversation_model_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_conversation_model(request) @@ -7117,6 +7137,7 @@ def test_get_conversation_model_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_conversation_model(request) # Establish that the response is the type that we expect. @@ -7162,6 +7183,7 @@ def test_get_conversation_model_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 = conversation_model.ConversationModel.to_json( conversation_model.ConversationModel() ) @@ -7208,6 +7230,7 @@ def test_list_conversation_models_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.list_conversation_models(request) @@ -7245,6 +7268,7 @@ def test_list_conversation_models_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_conversation_models(request) # Establish that the response is the type that we expect. @@ -7285,6 +7309,7 @@ def test_list_conversation_models_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 = conversation_model.ListConversationModelsResponse.to_json( conversation_model.ListConversationModelsResponse() ) @@ -7331,6 +7356,7 @@ def test_delete_conversation_model_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.delete_conversation_model(request) @@ -7361,6 +7387,7 @@ def test_delete_conversation_model_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.delete_conversation_model(request) # Establish that the response is the type that we expect. @@ -7402,6 +7429,7 @@ def test_delete_conversation_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7446,6 +7474,7 @@ def test_deploy_conversation_model_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.deploy_conversation_model(request) @@ -7476,6 +7505,7 @@ def test_deploy_conversation_model_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.deploy_conversation_model(request) # Establish that the response is the type that we expect. @@ -7517,6 +7547,7 @@ def test_deploy_conversation_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7561,6 +7592,7 @@ def test_undeploy_conversation_model_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.undeploy_conversation_model(request) @@ -7591,6 +7623,7 @@ def test_undeploy_conversation_model_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.undeploy_conversation_model(request) # Establish that the response is the type that we expect. @@ -7632,6 +7665,7 @@ def test_undeploy_conversation_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7678,6 +7712,7 @@ def test_get_conversation_model_evaluation_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_conversation_model_evaluation(request) @@ -7717,6 +7752,7 @@ def test_get_conversation_model_evaluation_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_conversation_model_evaluation(request) # Establish that the response is the type that we expect. @@ -7761,6 +7797,7 @@ def test_get_conversation_model_evaluation_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 = conversation_model.ConversationModelEvaluation.to_json( conversation_model.ConversationModelEvaluation() ) @@ -7807,6 +7844,7 @@ def test_list_conversation_model_evaluations_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.list_conversation_model_evaluations(request) @@ -7844,6 +7882,7 @@ def test_list_conversation_model_evaluations_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_conversation_model_evaluations(request) # Establish that the response is the type that we expect. @@ -7886,6 +7925,7 @@ def test_list_conversation_model_evaluations_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 = ( conversation_model.ListConversationModelEvaluationsResponse.to_json( conversation_model.ListConversationModelEvaluationsResponse() @@ -7938,6 +7978,7 @@ def test_create_conversation_model_evaluation_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.create_conversation_model_evaluation(request) @@ -7970,6 +8011,7 @@ def test_create_conversation_model_evaluation_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_conversation_model_evaluation(request) # Establish that the response is the type that we expect. @@ -8013,6 +8055,7 @@ def test_create_conversation_model_evaluation_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8057,6 +8100,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) @@ -8087,6 +8131,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) @@ -8115,6 +8160,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) @@ -8145,6 +8191,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) @@ -8175,6 +8222,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8205,6 +8253,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8235,6 +8284,7 @@ def test_get_operation_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.get_operation(request) @@ -8265,6 +8315,7 @@ def test_get_operation_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_operation(request) @@ -8293,6 +8344,7 @@ def test_list_operations_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_operations(request) @@ -8323,6 +8375,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py index 9a27fa90352e..87487ae97adb 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py @@ -4009,6 +4009,7 @@ def test_list_conversation_profiles_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.list_conversation_profiles(request) @@ -4064,6 +4065,7 @@ def test_list_conversation_profiles_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_conversation_profiles(**mock_args) @@ -4265,6 +4267,7 @@ def test_get_conversation_profile_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_conversation_profile(request) @@ -4310,6 +4313,7 @@ def test_get_conversation_profile_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_conversation_profile(**mock_args) @@ -4446,6 +4450,7 @@ def test_create_conversation_profile_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.create_conversation_profile(request) @@ -4502,6 +4507,7 @@ def test_create_conversation_profile_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_conversation_profile(**mock_args) @@ -4638,6 +4644,7 @@ def test_update_conversation_profile_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.update_conversation_profile(request) @@ -4698,6 +4705,7 @@ def test_update_conversation_profile_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_conversation_profile(**mock_args) @@ -4834,6 +4842,7 @@ def test_delete_conversation_profile_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.delete_conversation_profile(request) @@ -4877,6 +4886,7 @@ def test_delete_conversation_profile_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_conversation_profile(**mock_args) @@ -5014,6 +5024,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) @@ -5076,6 +5087,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(**mock_args) @@ -5220,6 +5232,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) @@ -5278,6 +5291,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(**mock_args) @@ -5825,6 +5839,7 @@ def test_list_conversation_profiles_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.list_conversation_profiles(request) @@ -5862,6 +5877,7 @@ def test_list_conversation_profiles_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_conversation_profiles(request) # Establish that the response is the type that we expect. @@ -5903,6 +5919,7 @@ def test_list_conversation_profiles_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 = conversation_profile.ListConversationProfilesResponse.to_json( conversation_profile.ListConversationProfilesResponse() ) @@ -5949,6 +5966,7 @@ def test_get_conversation_profile_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_conversation_profile(request) @@ -5988,6 +6006,7 @@ def test_get_conversation_profile_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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6032,6 +6051,7 @@ def test_get_conversation_profile_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 = conversation_profile.ConversationProfile.to_json( conversation_profile.ConversationProfile() ) @@ -6078,6 +6098,7 @@ def test_create_conversation_profile_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.create_conversation_profile(request) @@ -6289,6 +6310,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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6335,6 +6357,7 @@ def test_create_conversation_profile_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 = gcd_conversation_profile.ConversationProfile.to_json( gcd_conversation_profile.ConversationProfile() ) @@ -6385,6 +6408,7 @@ def test_update_conversation_profile_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.update_conversation_profile(request) @@ -6600,6 +6624,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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6646,6 +6671,7 @@ def test_update_conversation_profile_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 = gcd_conversation_profile.ConversationProfile.to_json( gcd_conversation_profile.ConversationProfile() ) @@ -6692,6 +6718,7 @@ def test_delete_conversation_profile_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.delete_conversation_profile(request) @@ -6722,6 +6749,7 @@ def test_delete_conversation_profile_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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6759,6 +6787,7 @@ def test_delete_conversation_profile_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 = conversation_profile.DeleteConversationProfileRequest() metadata = [ @@ -6801,6 +6830,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) @@ -6833,6 +6863,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) # Establish that the response is the type that we expect. @@ -6876,6 +6907,7 @@ def test_set_suggestion_feature_config_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6922,6 +6954,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) @@ -6954,6 +6987,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) # Establish that the response is the type that we expect. @@ -6997,6 +7031,7 @@ def test_clear_suggestion_feature_config_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7041,6 +7076,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) @@ -7071,6 +7107,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) @@ -7099,6 +7136,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) @@ -7129,6 +7167,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) @@ -7159,6 +7198,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7189,6 +7229,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7219,6 +7260,7 @@ def test_get_operation_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.get_operation(request) @@ -7249,6 +7291,7 @@ def test_get_operation_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_operation(request) @@ -7277,6 +7320,7 @@ def test_list_operations_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_operations(request) @@ -7307,6 +7351,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversations.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversations.py index 535449046e59..b785646e2385 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversations.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_conversations.py @@ -4453,6 +4453,7 @@ def test_create_conversation_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.create_conversation(request) @@ -4507,6 +4508,7 @@ def test_create_conversation_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_conversation(**mock_args) @@ -4649,6 +4651,7 @@ def test_list_conversations_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.list_conversations(request) @@ -4703,6 +4706,7 @@ def test_list_conversations_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_conversations(**mock_args) @@ -4897,6 +4901,7 @@ def test_get_conversation_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_conversation(request) @@ -4942,6 +4947,7 @@ def test_get_conversation_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_conversation(**mock_args) @@ -5077,6 +5083,7 @@ def test_complete_conversation_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.complete_conversation(request) @@ -5122,6 +5129,7 @@ def test_complete_conversation_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.complete_conversation(**mock_args) @@ -5260,6 +5268,7 @@ def test_list_messages_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.list_messages(request) @@ -5314,6 +5323,7 @@ def test_list_messages_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_messages(**mock_args) @@ -5514,6 +5524,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) @@ -5561,6 +5572,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(**mock_args) @@ -5695,6 +5707,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) @@ -5830,6 +5843,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) @@ -5962,6 +5976,7 @@ def test_search_knowledge_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.search_knowledge(request) @@ -6602,6 +6617,7 @@ def test_create_conversation_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.create_conversation(request) @@ -6716,6 +6732,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_conversation(request) # Establish that the response is the type that we expect. @@ -6765,6 +6782,7 @@ def test_create_conversation_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 = gcd_conversation.Conversation.to_json( gcd_conversation.Conversation() ) @@ -6811,6 +6829,7 @@ def test_list_conversations_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.list_conversations(request) @@ -6846,6 +6865,7 @@ def test_list_conversations_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_conversations(request) # Establish that the response is the type that we expect. @@ -6886,6 +6906,7 @@ def test_list_conversations_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 = conversation.ListConversationsResponse.to_json( conversation.ListConversationsResponse() ) @@ -6932,6 +6953,7 @@ def test_get_conversation_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_conversation(request) @@ -6970,6 +6992,7 @@ def test_get_conversation_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_conversation(request) # Establish that the response is the type that we expect. @@ -7018,6 +7041,7 @@ def test_get_conversation_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 = conversation.Conversation.to_json(conversation.Conversation()) req.return_value.content = return_value @@ -7062,6 +7086,7 @@ def test_complete_conversation_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.complete_conversation(request) @@ -7100,6 +7125,7 @@ def test_complete_conversation_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.complete_conversation(request) # Establish that the response is the type that we expect. @@ -7148,6 +7174,7 @@ def test_complete_conversation_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 = conversation.Conversation.to_json(conversation.Conversation()) req.return_value.content = return_value @@ -7190,6 +7217,7 @@ def test_list_messages_rest_bad_request(request_type=conversation.ListMessagesRe 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_messages(request) @@ -7225,6 +7253,7 @@ def test_list_messages_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_messages(request) # Establish that the response is the type that we expect. @@ -7265,6 +7294,7 @@ def test_list_messages_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 = conversation.ListMessagesResponse.to_json( conversation.ListMessagesResponse() ) @@ -7311,6 +7341,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) @@ -7349,6 +7380,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) # Establish that the response is the type that we expect. @@ -7390,6 +7422,7 @@ def test_suggest_conversation_summary_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 = gcd_conversation.SuggestConversationSummaryResponse.to_json( gcd_conversation.SuggestConversationSummaryResponse() ) @@ -7436,6 +7469,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) @@ -7472,6 +7506,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) # Establish that the response is the type that we expect. @@ -7513,6 +7548,7 @@ def test_generate_stateless_summary_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 = conversation.GenerateStatelessSummaryResponse.to_json( conversation.GenerateStatelessSummaryResponse() ) @@ -7559,6 +7595,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) @@ -7592,6 +7629,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) # Establish that the response is the type that we expect. @@ -7631,6 +7669,7 @@ def test_generate_stateless_suggestion_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 = conversation.GenerateStatelessSuggestionResponse.to_json( conversation.GenerateStatelessSuggestionResponse() ) @@ -7677,6 +7716,7 @@ def test_search_knowledge_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.search_knowledge(request) @@ -7712,6 +7752,7 @@ def test_search_knowledge_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.search_knowledge(request) # Establish that the response is the type that we expect. @@ -7752,6 +7793,7 @@ def test_search_knowledge_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 = conversation.SearchKnowledgeResponse.to_json( conversation.SearchKnowledgeResponse() ) @@ -7798,6 +7840,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) @@ -7828,6 +7871,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) @@ -7856,6 +7900,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) @@ -7886,6 +7931,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) @@ -7916,6 +7962,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7946,6 +7993,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7976,6 +8024,7 @@ def test_get_operation_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.get_operation(request) @@ -8006,6 +8055,7 @@ def test_get_operation_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_operation(request) @@ -8034,6 +8084,7 @@ def test_list_operations_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_operations(request) @@ -8064,6 +8115,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_documents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_documents.py index e2eaaeb2d2ad..e4e4c82e7ca5 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_documents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_documents.py @@ -3831,6 +3831,7 @@ def test_list_documents_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.list_documents(request) @@ -3885,6 +3886,7 @@ def test_list_documents_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_documents(**mock_args) @@ -4075,6 +4077,7 @@ def test_get_document_rest_required_fields(request_type=document.GetDocumentRequ 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_document(request) @@ -4122,6 +4125,7 @@ def test_get_document_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_document(**mock_args) @@ -4255,6 +4259,7 @@ def test_create_document_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.create_document(request) @@ -4307,6 +4312,7 @@ def test_create_document_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_document(**mock_args) @@ -4443,6 +4449,7 @@ def test_import_documents_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.import_documents(request) @@ -4571,6 +4578,7 @@ def test_delete_document_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.delete_document(request) @@ -4616,6 +4624,7 @@ def test_delete_document_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.delete_document(**mock_args) @@ -4746,6 +4755,7 @@ def test_update_document_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.update_document(request) @@ -4794,6 +4804,7 @@ def test_update_document_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_document(**mock_args) @@ -4928,6 +4939,7 @@ def test_reload_document_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.reload_document(request) @@ -4973,6 +4985,7 @@ def test_reload_document_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.reload_document(**mock_args) @@ -5107,6 +5120,7 @@ def test_export_document_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.export_document(request) @@ -5647,6 +5661,7 @@ def test_list_documents_rest_bad_request(request_type=document.ListDocumentsRequ 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_documents(request) @@ -5682,6 +5697,7 @@ def test_list_documents_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_documents(request) # Establish that the response is the type that we expect. @@ -5718,6 +5734,7 @@ def test_list_documents_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 = document.ListDocumentsResponse.to_json( document.ListDocumentsResponse() ) @@ -5762,6 +5779,7 @@ def test_get_document_rest_bad_request(request_type=document.GetDocumentRequest) 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_document(request) @@ -5803,6 +5821,7 @@ def test_get_document_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_document(request) # Establish that the response is the type that we expect. @@ -5844,6 +5863,7 @@ def test_get_document_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 = document.Document.to_json(document.Document()) req.return_value.content = return_value @@ -5888,6 +5908,7 @@ def test_create_document_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.create_document(request) @@ -6009,6 +6030,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_document(request) # Establish that the response is the type that we expect. @@ -6048,6 +6070,7 @@ def test_create_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6092,6 +6115,7 @@ def test_import_documents_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.import_documents(request) @@ -6122,6 +6146,7 @@ def test_import_documents_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.import_documents(request) # Establish that the response is the type that we expect. @@ -6161,6 +6186,7 @@ def test_import_documents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6203,6 +6229,7 @@ def test_delete_document_rest_bad_request(request_type=document.DeleteDocumentRe 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_document(request) @@ -6233,6 +6260,7 @@ def test_delete_document_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.delete_document(request) # Establish that the response is the type that we expect. @@ -6270,6 +6298,7 @@ def test_delete_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6318,6 +6347,7 @@ def test_update_document_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.update_document(request) @@ -6443,6 +6473,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_document(request) # Establish that the response is the type that we expect. @@ -6482,6 +6513,7 @@ def test_update_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6524,6 +6556,7 @@ def test_reload_document_rest_bad_request(request_type=document.ReloadDocumentRe 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.reload_document(request) @@ -6554,6 +6587,7 @@ def test_reload_document_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.reload_document(request) # Establish that the response is the type that we expect. @@ -6591,6 +6625,7 @@ def test_reload_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6633,6 +6668,7 @@ def test_export_document_rest_bad_request(request_type=document.ExportDocumentRe 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.export_document(request) @@ -6663,6 +6699,7 @@ def test_export_document_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.export_document(request) # Establish that the response is the type that we expect. @@ -6700,6 +6737,7 @@ def test_export_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6744,6 +6782,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) @@ -6774,6 +6813,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) @@ -6802,6 +6842,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) @@ -6832,6 +6873,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) @@ -6862,6 +6904,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6892,6 +6935,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6922,6 +6966,7 @@ def test_get_operation_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.get_operation(request) @@ -6952,6 +6997,7 @@ def test_get_operation_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_operation(request) @@ -6980,6 +7026,7 @@ def test_list_operations_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_operations(request) @@ -7010,6 +7057,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_encryption_spec_service.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_encryption_spec_service.py index 28bca7237b05..4cd2f5c3f96e 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_encryption_spec_service.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_encryption_spec_service.py @@ -1931,6 +1931,7 @@ def test_get_encryption_spec_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_encryption_spec(request) @@ -1976,6 +1977,7 @@ def test_get_encryption_spec_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_encryption_spec(**mock_args) @@ -2109,6 +2111,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) @@ -2156,6 +2159,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(**mock_args) @@ -2436,6 +2440,7 @@ def test_get_encryption_spec_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_encryption_spec(request) @@ -2472,6 +2477,7 @@ def test_get_encryption_spec_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_encryption_spec(request) # Establish that the response is the type that we expect. @@ -2513,6 +2519,7 @@ def test_get_encryption_spec_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 = encryption_spec.EncryptionSpec.to_json( encryption_spec.EncryptionSpec() ) @@ -2561,6 +2568,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) @@ -2593,6 +2601,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) # Establish that the response is the type that we expect. @@ -2636,6 +2645,7 @@ def test_initialize_encryption_spec_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -2680,6 +2690,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) @@ -2710,6 +2721,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) @@ -2738,6 +2750,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) @@ -2768,6 +2781,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) @@ -2798,6 +2812,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2828,6 +2843,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2858,6 +2874,7 @@ def test_get_operation_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.get_operation(request) @@ -2888,6 +2905,7 @@ def test_get_operation_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_operation(request) @@ -2916,6 +2934,7 @@ def test_list_operations_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_operations(request) @@ -2946,6 +2965,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_entity_types.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_entity_types.py index 781871041cee..6df134b39b3b 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_entity_types.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_entity_types.py @@ -4880,6 +4880,7 @@ def test_list_entity_types_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.list_entity_types(request) @@ -4935,6 +4936,7 @@ def test_list_entity_types_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_entity_types(**mock_args) @@ -5131,6 +5133,7 @@ def test_get_entity_type_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_entity_type(request) @@ -5177,6 +5180,7 @@ def test_get_entity_type_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_entity_type(**mock_args) @@ -5315,6 +5319,7 @@ def test_create_entity_type_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.create_entity_type(request) @@ -5370,6 +5375,7 @@ def test_create_entity_type_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_entity_type(**mock_args) @@ -5509,6 +5515,7 @@ def test_update_entity_type_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.update_entity_type(request) @@ -5565,6 +5572,7 @@ def test_update_entity_type_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_entity_type(**mock_args) @@ -5698,6 +5706,7 @@ def test_delete_entity_type_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.delete_entity_type(request) @@ -5741,6 +5750,7 @@ def test_delete_entity_type_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_entity_type(**mock_args) @@ -5878,6 +5888,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) @@ -6008,6 +6019,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) @@ -6060,6 +6072,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(**mock_args) @@ -6199,6 +6212,7 @@ def test_batch_create_entities_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.batch_create_entities(request) @@ -6252,6 +6266,7 @@ def test_batch_create_entities_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.batch_create_entities(**mock_args) @@ -6392,6 +6407,7 @@ def test_batch_update_entities_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.batch_update_entities(request) @@ -6445,6 +6461,7 @@ def test_batch_update_entities_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.batch_update_entities(**mock_args) @@ -6589,6 +6606,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) @@ -6642,6 +6660,7 @@ def test_batch_delete_entities_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.batch_delete_entities(**mock_args) @@ -7335,6 +7354,7 @@ def test_list_entity_types_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.list_entity_types(request) @@ -7370,6 +7390,7 @@ def test_list_entity_types_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_entity_types(request) # Establish that the response is the type that we expect. @@ -7410,6 +7431,7 @@ def test_list_entity_types_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 = entity_type.ListEntityTypesResponse.to_json( entity_type.ListEntityTypesResponse() ) @@ -7456,6 +7478,7 @@ def test_get_entity_type_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_entity_type(request) @@ -7495,6 +7518,7 @@ def test_get_entity_type_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_entity_type(request) # Establish that the response is the type that we expect. @@ -7542,6 +7566,7 @@ def test_get_entity_type_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 = entity_type.EntityType.to_json(entity_type.EntityType()) req.return_value.content = return_value @@ -7586,6 +7611,7 @@ def test_create_entity_type_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.create_entity_type(request) @@ -7702,6 +7728,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_entity_type(request) # Establish that the response is the type that we expect. @@ -7749,6 +7776,7 @@ def test_create_entity_type_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 = gcd_entity_type.EntityType.to_json(gcd_entity_type.EntityType()) req.return_value.content = return_value @@ -7795,6 +7823,7 @@ def test_update_entity_type_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.update_entity_type(request) @@ -7913,6 +7942,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_entity_type(request) # Establish that the response is the type that we expect. @@ -7960,6 +7990,7 @@ def test_update_entity_type_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 = gcd_entity_type.EntityType.to_json(gcd_entity_type.EntityType()) req.return_value.content = return_value @@ -8004,6 +8035,7 @@ def test_delete_entity_type_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.delete_entity_type(request) @@ -8034,6 +8066,7 @@ def test_delete_entity_type_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_entity_type(request) # Establish that the response is the type that we expect. @@ -8070,6 +8103,7 @@ def test_delete_entity_type_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 = entity_type.DeleteEntityTypeRequest() metadata = [ @@ -8110,6 +8144,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) @@ -8140,6 +8175,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) # Establish that the response is the type that we expect. @@ -8181,6 +8217,7 @@ def test_batch_update_entity_types_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8225,6 +8262,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) @@ -8255,6 +8293,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) # Establish that the response is the type that we expect. @@ -8296,6 +8335,7 @@ def test_batch_delete_entity_types_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8340,6 +8380,7 @@ def test_batch_create_entities_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.batch_create_entities(request) @@ -8370,6 +8411,7 @@ def test_batch_create_entities_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.batch_create_entities(request) # Establish that the response is the type that we expect. @@ -8411,6 +8453,7 @@ def test_batch_create_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8455,6 +8498,7 @@ def test_batch_update_entities_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.batch_update_entities(request) @@ -8485,6 +8529,7 @@ def test_batch_update_entities_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.batch_update_entities(request) # Establish that the response is the type that we expect. @@ -8526,6 +8571,7 @@ def test_batch_update_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8570,6 +8616,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) @@ -8600,6 +8647,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) # Establish that the response is the type that we expect. @@ -8641,6 +8689,7 @@ def test_batch_delete_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8685,6 +8734,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) @@ -8715,6 +8765,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) @@ -8743,6 +8794,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) @@ -8773,6 +8825,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) @@ -8803,6 +8856,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8833,6 +8887,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8863,6 +8918,7 @@ def test_get_operation_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.get_operation(request) @@ -8893,6 +8949,7 @@ def test_get_operation_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_operation(request) @@ -8921,6 +8978,7 @@ def test_list_operations_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_operations(request) @@ -8951,6 +9009,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_environments.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_environments.py index f5675008c666..e216c11e0feb 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_environments.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_environments.py @@ -3195,6 +3195,7 @@ def test_list_environments_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.list_environments(request) @@ -3248,6 +3249,7 @@ def test_list_environments_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_environments(**mock_args) @@ -3441,6 +3443,7 @@ def test_get_environment_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_environment(request) @@ -3574,6 +3577,7 @@ def test_create_environment_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.create_environment(request) @@ -3715,6 +3719,7 @@ def test_update_environment_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.update_environment(request) @@ -3848,6 +3853,7 @@ def test_delete_environment_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.delete_environment(request) @@ -3979,6 +3985,7 @@ def test_get_environment_history_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_environment_history(request) @@ -4527,6 +4534,7 @@ def test_list_environments_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.list_environments(request) @@ -4562,6 +4570,7 @@ def test_list_environments_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_environments(request) # Establish that the response is the type that we expect. @@ -4602,6 +4611,7 @@ def test_list_environments_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 = environment.ListEnvironmentsResponse.to_json( environment.ListEnvironmentsResponse() ) @@ -4648,6 +4658,7 @@ def test_get_environment_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_environment(request) @@ -4686,6 +4697,7 @@ def test_get_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -4729,6 +4741,7 @@ def test_get_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -4773,6 +4786,7 @@ def test_create_environment_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.create_environment(request) @@ -4904,6 +4918,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_environment(request) # Establish that the response is the type that we expect. @@ -4947,6 +4962,7 @@ def test_create_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -4993,6 +5009,7 @@ def test_update_environment_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.update_environment(request) @@ -5126,6 +5143,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_environment(request) # Establish that the response is the type that we expect. @@ -5169,6 +5187,7 @@ def test_update_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -5213,6 +5232,7 @@ def test_delete_environment_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.delete_environment(request) @@ -5243,6 +5263,7 @@ def test_delete_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -5279,6 +5300,7 @@ def test_delete_environment_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 = environment.DeleteEnvironmentRequest() metadata = [ @@ -5319,6 +5341,7 @@ def test_get_environment_history_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_environment_history(request) @@ -5355,6 +5378,7 @@ def test_get_environment_history_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_environment_history(request) # Establish that the response is the type that we expect. @@ -5396,6 +5420,7 @@ def test_get_environment_history_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 = environment.EnvironmentHistory.to_json( environment.EnvironmentHistory() ) @@ -5442,6 +5467,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) @@ -5472,6 +5498,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) @@ -5500,6 +5527,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) @@ -5530,6 +5558,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) @@ -5560,6 +5589,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5590,6 +5620,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5620,6 +5651,7 @@ def test_get_operation_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.get_operation(request) @@ -5650,6 +5682,7 @@ def test_get_operation_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_operation(request) @@ -5678,6 +5711,7 @@ def test_list_operations_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_operations(request) @@ -5708,6 +5742,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_fulfillments.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_fulfillments.py index 62996146b254..a832ae550c6d 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_fulfillments.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_fulfillments.py @@ -1832,6 +1832,7 @@ def test_get_fulfillment_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_fulfillment(request) @@ -1877,6 +1878,7 @@ def test_get_fulfillment_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_fulfillment(**mock_args) @@ -2009,6 +2011,7 @@ def test_update_fulfillment_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.update_fulfillment(request) @@ -2063,6 +2066,7 @@ def test_update_fulfillment_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_fulfillment(**mock_args) @@ -2345,6 +2349,7 @@ def test_get_fulfillment_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_fulfillment(request) @@ -2382,6 +2387,7 @@ def test_get_fulfillment_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_fulfillment(request) # Establish that the response is the type that we expect. @@ -2424,6 +2430,7 @@ def test_get_fulfillment_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 = fulfillment.Fulfillment.to_json(fulfillment.Fulfillment()) req.return_value.content = return_value @@ -2468,6 +2475,7 @@ def test_update_fulfillment_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.update_fulfillment(request) @@ -2585,6 +2593,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_fulfillment(request) # Establish that the response is the type that we expect. @@ -2627,6 +2636,7 @@ def test_update_fulfillment_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 = gcd_fulfillment.Fulfillment.to_json( gcd_fulfillment.Fulfillment() ) @@ -2673,6 +2683,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) @@ -2703,6 +2714,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) @@ -2731,6 +2743,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) @@ -2761,6 +2774,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) @@ -2791,6 +2805,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2821,6 +2836,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2851,6 +2867,7 @@ def test_get_operation_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.get_operation(request) @@ -2881,6 +2898,7 @@ def test_get_operation_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_operation(request) @@ -2909,6 +2927,7 @@ def test_list_operations_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_operations(request) @@ -2939,6 +2958,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_generators.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_generators.py index 4f31d0cd1d14..68784c7734cf 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_generators.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_generators.py @@ -2987,6 +2987,7 @@ def test_create_generator_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.create_generator(request) @@ -3042,6 +3043,7 @@ def test_create_generator_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_generator(**mock_args) @@ -3172,6 +3174,7 @@ def test_get_generator_rest_required_fields(request_type=generator.GetGeneratorR 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_generator(request) @@ -3219,6 +3222,7 @@ def test_get_generator_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_generator(**mock_args) @@ -3356,6 +3360,7 @@ def test_list_generators_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.list_generators(request) @@ -3409,6 +3414,7 @@ def test_list_generators_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_generators(**mock_args) @@ -3599,6 +3605,7 @@ def test_delete_generator_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.delete_generator(request) @@ -3644,6 +3651,7 @@ def test_delete_generator_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_generator(**mock_args) @@ -3774,6 +3782,7 @@ def test_update_generator_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.update_generator(request) @@ -3824,6 +3833,7 @@ def test_update_generator_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_generator(**mock_args) @@ -4244,6 +4254,7 @@ def test_create_generator_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.create_generator(request) @@ -4391,6 +4402,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_generator(request) # Establish that the response is the type that we expect. @@ -4433,6 +4445,7 @@ def test_create_generator_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 = gcd_generator.Generator.to_json(gcd_generator.Generator()) req.return_value.content = return_value @@ -4475,6 +4488,7 @@ def test_get_generator_rest_bad_request(request_type=generator.GetGeneratorReque 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_generator(request) @@ -4512,6 +4526,7 @@ def test_get_generator_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_generator(request) # Establish that the response is the type that we expect. @@ -4552,6 +4567,7 @@ def test_get_generator_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 = generator.Generator.to_json(generator.Generator()) req.return_value.content = return_value @@ -4594,6 +4610,7 @@ def test_list_generators_rest_bad_request(request_type=generator.ListGeneratorsR 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_generators(request) @@ -4629,6 +4646,7 @@ def test_list_generators_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_generators(request) # Establish that the response is the type that we expect. @@ -4669,6 +4687,7 @@ def test_list_generators_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 = generator.ListGeneratorsResponse.to_json( generator.ListGeneratorsResponse() ) @@ -4715,6 +4734,7 @@ def test_delete_generator_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.delete_generator(request) @@ -4745,6 +4765,7 @@ def test_delete_generator_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_generator(request) # Establish that the response is the type that we expect. @@ -4781,6 +4802,7 @@ def test_delete_generator_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 = generator.DeleteGeneratorRequest() metadata = [ @@ -4823,6 +4845,7 @@ def test_update_generator_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.update_generator(request) @@ -4972,6 +4995,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_generator(request) # Establish that the response is the type that we expect. @@ -5014,6 +5038,7 @@ def test_update_generator_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 = gcd_generator.Generator.to_json(gcd_generator.Generator()) req.return_value.content = return_value @@ -5058,6 +5083,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) @@ -5088,6 +5114,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) @@ -5116,6 +5143,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) @@ -5146,6 +5174,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) @@ -5176,6 +5205,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5206,6 +5236,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5236,6 +5267,7 @@ def test_get_operation_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.get_operation(request) @@ -5266,6 +5298,7 @@ def test_get_operation_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_operation(request) @@ -5294,6 +5327,7 @@ def test_list_operations_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_operations(request) @@ -5324,6 +5358,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_intents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_intents.py index 92f9e4e9b94c..c48b0af2484d 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_intents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_intents.py @@ -3890,6 +3890,7 @@ def test_list_intents_rest_required_fields(request_type=intent.ListIntentsReques 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_intents(request) @@ -3946,6 +3947,7 @@ def test_list_intents_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_intents(**mock_args) @@ -4142,6 +4144,7 @@ def test_get_intent_rest_required_fields(request_type=intent.GetIntentRequest): 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_intent(request) @@ -4196,6 +4199,7 @@ def test_get_intent_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_intent(**mock_args) @@ -4334,6 +4338,7 @@ def test_create_intent_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.create_intent(request) @@ -4394,6 +4399,7 @@ def test_create_intent_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_intent(**mock_args) @@ -4529,6 +4535,7 @@ def test_update_intent_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.update_intent(request) @@ -4585,6 +4592,7 @@ def test_update_intent_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_intent(**mock_args) @@ -4712,6 +4720,7 @@ def test_delete_intent_rest_required_fields(request_type=intent.DeleteIntentRequ 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_intent(request) @@ -4755,6 +4764,7 @@ def test_delete_intent_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_intent(**mock_args) @@ -4890,6 +4900,7 @@ def test_batch_update_intents_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.batch_update_intents(request) @@ -4933,6 +4944,7 @@ def test_batch_update_intents_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.batch_update_intents(**mock_args) @@ -5074,6 +5086,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) @@ -5126,6 +5139,7 @@ def test_batch_delete_intents_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.batch_delete_intents(**mock_args) @@ -5684,6 +5698,7 @@ def test_list_intents_rest_bad_request(request_type=intent.ListIntentsRequest): 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_intents(request) @@ -5719,6 +5734,7 @@ def test_list_intents_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_intents(request) # Establish that the response is the type that we expect. @@ -5755,6 +5771,7 @@ def test_list_intents_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 = intent.ListIntentsResponse.to_json(intent.ListIntentsResponse()) req.return_value.content = return_value @@ -5797,6 +5814,7 @@ def test_get_intent_rest_bad_request(request_type=intent.GetIntentRequest): 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_intent(request) @@ -5846,6 +5864,7 @@ def test_get_intent_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_intent(request) # Establish that the response is the type that we expect. @@ -5898,6 +5917,7 @@ def test_get_intent_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 = intent.Intent.to_json(intent.Intent()) req.return_value.content = return_value @@ -5940,6 +5960,7 @@ def test_create_intent_rest_bad_request(request_type=gcd_intent.CreateIntentRequ 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_intent(request) @@ -6220,6 +6241,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_intent(request) # Establish that the response is the type that we expect. @@ -6274,6 +6296,7 @@ def test_create_intent_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 = gcd_intent.Intent.to_json(gcd_intent.Intent()) req.return_value.content = return_value @@ -6316,6 +6339,7 @@ def test_update_intent_rest_bad_request(request_type=gcd_intent.UpdateIntentRequ 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_intent(request) @@ -6596,6 +6620,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_intent(request) # Establish that the response is the type that we expect. @@ -6650,6 +6675,7 @@ def test_update_intent_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 = gcd_intent.Intent.to_json(gcd_intent.Intent()) req.return_value.content = return_value @@ -6692,6 +6718,7 @@ def test_delete_intent_rest_bad_request(request_type=intent.DeleteIntentRequest) 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_intent(request) @@ -6722,6 +6749,7 @@ def test_delete_intent_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_intent(request) # Establish that the response is the type that we expect. @@ -6754,6 +6782,7 @@ def test_delete_intent_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 = intent.DeleteIntentRequest() metadata = [ @@ -6794,6 +6823,7 @@ def test_batch_update_intents_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.batch_update_intents(request) @@ -6824,6 +6854,7 @@ def test_batch_update_intents_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.batch_update_intents(request) # Establish that the response is the type that we expect. @@ -6863,6 +6894,7 @@ def test_batch_update_intents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6907,6 +6939,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) @@ -6937,6 +6970,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) # Establish that the response is the type that we expect. @@ -6976,6 +7010,7 @@ def test_batch_delete_intents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7020,6 +7055,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) @@ -7050,6 +7086,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) @@ -7078,6 +7115,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) @@ -7108,6 +7146,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) @@ -7138,6 +7177,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7168,6 +7208,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7198,6 +7239,7 @@ def test_get_operation_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.get_operation(request) @@ -7228,6 +7270,7 @@ def test_get_operation_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_operation(request) @@ -7256,6 +7299,7 @@ def test_list_operations_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_operations(request) @@ -7286,6 +7330,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py index 8c17c9f38c32..22b2c7ff9475 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py @@ -3127,6 +3127,7 @@ def test_list_knowledge_bases_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.list_knowledge_bases(request) @@ -3181,6 +3182,7 @@ def test_list_knowledge_bases_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_knowledge_bases(**mock_args) @@ -3377,6 +3379,7 @@ def test_get_knowledge_base_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_knowledge_base(request) @@ -3422,6 +3425,7 @@ def test_get_knowledge_base_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_knowledge_base(**mock_args) @@ -3557,6 +3561,7 @@ def test_create_knowledge_base_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.create_knowledge_base(request) @@ -3611,6 +3616,7 @@ def test_create_knowledge_base_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_knowledge_base(**mock_args) @@ -3745,6 +3751,7 @@ def test_delete_knowledge_base_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.delete_knowledge_base(request) @@ -3788,6 +3795,7 @@ def test_delete_knowledge_base_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_knowledge_base(**mock_args) @@ -3920,6 +3928,7 @@ def test_update_knowledge_base_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.update_knowledge_base(request) @@ -3968,6 +3977,7 @@ def test_update_knowledge_base_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_knowledge_base(**mock_args) @@ -4408,6 +4418,7 @@ def test_list_knowledge_bases_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.list_knowledge_bases(request) @@ -4443,6 +4454,7 @@ def test_list_knowledge_bases_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_knowledge_bases(request) # Establish that the response is the type that we expect. @@ -4483,6 +4495,7 @@ def test_list_knowledge_bases_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 = knowledge_base.ListKnowledgeBasesResponse.to_json( knowledge_base.ListKnowledgeBasesResponse() ) @@ -4529,6 +4542,7 @@ def test_get_knowledge_base_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_knowledge_base(request) @@ -4566,6 +4580,7 @@ def test_get_knowledge_base_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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4608,6 +4623,7 @@ def test_get_knowledge_base_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 = knowledge_base.KnowledgeBase.to_json( knowledge_base.KnowledgeBase() ) @@ -4654,6 +4670,7 @@ def test_create_knowledge_base_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.create_knowledge_base(request) @@ -4765,6 +4782,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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4807,6 +4825,7 @@ def test_create_knowledge_base_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 = gcd_knowledge_base.KnowledgeBase.to_json( gcd_knowledge_base.KnowledgeBase() ) @@ -4853,6 +4872,7 @@ def test_delete_knowledge_base_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.delete_knowledge_base(request) @@ -4883,6 +4903,7 @@ def test_delete_knowledge_base_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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4919,6 +4940,7 @@ def test_delete_knowledge_base_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 = knowledge_base.DeleteKnowledgeBaseRequest() metadata = [ @@ -4961,6 +4983,7 @@ def test_update_knowledge_base_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.update_knowledge_base(request) @@ -5074,6 +5097,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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -5116,6 +5140,7 @@ def test_update_knowledge_base_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 = gcd_knowledge_base.KnowledgeBase.to_json( gcd_knowledge_base.KnowledgeBase() ) @@ -5162,6 +5187,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) @@ -5192,6 +5218,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) @@ -5220,6 +5247,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) @@ -5250,6 +5278,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) @@ -5280,6 +5309,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5310,6 +5340,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5340,6 +5371,7 @@ def test_get_operation_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.get_operation(request) @@ -5370,6 +5402,7 @@ def test_get_operation_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_operation(request) @@ -5398,6 +5431,7 @@ def test_list_operations_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_operations(request) @@ -5428,6 +5462,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_participants.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_participants.py index 9aaea1875709..182d10d6f569 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_participants.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_participants.py @@ -4542,6 +4542,7 @@ def test_create_participant_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.create_participant(request) @@ -4596,6 +4597,7 @@ def test_create_participant_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_participant(**mock_args) @@ -4728,6 +4730,7 @@ def test_get_participant_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_participant(request) @@ -4775,6 +4778,7 @@ def test_get_participant_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_participant(**mock_args) @@ -4915,6 +4919,7 @@ def test_list_participants_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.list_participants(request) @@ -4968,6 +4973,7 @@ def test_list_participants_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_participants(**mock_args) @@ -5164,6 +5170,7 @@ def test_update_participant_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.update_participant(request) @@ -5222,6 +5229,7 @@ def test_update_participant_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_participant(**mock_args) @@ -5355,6 +5363,7 @@ def test_analyze_content_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.analyze_content(request) @@ -5402,6 +5411,7 @@ def test_analyze_content_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.analyze_content(**mock_args) @@ -5549,6 +5559,7 @@ def test_suggest_articles_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.suggest_articles(request) @@ -5596,6 +5607,7 @@ def test_suggest_articles_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.suggest_articles(**mock_args) @@ -5732,6 +5744,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) @@ -5779,6 +5792,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(**mock_args) @@ -5916,6 +5930,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) @@ -5963,6 +5978,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(**mock_args) @@ -6100,6 +6116,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) @@ -6747,6 +6764,7 @@ def test_create_participant_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.create_participant(request) @@ -6859,6 +6877,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_participant(request) # Establish that the response is the type that we expect. @@ -6902,6 +6921,7 @@ def test_create_participant_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 = gcd_participant.Participant.to_json( gcd_participant.Participant() ) @@ -6950,6 +6970,7 @@ def test_get_participant_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_participant(request) @@ -6990,6 +7011,7 @@ def test_get_participant_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_participant(request) # Establish that the response is the type that we expect. @@ -7033,6 +7055,7 @@ def test_get_participant_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 = participant.Participant.to_json(participant.Participant()) req.return_value.content = return_value @@ -7077,6 +7100,7 @@ def test_list_participants_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.list_participants(request) @@ -7112,6 +7136,7 @@ def test_list_participants_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_participants(request) # Establish that the response is the type that we expect. @@ -7152,6 +7177,7 @@ def test_list_participants_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 = participant.ListParticipantsResponse.to_json( participant.ListParticipantsResponse() ) @@ -7202,6 +7228,7 @@ def test_update_participant_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.update_participant(request) @@ -7318,6 +7345,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_participant(request) # Establish that the response is the type that we expect. @@ -7361,6 +7389,7 @@ def test_update_participant_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 = gcd_participant.Participant.to_json( gcd_participant.Participant() ) @@ -7409,6 +7438,7 @@ def test_analyze_content_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.analyze_content(request) @@ -7446,6 +7476,7 @@ def test_analyze_content_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.analyze_content(request) # Establish that the response is the type that we expect. @@ -7486,6 +7517,7 @@ def test_analyze_content_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 = gcd_participant.AnalyzeContentResponse.to_json( gcd_participant.AnalyzeContentResponse() ) @@ -7546,6 +7578,7 @@ def test_suggest_articles_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.suggest_articles(request) @@ -7584,6 +7617,7 @@ def test_suggest_articles_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.suggest_articles(request) # Establish that the response is the type that we expect. @@ -7625,6 +7659,7 @@ def test_suggest_articles_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 = participant.SuggestArticlesResponse.to_json( participant.SuggestArticlesResponse() ) @@ -7673,6 +7708,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) @@ -7711,6 +7747,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) # Establish that the response is the type that we expect. @@ -7752,6 +7789,7 @@ def test_suggest_faq_answers_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 = participant.SuggestFaqAnswersResponse.to_json( participant.SuggestFaqAnswersResponse() ) @@ -7800,6 +7838,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) @@ -7838,6 +7877,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) # Establish that the response is the type that we expect. @@ -7879,6 +7919,7 @@ def test_suggest_smart_replies_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 = participant.SuggestSmartRepliesResponse.to_json( participant.SuggestSmartRepliesResponse() ) @@ -7927,6 +7968,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) @@ -7965,6 +8007,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) # Establish that the response is the type that we expect. @@ -8006,6 +8049,7 @@ def test_suggest_knowledge_assist_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 = participant.SuggestKnowledgeAssistResponse.to_json( participant.SuggestKnowledgeAssistResponse() ) @@ -8052,6 +8096,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) @@ -8082,6 +8127,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) @@ -8110,6 +8156,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) @@ -8140,6 +8187,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) @@ -8170,6 +8218,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8200,6 +8249,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8230,6 +8280,7 @@ def test_get_operation_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.get_operation(request) @@ -8260,6 +8311,7 @@ def test_get_operation_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_operation(request) @@ -8288,6 +8340,7 @@ def test_list_operations_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_operations(request) @@ -8318,6 +8371,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py index 2d2f36b11efc..e7f5d4f4c89b 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py @@ -3203,6 +3203,7 @@ def test_list_session_entity_types_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.list_session_entity_types(request) @@ -3258,6 +3259,7 @@ def test_list_session_entity_types_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_session_entity_types(**mock_args) @@ -3460,6 +3462,7 @@ def test_get_session_entity_type_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_session_entity_type(request) @@ -3507,6 +3510,7 @@ def test_get_session_entity_type_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_session_entity_type(**mock_args) @@ -3644,6 +3648,7 @@ def test_create_session_entity_type_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.create_session_entity_type(request) @@ -3700,6 +3705,7 @@ def test_create_session_entity_type_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_session_entity_type(**mock_args) @@ -3837,6 +3843,7 @@ def test_update_session_entity_type_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.update_session_entity_type(request) @@ -3889,6 +3896,7 @@ def test_update_session_entity_type_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_session_entity_type(**mock_args) @@ -4025,6 +4033,7 @@ def test_delete_session_entity_type_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.delete_session_entity_type(request) @@ -4070,6 +4079,7 @@ def test_delete_session_entity_type_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_session_entity_type(**mock_args) @@ -4506,6 +4516,7 @@ def test_list_session_entity_types_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.list_session_entity_types(request) @@ -4543,6 +4554,7 @@ def test_list_session_entity_types_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_session_entity_types(request) # Establish that the response is the type that we expect. @@ -4583,6 +4595,7 @@ def test_list_session_entity_types_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 = session_entity_type.ListSessionEntityTypesResponse.to_json( session_entity_type.ListSessionEntityTypesResponse() ) @@ -4631,6 +4644,7 @@ def test_get_session_entity_type_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_session_entity_type(request) @@ -4669,6 +4683,7 @@ def test_get_session_entity_type_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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -4713,6 +4728,7 @@ def test_get_session_entity_type_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 = session_entity_type.SessionEntityType.to_json( session_entity_type.SessionEntityType() ) @@ -4759,6 +4775,7 @@ def test_create_session_entity_type_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.create_session_entity_type(request) @@ -4871,6 +4888,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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -4915,6 +4933,7 @@ def test_create_session_entity_type_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 = gcd_session_entity_type.SessionEntityType.to_json( gcd_session_entity_type.SessionEntityType() ) @@ -4965,6 +4984,7 @@ def test_update_session_entity_type_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.update_session_entity_type(request) @@ -5081,6 +5101,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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -5125,6 +5146,7 @@ def test_update_session_entity_type_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 = gcd_session_entity_type.SessionEntityType.to_json( gcd_session_entity_type.SessionEntityType() ) @@ -5173,6 +5195,7 @@ def test_delete_session_entity_type_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.delete_session_entity_type(request) @@ -5205,6 +5228,7 @@ def test_delete_session_entity_type_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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -5241,6 +5265,7 @@ def test_delete_session_entity_type_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 = session_entity_type.DeleteSessionEntityTypeRequest() metadata = [ @@ -5281,6 +5306,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) @@ -5311,6 +5337,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) @@ -5339,6 +5366,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) @@ -5369,6 +5397,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) @@ -5399,6 +5428,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5429,6 +5459,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5459,6 +5490,7 @@ def test_get_operation_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.get_operation(request) @@ -5489,6 +5521,7 @@ def test_get_operation_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_operation(request) @@ -5517,6 +5550,7 @@ def test_list_operations_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_operations(request) @@ -5547,6 +5581,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_sessions.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_sessions.py index 7d2241dd43de..abe9ecdfd3a0 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_sessions.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_sessions.py @@ -1637,6 +1637,7 @@ def test_detect_intent_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.detect_intent(request) @@ -1695,6 +1696,7 @@ def test_detect_intent_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.detect_intent(**mock_args) @@ -1948,6 +1950,7 @@ def test_detect_intent_rest_bad_request(request_type=gcd_session.DetectIntentReq 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.detect_intent(request) @@ -1984,6 +1987,7 @@ def test_detect_intent_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.detect_intent(request) # Establish that the response is the type that we expect. @@ -2023,6 +2027,7 @@ def test_detect_intent_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 = gcd_session.DetectIntentResponse.to_json( gcd_session.DetectIntentResponse() ) @@ -2081,6 +2086,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) @@ -2111,6 +2117,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) @@ -2139,6 +2146,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) @@ -2169,6 +2177,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) @@ -2199,6 +2208,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2229,6 +2239,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2259,6 +2270,7 @@ def test_get_operation_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.get_operation(request) @@ -2289,6 +2301,7 @@ def test_get_operation_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_operation(request) @@ -2317,6 +2330,7 @@ def test_list_operations_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_operations(request) @@ -2347,6 +2361,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_versions.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_versions.py index 82624a0aaa4f..ad52cbe58c78 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_versions.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2/test_versions.py @@ -2958,6 +2958,7 @@ def test_list_versions_rest_required_fields(request_type=version.ListVersionsReq 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_versions(request) @@ -3011,6 +3012,7 @@ def test_list_versions_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_versions(**mock_args) @@ -3199,6 +3201,7 @@ def test_get_version_rest_required_fields(request_type=version.GetVersionRequest 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_version(request) @@ -3244,6 +3247,7 @@ def test_get_version_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_version(**mock_args) @@ -3374,6 +3378,7 @@ def test_create_version_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.create_version(request) @@ -3428,6 +3433,7 @@ def test_create_version_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_version(**mock_args) @@ -3556,6 +3562,7 @@ def test_update_version_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.update_version(request) @@ -3612,6 +3619,7 @@ def test_update_version_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_version(**mock_args) @@ -3738,6 +3746,7 @@ def test_delete_version_rest_required_fields(request_type=version.DeleteVersionR 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_version(request) @@ -3781,6 +3790,7 @@ def test_delete_version_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_version(**mock_args) @@ -4199,6 +4209,7 @@ def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest 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_versions(request) @@ -4234,6 +4245,7 @@ def test_list_versions_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_versions(request) # Establish that the response is the type that we expect. @@ -4270,6 +4282,7 @@ def test_list_versions_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 = version.ListVersionsResponse.to_json( version.ListVersionsResponse() ) @@ -4314,6 +4327,7 @@ def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): 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_version(request) @@ -4352,6 +4366,7 @@ def test_get_version_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_version(request) # Establish that the response is the type that we expect. @@ -4391,6 +4406,7 @@ def test_get_version_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 = version.Version.to_json(version.Version()) req.return_value.content = return_value @@ -4433,6 +4449,7 @@ def test_create_version_rest_bad_request(request_type=gcd_version.CreateVersionR 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_version(request) @@ -4545,6 +4562,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_version(request) # Establish that the response is the type that we expect. @@ -4586,6 +4604,7 @@ def test_create_version_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 = gcd_version.Version.to_json(gcd_version.Version()) req.return_value.content = return_value @@ -4628,6 +4647,7 @@ def test_update_version_rest_bad_request(request_type=gcd_version.UpdateVersionR 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_version(request) @@ -4740,6 +4760,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_version(request) # Establish that the response is the type that we expect. @@ -4781,6 +4802,7 @@ def test_update_version_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 = gcd_version.Version.to_json(gcd_version.Version()) req.return_value.content = return_value @@ -4823,6 +4845,7 @@ def test_delete_version_rest_bad_request(request_type=version.DeleteVersionReque 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_version(request) @@ -4853,6 +4876,7 @@ def test_delete_version_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_version(request) # Establish that the response is the type that we expect. @@ -4885,6 +4909,7 @@ def test_delete_version_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 = version.DeleteVersionRequest() metadata = [ @@ -4925,6 +4950,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) @@ -4955,6 +4981,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) @@ -4983,6 +5010,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) @@ -5013,6 +5041,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) @@ -5043,6 +5072,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5073,6 +5103,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5103,6 +5134,7 @@ def test_get_operation_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.get_operation(request) @@ -5133,6 +5165,7 @@ def test_get_operation_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_operation(request) @@ -5161,6 +5194,7 @@ def test_list_operations_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_operations(request) @@ -5191,6 +5225,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_agents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_agents.py index 3ad934c3917b..53f89bf61cbd 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_agents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_agents.py @@ -4069,6 +4069,7 @@ def test_get_agent_rest_required_fields(request_type=agent.GetAgentRequest): 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_agent(request) @@ -4114,6 +4115,7 @@ def test_get_agent_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_agent(**mock_args) @@ -4239,6 +4241,7 @@ def test_set_agent_rest_required_fields(request_type=gcd_agent.SetAgentRequest): 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_agent(request) @@ -4284,6 +4287,7 @@ def test_set_agent_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_agent(**mock_args) @@ -4409,6 +4413,7 @@ def test_delete_agent_rest_required_fields(request_type=agent.DeleteAgentRequest 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_agent(request) @@ -4452,6 +4457,7 @@ def test_delete_agent_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_agent(**mock_args) @@ -4586,6 +4592,7 @@ def test_search_agents_rest_required_fields(request_type=agent.SearchAgentsReque 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.search_agents(request) @@ -4639,6 +4646,7 @@ def test_search_agents_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.search_agents(**mock_args) @@ -4830,6 +4838,7 @@ def test_train_agent_rest_required_fields(request_type=agent.TrainAgentRequest): 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.train_agent(request) @@ -4873,6 +4882,7 @@ def test_train_agent_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.train_agent(**mock_args) @@ -5003,6 +5013,7 @@ def test_export_agent_rest_required_fields(request_type=agent.ExportAgentRequest 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.export_agent(request) @@ -5046,6 +5057,7 @@ def test_export_agent_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.export_agent(**mock_args) @@ -5176,6 +5188,7 @@ def test_import_agent_rest_required_fields(request_type=agent.ImportAgentRequest 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.import_agent(request) @@ -5295,6 +5308,7 @@ def test_restore_agent_rest_required_fields(request_type=agent.RestoreAgentReque 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.restore_agent(request) @@ -5421,6 +5435,7 @@ def test_get_validation_result_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_validation_result(request) @@ -6028,6 +6043,7 @@ def test_get_agent_rest_bad_request(request_type=agent.GetAgentRequest): 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_agent(request) @@ -6074,6 +6090,7 @@ def test_get_agent_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_agent(request) # Establish that the response is the type that we expect. @@ -6123,6 +6140,7 @@ def test_get_agent_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 = agent.Agent.to_json(agent.Agent()) req.return_value.content = return_value @@ -6165,6 +6183,7 @@ def test_set_agent_rest_bad_request(request_type=gcd_agent.SetAgentRequest): 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_agent(request) @@ -6295,6 +6314,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.set_agent(request) # Establish that the response is the type that we expect. @@ -6344,6 +6364,7 @@ def test_set_agent_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 = gcd_agent.Agent.to_json(gcd_agent.Agent()) req.return_value.content = return_value @@ -6386,6 +6407,7 @@ def test_delete_agent_rest_bad_request(request_type=agent.DeleteAgentRequest): 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_agent(request) @@ -6416,6 +6438,7 @@ def test_delete_agent_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_agent(request) # Establish that the response is the type that we expect. @@ -6448,6 +6471,7 @@ def test_delete_agent_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 = agent.DeleteAgentRequest() metadata = [ @@ -6486,6 +6510,7 @@ def test_search_agents_rest_bad_request(request_type=agent.SearchAgentsRequest): 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.search_agents(request) @@ -6521,6 +6546,7 @@ def test_search_agents_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.search_agents(request) # Establish that the response is the type that we expect. @@ -6557,6 +6583,7 @@ def test_search_agents_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 = agent.SearchAgentsResponse.to_json(agent.SearchAgentsResponse()) req.return_value.content = return_value @@ -6599,6 +6626,7 @@ def test_train_agent_rest_bad_request(request_type=agent.TrainAgentRequest): 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.train_agent(request) @@ -6629,6 +6657,7 @@ def test_train_agent_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.train_agent(request) # Establish that the response is the type that we expect. @@ -6666,6 +6695,7 @@ def test_train_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6708,6 +6738,7 @@ def test_export_agent_rest_bad_request(request_type=agent.ExportAgentRequest): 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.export_agent(request) @@ -6738,6 +6769,7 @@ def test_export_agent_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.export_agent(request) # Establish that the response is the type that we expect. @@ -6775,6 +6807,7 @@ def test_export_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6817,6 +6850,7 @@ def test_import_agent_rest_bad_request(request_type=agent.ImportAgentRequest): 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.import_agent(request) @@ -6847,6 +6881,7 @@ def test_import_agent_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.import_agent(request) # Establish that the response is the type that we expect. @@ -6884,6 +6919,7 @@ def test_import_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6926,6 +6962,7 @@ def test_restore_agent_rest_bad_request(request_type=agent.RestoreAgentRequest): 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.restore_agent(request) @@ -6956,6 +6993,7 @@ def test_restore_agent_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.restore_agent(request) # Establish that the response is the type that we expect. @@ -6993,6 +7031,7 @@ def test_restore_agent_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7037,6 +7076,7 @@ def test_get_validation_result_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_validation_result(request) @@ -7070,6 +7110,7 @@ def test_get_validation_result_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_validation_result(request) # Establish that the response is the type that we expect. @@ -7107,6 +7148,7 @@ def test_get_validation_result_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 = validation_result.ValidationResult.to_json( validation_result.ValidationResult() ) @@ -7153,6 +7195,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) @@ -7183,6 +7226,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) @@ -7211,6 +7255,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) @@ -7241,6 +7286,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) @@ -7271,6 +7317,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7301,6 +7348,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7331,6 +7379,7 @@ def test_get_operation_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.get_operation(request) @@ -7361,6 +7410,7 @@ def test_get_operation_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_operation(request) @@ -7389,6 +7439,7 @@ def test_list_operations_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_operations(request) @@ -7419,6 +7470,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py index 83849ab89b49..361bc2e6d603 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py @@ -2320,6 +2320,7 @@ def test_list_answer_records_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_answer_records(**mock_args) @@ -2515,6 +2516,7 @@ def test_update_answer_record_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.update_answer_record(request) @@ -2563,6 +2565,7 @@ def test_update_answer_record_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_answer_record(**mock_args) @@ -2897,6 +2900,7 @@ def test_get_answer_record_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_answer_record(request) @@ -2932,6 +2936,7 @@ def test_get_answer_record_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_answer_record(request) # Establish that the response is the type that we expect. @@ -2972,6 +2977,7 @@ def test_get_answer_record_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 = answer_record.AnswerRecord.to_json(answer_record.AnswerRecord()) req.return_value.content = return_value @@ -3016,6 +3022,7 @@ def test_list_answer_records_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.list_answer_records(request) @@ -3051,6 +3058,7 @@ def test_list_answer_records_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_answer_records(request) # Establish that the response is the type that we expect. @@ -3091,6 +3099,7 @@ def test_list_answer_records_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 = answer_record.ListAnswerRecordsResponse.to_json( answer_record.ListAnswerRecordsResponse() ) @@ -3137,6 +3146,7 @@ def test_update_answer_record_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.update_answer_record(request) @@ -3556,6 +3566,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_answer_record(request) # Establish that the response is the type that we expect. @@ -3596,6 +3607,7 @@ def test_update_answer_record_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 = gcd_answer_record.AnswerRecord.to_json( gcd_answer_record.AnswerRecord() ) @@ -3642,6 +3654,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) @@ -3672,6 +3685,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) @@ -3700,6 +3714,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) @@ -3730,6 +3745,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) @@ -3760,6 +3776,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -3790,6 +3807,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -3820,6 +3838,7 @@ def test_get_operation_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.get_operation(request) @@ -3850,6 +3869,7 @@ def test_get_operation_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_operation(request) @@ -3878,6 +3898,7 @@ def test_list_operations_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_operations(request) @@ -3908,6 +3929,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py index b06d573b28f4..02852788f15c 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py @@ -3263,6 +3263,7 @@ def test_list_contexts_rest_required_fields(request_type=context.ListContextsReq 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_contexts(request) @@ -3316,6 +3317,7 @@ def test_list_contexts_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_contexts(**mock_args) @@ -3506,6 +3508,7 @@ def test_get_context_rest_required_fields(request_type=context.GetContextRequest 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_context(request) @@ -3553,6 +3556,7 @@ def test_get_context_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_context(**mock_args) @@ -3685,6 +3689,7 @@ def test_create_context_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.create_context(request) @@ -3739,6 +3744,7 @@ def test_create_context_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_context(**mock_args) @@ -3869,6 +3875,7 @@ def test_update_context_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.update_context(request) @@ -3919,6 +3926,7 @@ def test_update_context_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_context(**mock_args) @@ -4046,6 +4054,7 @@ def test_delete_context_rest_required_fields(request_type=context.DeleteContextR 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_context(request) @@ -4091,6 +4100,7 @@ def test_delete_context_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_context(**mock_args) @@ -4223,6 +4233,7 @@ def test_delete_all_contexts_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.delete_all_contexts(request) @@ -4266,6 +4277,7 @@ def test_delete_all_contexts_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_all_contexts(**mock_args) @@ -4728,6 +4740,7 @@ def test_list_contexts_rest_bad_request(request_type=context.ListContextsRequest 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_contexts(request) @@ -4763,6 +4776,7 @@ def test_list_contexts_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_contexts(request) # Establish that the response is the type that we expect. @@ -4799,6 +4813,7 @@ def test_list_contexts_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 = context.ListContextsResponse.to_json( context.ListContextsResponse() ) @@ -4843,6 +4858,7 @@ def test_get_context_rest_bad_request(request_type=context.GetContextRequest): 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_context(request) @@ -4879,6 +4895,7 @@ def test_get_context_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_context(request) # Establish that the response is the type that we expect. @@ -4916,6 +4933,7 @@ def test_get_context_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 = context.Context.to_json(context.Context()) req.return_value.content = return_value @@ -4958,6 +4976,7 @@ def test_create_context_rest_bad_request(request_type=gcd_context.CreateContextR 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_context(request) @@ -5066,6 +5085,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_context(request) # Establish that the response is the type that we expect. @@ -5105,6 +5125,7 @@ def test_create_context_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 = gcd_context.Context.to_json(gcd_context.Context()) req.return_value.content = return_value @@ -5149,6 +5170,7 @@ def test_update_context_rest_bad_request(request_type=gcd_context.UpdateContextR 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_context(request) @@ -5259,6 +5281,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_context(request) # Establish that the response is the type that we expect. @@ -5298,6 +5321,7 @@ def test_update_context_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 = gcd_context.Context.to_json(gcd_context.Context()) req.return_value.content = return_value @@ -5340,6 +5364,7 @@ def test_delete_context_rest_bad_request(request_type=context.DeleteContextReque 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_context(request) @@ -5370,6 +5395,7 @@ def test_delete_context_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_context(request) # Establish that the response is the type that we expect. @@ -5402,6 +5428,7 @@ def test_delete_context_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 = context.DeleteContextRequest() metadata = [ @@ -5442,6 +5469,7 @@ def test_delete_all_contexts_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.delete_all_contexts(request) @@ -5472,6 +5500,7 @@ def test_delete_all_contexts_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_all_contexts(request) # Establish that the response is the type that we expect. @@ -5506,6 +5535,7 @@ def test_delete_all_contexts_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 = context.DeleteAllContextsRequest() metadata = [ @@ -5546,6 +5576,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) @@ -5576,6 +5607,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) @@ -5604,6 +5636,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) @@ -5634,6 +5667,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) @@ -5664,6 +5698,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5694,6 +5729,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5724,6 +5760,7 @@ def test_get_operation_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.get_operation(request) @@ -5754,6 +5791,7 @@ def test_get_operation_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_operation(request) @@ -5782,6 +5820,7 @@ def test_list_operations_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_operations(request) @@ -5812,6 +5851,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py index 116b74b85c1d..82bde4e771fb 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py @@ -4013,6 +4013,7 @@ def test_list_conversation_profiles_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.list_conversation_profiles(request) @@ -4068,6 +4069,7 @@ def test_list_conversation_profiles_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_conversation_profiles(**mock_args) @@ -4270,6 +4272,7 @@ def test_get_conversation_profile_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_conversation_profile(request) @@ -4315,6 +4318,7 @@ def test_get_conversation_profile_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_conversation_profile(**mock_args) @@ -4452,6 +4456,7 @@ def test_create_conversation_profile_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.create_conversation_profile(request) @@ -4508,6 +4513,7 @@ def test_create_conversation_profile_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_conversation_profile(**mock_args) @@ -4645,6 +4651,7 @@ def test_update_conversation_profile_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.update_conversation_profile(request) @@ -4705,6 +4712,7 @@ def test_update_conversation_profile_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_conversation_profile(**mock_args) @@ -4841,6 +4849,7 @@ def test_delete_conversation_profile_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.delete_conversation_profile(request) @@ -4884,6 +4893,7 @@ def test_delete_conversation_profile_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_conversation_profile(**mock_args) @@ -5022,6 +5032,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) @@ -5084,6 +5095,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(**mock_args) @@ -5228,6 +5240,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) @@ -5286,6 +5299,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(**mock_args) @@ -5833,6 +5847,7 @@ def test_list_conversation_profiles_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.list_conversation_profiles(request) @@ -5870,6 +5885,7 @@ def test_list_conversation_profiles_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_conversation_profiles(request) # Establish that the response is the type that we expect. @@ -5911,6 +5927,7 @@ def test_list_conversation_profiles_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 = conversation_profile.ListConversationProfilesResponse.to_json( conversation_profile.ListConversationProfilesResponse() ) @@ -5957,6 +5974,7 @@ def test_get_conversation_profile_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_conversation_profile(request) @@ -5996,6 +6014,7 @@ def test_get_conversation_profile_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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6040,6 +6059,7 @@ def test_get_conversation_profile_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 = conversation_profile.ConversationProfile.to_json( conversation_profile.ConversationProfile() ) @@ -6086,6 +6106,7 @@ def test_create_conversation_profile_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.create_conversation_profile(request) @@ -6297,6 +6318,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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6343,6 +6365,7 @@ def test_create_conversation_profile_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 = gcd_conversation_profile.ConversationProfile.to_json( gcd_conversation_profile.ConversationProfile() ) @@ -6393,6 +6416,7 @@ def test_update_conversation_profile_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.update_conversation_profile(request) @@ -6608,6 +6632,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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6654,6 +6679,7 @@ def test_update_conversation_profile_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 = gcd_conversation_profile.ConversationProfile.to_json( gcd_conversation_profile.ConversationProfile() ) @@ -6700,6 +6726,7 @@ def test_delete_conversation_profile_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.delete_conversation_profile(request) @@ -6730,6 +6757,7 @@ def test_delete_conversation_profile_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_conversation_profile(request) # Establish that the response is the type that we expect. @@ -6767,6 +6795,7 @@ def test_delete_conversation_profile_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 = conversation_profile.DeleteConversationProfileRequest() metadata = [ @@ -6809,6 +6838,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) @@ -6841,6 +6871,7 @@ def test_set_suggestion_feature_config_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_suggestion_feature_config(request) # Establish that the response is the type that we expect. @@ -6884,6 +6915,7 @@ def test_set_suggestion_feature_config_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6930,6 +6962,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) @@ -6962,6 +6995,7 @@ def test_clear_suggestion_feature_config_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.clear_suggestion_feature_config(request) # Establish that the response is the type that we expect. @@ -7005,6 +7039,7 @@ def test_clear_suggestion_feature_config_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7049,6 +7084,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) @@ -7079,6 +7115,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) @@ -7107,6 +7144,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) @@ -7137,6 +7175,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) @@ -7167,6 +7206,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7197,6 +7237,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7227,6 +7268,7 @@ def test_get_operation_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.get_operation(request) @@ -7257,6 +7299,7 @@ def test_get_operation_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_operation(request) @@ -7285,6 +7328,7 @@ def test_list_operations_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_operations(request) @@ -7315,6 +7359,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py index 2868f57dc901..ca787759610e 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py @@ -4800,6 +4800,7 @@ def test_create_conversation_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.create_conversation(request) @@ -4854,6 +4855,7 @@ def test_create_conversation_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_conversation(**mock_args) @@ -4997,6 +4999,7 @@ def test_list_conversations_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.list_conversations(request) @@ -5051,6 +5054,7 @@ def test_list_conversations_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_conversations(**mock_args) @@ -5246,6 +5250,7 @@ def test_get_conversation_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_conversation(request) @@ -5291,6 +5296,7 @@ def test_get_conversation_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_conversation(**mock_args) @@ -5427,6 +5433,7 @@ def test_complete_conversation_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.complete_conversation(request) @@ -5472,6 +5479,7 @@ def test_complete_conversation_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.complete_conversation(**mock_args) @@ -5609,6 +5617,7 @@ def test_batch_create_messages_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.batch_create_messages(request) @@ -5663,6 +5672,7 @@ def test_batch_create_messages_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.batch_create_messages(**mock_args) @@ -5803,6 +5813,7 @@ def test_list_messages_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.list_messages(request) @@ -5857,6 +5868,7 @@ def test_list_messages_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_messages(**mock_args) @@ -6057,6 +6069,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) @@ -6104,6 +6117,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(**mock_args) @@ -6238,6 +6252,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) @@ -6373,6 +6388,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) @@ -6505,6 +6521,7 @@ def test_search_knowledge_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.search_knowledge(request) @@ -7195,6 +7212,7 @@ def test_create_conversation_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.create_conversation(request) @@ -7309,6 +7327,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_conversation(request) # Establish that the response is the type that we expect. @@ -7358,6 +7377,7 @@ def test_create_conversation_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 = gcd_conversation.Conversation.to_json( gcd_conversation.Conversation() ) @@ -7404,6 +7424,7 @@ def test_list_conversations_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.list_conversations(request) @@ -7439,6 +7460,7 @@ def test_list_conversations_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_conversations(request) # Establish that the response is the type that we expect. @@ -7479,6 +7501,7 @@ def test_list_conversations_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 = conversation.ListConversationsResponse.to_json( conversation.ListConversationsResponse() ) @@ -7525,6 +7548,7 @@ def test_get_conversation_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_conversation(request) @@ -7563,6 +7587,7 @@ def test_get_conversation_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_conversation(request) # Establish that the response is the type that we expect. @@ -7611,6 +7636,7 @@ def test_get_conversation_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 = conversation.Conversation.to_json(conversation.Conversation()) req.return_value.content = return_value @@ -7655,6 +7681,7 @@ def test_complete_conversation_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.complete_conversation(request) @@ -7693,6 +7720,7 @@ def test_complete_conversation_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.complete_conversation(request) # Establish that the response is the type that we expect. @@ -7741,6 +7769,7 @@ def test_complete_conversation_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 = conversation.Conversation.to_json(conversation.Conversation()) req.return_value.content = return_value @@ -7785,6 +7814,7 @@ def test_batch_create_messages_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.batch_create_messages(request) @@ -7818,6 +7848,7 @@ def test_batch_create_messages_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.batch_create_messages(request) # Establish that the response is the type that we expect. @@ -7857,6 +7888,7 @@ def test_batch_create_messages_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 = conversation.BatchCreateMessagesResponse.to_json( conversation.BatchCreateMessagesResponse() ) @@ -7901,6 +7933,7 @@ def test_list_messages_rest_bad_request(request_type=conversation.ListMessagesRe 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_messages(request) @@ -7936,6 +7969,7 @@ def test_list_messages_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_messages(request) # Establish that the response is the type that we expect. @@ -7976,6 +8010,7 @@ def test_list_messages_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 = conversation.ListMessagesResponse.to_json( conversation.ListMessagesResponse() ) @@ -8022,6 +8057,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) @@ -8060,6 +8096,7 @@ def test_suggest_conversation_summary_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.suggest_conversation_summary(request) # Establish that the response is the type that we expect. @@ -8101,6 +8138,7 @@ def test_suggest_conversation_summary_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 = gcd_conversation.SuggestConversationSummaryResponse.to_json( gcd_conversation.SuggestConversationSummaryResponse() ) @@ -8147,6 +8185,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) @@ -8183,6 +8222,7 @@ def test_generate_stateless_summary_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.generate_stateless_summary(request) # Establish that the response is the type that we expect. @@ -8224,6 +8264,7 @@ def test_generate_stateless_summary_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 = conversation.GenerateStatelessSummaryResponse.to_json( conversation.GenerateStatelessSummaryResponse() ) @@ -8270,6 +8311,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) @@ -8303,6 +8345,7 @@ def test_generate_stateless_suggestion_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.generate_stateless_suggestion(request) # Establish that the response is the type that we expect. @@ -8342,6 +8385,7 @@ def test_generate_stateless_suggestion_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 = conversation.GenerateStatelessSuggestionResponse.to_json( conversation.GenerateStatelessSuggestionResponse() ) @@ -8388,6 +8432,7 @@ def test_search_knowledge_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.search_knowledge(request) @@ -8423,6 +8468,7 @@ def test_search_knowledge_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.search_knowledge(request) # Establish that the response is the type that we expect. @@ -8463,6 +8509,7 @@ def test_search_knowledge_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 = conversation.SearchKnowledgeResponse.to_json( conversation.SearchKnowledgeResponse() ) @@ -8509,6 +8556,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) @@ -8539,6 +8587,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) @@ -8567,6 +8616,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) @@ -8597,6 +8647,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) @@ -8627,6 +8678,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8657,6 +8709,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8687,6 +8740,7 @@ def test_get_operation_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.get_operation(request) @@ -8717,6 +8771,7 @@ def test_get_operation_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_operation(request) @@ -8745,6 +8800,7 @@ def test_list_operations_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_operations(request) @@ -8775,6 +8831,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_documents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_documents.py index 9dd9f82cc9c4..7e78424a9571 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_documents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_documents.py @@ -3584,6 +3584,7 @@ def test_list_documents_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.list_documents(request) @@ -3638,6 +3639,7 @@ def test_list_documents_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_documents(**mock_args) @@ -3828,6 +3830,7 @@ def test_get_document_rest_required_fields(request_type=document.GetDocumentRequ 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_document(request) @@ -3875,6 +3878,7 @@ def test_get_document_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_document(**mock_args) @@ -4010,6 +4014,7 @@ def test_create_document_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.create_document(request) @@ -4062,6 +4067,7 @@ def test_create_document_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_document(**mock_args) @@ -4198,6 +4204,7 @@ def test_import_documents_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.import_documents(request) @@ -4326,6 +4333,7 @@ def test_delete_document_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.delete_document(request) @@ -4371,6 +4379,7 @@ def test_delete_document_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.delete_document(**mock_args) @@ -4501,6 +4510,7 @@ def test_update_document_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.update_document(request) @@ -4549,6 +4559,7 @@ def test_update_document_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_document(**mock_args) @@ -4683,6 +4694,7 @@ def test_reload_document_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.reload_document(request) @@ -4728,6 +4740,7 @@ def test_reload_document_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.reload_document(**mock_args) @@ -5235,6 +5248,7 @@ def test_list_documents_rest_bad_request(request_type=document.ListDocumentsRequ 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_documents(request) @@ -5270,6 +5284,7 @@ def test_list_documents_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_documents(request) # Establish that the response is the type that we expect. @@ -5306,6 +5321,7 @@ def test_list_documents_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 = document.ListDocumentsResponse.to_json( document.ListDocumentsResponse() ) @@ -5350,6 +5366,7 @@ def test_get_document_rest_bad_request(request_type=document.GetDocumentRequest) 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_document(request) @@ -5391,6 +5408,7 @@ def test_get_document_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_document(request) # Establish that the response is the type that we expect. @@ -5432,6 +5450,7 @@ def test_get_document_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 = document.Document.to_json(document.Document()) req.return_value.content = return_value @@ -5476,6 +5495,7 @@ def test_create_document_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.create_document(request) @@ -5598,6 +5618,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_document(request) # Establish that the response is the type that we expect. @@ -5637,6 +5658,7 @@ def test_create_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5681,6 +5703,7 @@ def test_import_documents_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.import_documents(request) @@ -5711,6 +5734,7 @@ def test_import_documents_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.import_documents(request) # Establish that the response is the type that we expect. @@ -5750,6 +5774,7 @@ def test_import_documents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5792,6 +5817,7 @@ def test_delete_document_rest_bad_request(request_type=document.DeleteDocumentRe 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_document(request) @@ -5822,6 +5848,7 @@ def test_delete_document_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.delete_document(request) # Establish that the response is the type that we expect. @@ -5859,6 +5886,7 @@ def test_delete_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -5907,6 +5935,7 @@ def test_update_document_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.update_document(request) @@ -6033,6 +6062,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_document(request) # Establish that the response is the type that we expect. @@ -6072,6 +6102,7 @@ def test_update_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6114,6 +6145,7 @@ def test_reload_document_rest_bad_request(request_type=document.ReloadDocumentRe 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.reload_document(request) @@ -6144,6 +6176,7 @@ def test_reload_document_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.reload_document(request) # Establish that the response is the type that we expect. @@ -6181,6 +6214,7 @@ def test_reload_document_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -6225,6 +6259,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) @@ -6255,6 +6290,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) @@ -6283,6 +6319,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) @@ -6313,6 +6350,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) @@ -6343,6 +6381,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6373,6 +6412,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -6403,6 +6443,7 @@ def test_get_operation_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.get_operation(request) @@ -6433,6 +6474,7 @@ def test_get_operation_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_operation(request) @@ -6461,6 +6503,7 @@ def test_list_operations_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_operations(request) @@ -6491,6 +6534,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_encryption_spec_service.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_encryption_spec_service.py index 40f0a4fbd928..126c4db5804a 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_encryption_spec_service.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_encryption_spec_service.py @@ -1931,6 +1931,7 @@ def test_get_encryption_spec_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_encryption_spec(request) @@ -1976,6 +1977,7 @@ def test_get_encryption_spec_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_encryption_spec(**mock_args) @@ -2109,6 +2111,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) @@ -2156,6 +2159,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(**mock_args) @@ -2436,6 +2440,7 @@ def test_get_encryption_spec_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_encryption_spec(request) @@ -2472,6 +2477,7 @@ def test_get_encryption_spec_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_encryption_spec(request) # Establish that the response is the type that we expect. @@ -2513,6 +2519,7 @@ def test_get_encryption_spec_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 = encryption_spec.EncryptionSpec.to_json( encryption_spec.EncryptionSpec() ) @@ -2561,6 +2568,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) @@ -2593,6 +2601,7 @@ def test_initialize_encryption_spec_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.initialize_encryption_spec(request) # Establish that the response is the type that we expect. @@ -2636,6 +2645,7 @@ def test_initialize_encryption_spec_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -2680,6 +2690,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) @@ -2710,6 +2721,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) @@ -2738,6 +2750,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) @@ -2768,6 +2781,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) @@ -2798,6 +2812,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2828,6 +2843,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2858,6 +2874,7 @@ def test_get_operation_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.get_operation(request) @@ -2888,6 +2905,7 @@ def test_get_operation_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_operation(request) @@ -2916,6 +2934,7 @@ def test_list_operations_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_operations(request) @@ -2946,6 +2965,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py index 2295b9f610e1..09275e12c7e1 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py @@ -4890,6 +4890,7 @@ def test_list_entity_types_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.list_entity_types(request) @@ -4945,6 +4946,7 @@ def test_list_entity_types_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_entity_types(**mock_args) @@ -5141,6 +5143,7 @@ def test_get_entity_type_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_entity_type(request) @@ -5187,6 +5190,7 @@ def test_get_entity_type_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_entity_type(**mock_args) @@ -5325,6 +5329,7 @@ def test_create_entity_type_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.create_entity_type(request) @@ -5380,6 +5385,7 @@ def test_create_entity_type_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_entity_type(**mock_args) @@ -5519,6 +5525,7 @@ def test_update_entity_type_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.update_entity_type(request) @@ -5576,6 +5583,7 @@ def test_update_entity_type_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_entity_type(**mock_args) @@ -5710,6 +5718,7 @@ def test_delete_entity_type_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.delete_entity_type(request) @@ -5753,6 +5762,7 @@ def test_delete_entity_type_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_entity_type(**mock_args) @@ -5890,6 +5900,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) @@ -6020,6 +6031,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) @@ -6072,6 +6084,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(**mock_args) @@ -6211,6 +6224,7 @@ def test_batch_create_entities_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.batch_create_entities(request) @@ -6264,6 +6278,7 @@ def test_batch_create_entities_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.batch_create_entities(**mock_args) @@ -6404,6 +6419,7 @@ def test_batch_update_entities_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.batch_update_entities(request) @@ -6457,6 +6473,7 @@ def test_batch_update_entities_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.batch_update_entities(**mock_args) @@ -6601,6 +6618,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) @@ -6654,6 +6672,7 @@ def test_batch_delete_entities_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.batch_delete_entities(**mock_args) @@ -7347,6 +7366,7 @@ def test_list_entity_types_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.list_entity_types(request) @@ -7382,6 +7402,7 @@ def test_list_entity_types_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_entity_types(request) # Establish that the response is the type that we expect. @@ -7422,6 +7443,7 @@ def test_list_entity_types_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 = entity_type.ListEntityTypesResponse.to_json( entity_type.ListEntityTypesResponse() ) @@ -7468,6 +7490,7 @@ def test_get_entity_type_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_entity_type(request) @@ -7507,6 +7530,7 @@ def test_get_entity_type_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_entity_type(request) # Establish that the response is the type that we expect. @@ -7554,6 +7578,7 @@ def test_get_entity_type_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 = entity_type.EntityType.to_json(entity_type.EntityType()) req.return_value.content = return_value @@ -7598,6 +7623,7 @@ def test_create_entity_type_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.create_entity_type(request) @@ -7714,6 +7740,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_entity_type(request) # Establish that the response is the type that we expect. @@ -7761,6 +7788,7 @@ def test_create_entity_type_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 = gcd_entity_type.EntityType.to_json(gcd_entity_type.EntityType()) req.return_value.content = return_value @@ -7807,6 +7835,7 @@ def test_update_entity_type_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.update_entity_type(request) @@ -7925,6 +7954,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_entity_type(request) # Establish that the response is the type that we expect. @@ -7972,6 +8002,7 @@ def test_update_entity_type_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 = gcd_entity_type.EntityType.to_json(gcd_entity_type.EntityType()) req.return_value.content = return_value @@ -8016,6 +8047,7 @@ def test_delete_entity_type_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.delete_entity_type(request) @@ -8046,6 +8078,7 @@ def test_delete_entity_type_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_entity_type(request) # Establish that the response is the type that we expect. @@ -8082,6 +8115,7 @@ def test_delete_entity_type_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 = entity_type.DeleteEntityTypeRequest() metadata = [ @@ -8122,6 +8156,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) @@ -8152,6 +8187,7 @@ def test_batch_update_entity_types_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.batch_update_entity_types(request) # Establish that the response is the type that we expect. @@ -8193,6 +8229,7 @@ def test_batch_update_entity_types_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8237,6 +8274,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) @@ -8267,6 +8305,7 @@ def test_batch_delete_entity_types_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.batch_delete_entity_types(request) # Establish that the response is the type that we expect. @@ -8308,6 +8347,7 @@ def test_batch_delete_entity_types_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8352,6 +8392,7 @@ def test_batch_create_entities_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.batch_create_entities(request) @@ -8382,6 +8423,7 @@ def test_batch_create_entities_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.batch_create_entities(request) # Establish that the response is the type that we expect. @@ -8423,6 +8465,7 @@ def test_batch_create_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8467,6 +8510,7 @@ def test_batch_update_entities_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.batch_update_entities(request) @@ -8497,6 +8541,7 @@ def test_batch_update_entities_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.batch_update_entities(request) # Establish that the response is the type that we expect. @@ -8538,6 +8583,7 @@ def test_batch_update_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8582,6 +8628,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) @@ -8612,6 +8659,7 @@ def test_batch_delete_entities_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.batch_delete_entities(request) # Establish that the response is the type that we expect. @@ -8653,6 +8701,7 @@ def test_batch_delete_entities_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -8697,6 +8746,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) @@ -8727,6 +8777,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) @@ -8755,6 +8806,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) @@ -8785,6 +8837,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) @@ -8815,6 +8868,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8845,6 +8899,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -8875,6 +8930,7 @@ def test_get_operation_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.get_operation(request) @@ -8905,6 +8961,7 @@ def test_get_operation_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_operation(request) @@ -8933,6 +8990,7 @@ def test_list_operations_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_operations(request) @@ -8963,6 +9021,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_environments.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_environments.py index 59c7e8d77255..9ef7d59406e8 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_environments.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_environments.py @@ -3195,6 +3195,7 @@ def test_list_environments_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.list_environments(request) @@ -3248,6 +3249,7 @@ def test_list_environments_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_environments(**mock_args) @@ -3442,6 +3444,7 @@ def test_get_environment_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_environment(request) @@ -3575,6 +3578,7 @@ def test_create_environment_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.create_environment(request) @@ -3716,6 +3720,7 @@ def test_update_environment_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.update_environment(request) @@ -3849,6 +3854,7 @@ def test_delete_environment_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.delete_environment(request) @@ -3980,6 +3986,7 @@ def test_get_environment_history_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_environment_history(request) @@ -4528,6 +4535,7 @@ def test_list_environments_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.list_environments(request) @@ -4563,6 +4571,7 @@ def test_list_environments_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_environments(request) # Establish that the response is the type that we expect. @@ -4603,6 +4612,7 @@ def test_list_environments_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 = environment.ListEnvironmentsResponse.to_json( environment.ListEnvironmentsResponse() ) @@ -4649,6 +4659,7 @@ def test_get_environment_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_environment(request) @@ -4687,6 +4698,7 @@ def test_get_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -4730,6 +4742,7 @@ def test_get_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -4774,6 +4787,7 @@ def test_create_environment_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.create_environment(request) @@ -4905,6 +4919,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_environment(request) # Establish that the response is the type that we expect. @@ -4948,6 +4963,7 @@ def test_create_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -4994,6 +5010,7 @@ def test_update_environment_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.update_environment(request) @@ -5127,6 +5144,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_environment(request) # Establish that the response is the type that we expect. @@ -5170,6 +5188,7 @@ def test_update_environment_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 = environment.Environment.to_json(environment.Environment()) req.return_value.content = return_value @@ -5214,6 +5233,7 @@ def test_delete_environment_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.delete_environment(request) @@ -5244,6 +5264,7 @@ def test_delete_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -5280,6 +5301,7 @@ def test_delete_environment_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 = environment.DeleteEnvironmentRequest() metadata = [ @@ -5320,6 +5342,7 @@ def test_get_environment_history_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_environment_history(request) @@ -5356,6 +5379,7 @@ def test_get_environment_history_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_environment_history(request) # Establish that the response is the type that we expect. @@ -5397,6 +5421,7 @@ def test_get_environment_history_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 = environment.EnvironmentHistory.to_json( environment.EnvironmentHistory() ) @@ -5443,6 +5468,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) @@ -5473,6 +5499,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) @@ -5501,6 +5528,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) @@ -5531,6 +5559,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) @@ -5561,6 +5590,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5591,6 +5621,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5621,6 +5652,7 @@ def test_get_operation_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.get_operation(request) @@ -5651,6 +5683,7 @@ def test_get_operation_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_operation(request) @@ -5679,6 +5712,7 @@ def test_list_operations_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_operations(request) @@ -5709,6 +5743,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py index 3538ec5f7c18..ca767709f12f 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py @@ -1832,6 +1832,7 @@ def test_get_fulfillment_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_fulfillment(request) @@ -1877,6 +1878,7 @@ def test_get_fulfillment_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_fulfillment(**mock_args) @@ -2009,6 +2011,7 @@ def test_update_fulfillment_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.update_fulfillment(request) @@ -2063,6 +2066,7 @@ def test_update_fulfillment_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_fulfillment(**mock_args) @@ -2345,6 +2349,7 @@ def test_get_fulfillment_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_fulfillment(request) @@ -2382,6 +2387,7 @@ def test_get_fulfillment_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_fulfillment(request) # Establish that the response is the type that we expect. @@ -2424,6 +2430,7 @@ def test_get_fulfillment_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 = fulfillment.Fulfillment.to_json(fulfillment.Fulfillment()) req.return_value.content = return_value @@ -2468,6 +2475,7 @@ def test_update_fulfillment_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.update_fulfillment(request) @@ -2585,6 +2593,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_fulfillment(request) # Establish that the response is the type that we expect. @@ -2627,6 +2636,7 @@ def test_update_fulfillment_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 = gcd_fulfillment.Fulfillment.to_json( gcd_fulfillment.Fulfillment() ) @@ -2673,6 +2683,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) @@ -2703,6 +2714,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) @@ -2731,6 +2743,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) @@ -2761,6 +2774,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) @@ -2791,6 +2805,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2821,6 +2836,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2851,6 +2867,7 @@ def test_get_operation_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.get_operation(request) @@ -2881,6 +2898,7 @@ def test_get_operation_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_operation(request) @@ -2909,6 +2927,7 @@ def test_list_operations_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_operations(request) @@ -2939,6 +2958,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_generators.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_generators.py index 64ec57ad4a80..bb6f49b7303b 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_generators.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_generators.py @@ -2987,6 +2987,7 @@ def test_create_generator_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.create_generator(request) @@ -3042,6 +3043,7 @@ def test_create_generator_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_generator(**mock_args) @@ -3173,6 +3175,7 @@ def test_get_generator_rest_required_fields(request_type=generator.GetGeneratorR 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_generator(request) @@ -3220,6 +3223,7 @@ def test_get_generator_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_generator(**mock_args) @@ -3358,6 +3362,7 @@ def test_list_generators_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.list_generators(request) @@ -3411,6 +3416,7 @@ def test_list_generators_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_generators(**mock_args) @@ -3602,6 +3608,7 @@ def test_delete_generator_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.delete_generator(request) @@ -3647,6 +3654,7 @@ def test_delete_generator_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_generator(**mock_args) @@ -3778,6 +3786,7 @@ def test_update_generator_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.update_generator(request) @@ -3828,6 +3837,7 @@ def test_update_generator_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_generator(**mock_args) @@ -4248,6 +4258,7 @@ def test_create_generator_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.create_generator(request) @@ -4395,6 +4406,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_generator(request) # Establish that the response is the type that we expect. @@ -4437,6 +4449,7 @@ def test_create_generator_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 = gcd_generator.Generator.to_json(gcd_generator.Generator()) req.return_value.content = return_value @@ -4479,6 +4492,7 @@ def test_get_generator_rest_bad_request(request_type=generator.GetGeneratorReque 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_generator(request) @@ -4516,6 +4530,7 @@ def test_get_generator_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_generator(request) # Establish that the response is the type that we expect. @@ -4556,6 +4571,7 @@ def test_get_generator_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 = generator.Generator.to_json(generator.Generator()) req.return_value.content = return_value @@ -4598,6 +4614,7 @@ def test_list_generators_rest_bad_request(request_type=generator.ListGeneratorsR 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_generators(request) @@ -4633,6 +4650,7 @@ def test_list_generators_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_generators(request) # Establish that the response is the type that we expect. @@ -4673,6 +4691,7 @@ def test_list_generators_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 = generator.ListGeneratorsResponse.to_json( generator.ListGeneratorsResponse() ) @@ -4719,6 +4738,7 @@ def test_delete_generator_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.delete_generator(request) @@ -4749,6 +4769,7 @@ def test_delete_generator_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_generator(request) # Establish that the response is the type that we expect. @@ -4785,6 +4806,7 @@ def test_delete_generator_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 = generator.DeleteGeneratorRequest() metadata = [ @@ -4827,6 +4849,7 @@ def test_update_generator_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.update_generator(request) @@ -4976,6 +4999,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_generator(request) # Establish that the response is the type that we expect. @@ -5018,6 +5042,7 @@ def test_update_generator_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 = gcd_generator.Generator.to_json(gcd_generator.Generator()) req.return_value.content = return_value @@ -5062,6 +5087,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) @@ -5092,6 +5118,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) @@ -5120,6 +5147,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) @@ -5150,6 +5178,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) @@ -5180,6 +5209,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5210,6 +5240,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5240,6 +5271,7 @@ def test_get_operation_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.get_operation(request) @@ -5270,6 +5302,7 @@ def test_get_operation_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_operation(request) @@ -5298,6 +5331,7 @@ def test_list_operations_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_operations(request) @@ -5328,6 +5362,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_intents.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_intents.py index 74298ca6eba3..2f51458f28ea 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_intents.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_intents.py @@ -3902,6 +3902,7 @@ def test_list_intents_rest_required_fields(request_type=intent.ListIntentsReques 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_intents(request) @@ -3958,6 +3959,7 @@ def test_list_intents_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_intents(**mock_args) @@ -4155,6 +4157,7 @@ def test_get_intent_rest_required_fields(request_type=intent.GetIntentRequest): 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_intent(request) @@ -4209,6 +4212,7 @@ def test_get_intent_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_intent(**mock_args) @@ -4348,6 +4352,7 @@ def test_create_intent_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.create_intent(request) @@ -4408,6 +4413,7 @@ def test_create_intent_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_intent(**mock_args) @@ -4544,6 +4550,7 @@ def test_update_intent_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.update_intent(request) @@ -4600,6 +4607,7 @@ def test_update_intent_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_intent(**mock_args) @@ -4728,6 +4736,7 @@ def test_delete_intent_rest_required_fields(request_type=intent.DeleteIntentRequ 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_intent(request) @@ -4771,6 +4780,7 @@ def test_delete_intent_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_intent(**mock_args) @@ -4907,6 +4917,7 @@ def test_batch_update_intents_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.batch_update_intents(request) @@ -4950,6 +4961,7 @@ def test_batch_update_intents_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.batch_update_intents(**mock_args) @@ -5091,6 +5103,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) @@ -5143,6 +5156,7 @@ def test_batch_delete_intents_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.batch_delete_intents(**mock_args) @@ -5704,6 +5718,7 @@ def test_list_intents_rest_bad_request(request_type=intent.ListIntentsRequest): 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_intents(request) @@ -5739,6 +5754,7 @@ def test_list_intents_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_intents(request) # Establish that the response is the type that we expect. @@ -5775,6 +5791,7 @@ def test_list_intents_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 = intent.ListIntentsResponse.to_json(intent.ListIntentsResponse()) req.return_value.content = return_value @@ -5817,6 +5834,7 @@ def test_get_intent_rest_bad_request(request_type=intent.GetIntentRequest): 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_intent(request) @@ -5867,6 +5885,7 @@ def test_get_intent_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_intent(request) # Establish that the response is the type that we expect. @@ -5920,6 +5939,7 @@ def test_get_intent_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 = intent.Intent.to_json(intent.Intent()) req.return_value.content = return_value @@ -5962,6 +5982,7 @@ def test_create_intent_rest_bad_request(request_type=gcd_intent.CreateIntentRequ 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_intent(request) @@ -6283,6 +6304,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_intent(request) # Establish that the response is the type that we expect. @@ -6338,6 +6360,7 @@ def test_create_intent_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 = gcd_intent.Intent.to_json(gcd_intent.Intent()) req.return_value.content = return_value @@ -6380,6 +6403,7 @@ def test_update_intent_rest_bad_request(request_type=gcd_intent.UpdateIntentRequ 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_intent(request) @@ -6701,6 +6725,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_intent(request) # Establish that the response is the type that we expect. @@ -6756,6 +6781,7 @@ def test_update_intent_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 = gcd_intent.Intent.to_json(gcd_intent.Intent()) req.return_value.content = return_value @@ -6798,6 +6824,7 @@ def test_delete_intent_rest_bad_request(request_type=intent.DeleteIntentRequest) 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_intent(request) @@ -6828,6 +6855,7 @@ def test_delete_intent_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_intent(request) # Establish that the response is the type that we expect. @@ -6860,6 +6888,7 @@ def test_delete_intent_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 = intent.DeleteIntentRequest() metadata = [ @@ -6900,6 +6929,7 @@ def test_batch_update_intents_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.batch_update_intents(request) @@ -6930,6 +6960,7 @@ def test_batch_update_intents_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.batch_update_intents(request) # Establish that the response is the type that we expect. @@ -6969,6 +7000,7 @@ def test_batch_update_intents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7013,6 +7045,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) @@ -7043,6 +7076,7 @@ def test_batch_delete_intents_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.batch_delete_intents(request) # Establish that the response is the type that we expect. @@ -7082,6 +7116,7 @@ def test_batch_delete_intents_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -7126,6 +7161,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) @@ -7156,6 +7192,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) @@ -7184,6 +7221,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) @@ -7214,6 +7252,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) @@ -7244,6 +7283,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7274,6 +7314,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -7304,6 +7345,7 @@ def test_get_operation_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.get_operation(request) @@ -7334,6 +7376,7 @@ def test_get_operation_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_operation(request) @@ -7362,6 +7405,7 @@ def test_list_operations_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_operations(request) @@ -7392,6 +7436,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py index 15df3af59e8e..1c756113b71e 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py @@ -3127,6 +3127,7 @@ def test_list_knowledge_bases_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.list_knowledge_bases(request) @@ -3181,6 +3182,7 @@ def test_list_knowledge_bases_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_knowledge_bases(**mock_args) @@ -3378,6 +3380,7 @@ def test_get_knowledge_base_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_knowledge_base(request) @@ -3423,6 +3426,7 @@ def test_get_knowledge_base_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_knowledge_base(**mock_args) @@ -3559,6 +3563,7 @@ def test_create_knowledge_base_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.create_knowledge_base(request) @@ -3613,6 +3618,7 @@ def test_create_knowledge_base_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_knowledge_base(**mock_args) @@ -3748,6 +3754,7 @@ def test_delete_knowledge_base_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.delete_knowledge_base(request) @@ -3791,6 +3798,7 @@ def test_delete_knowledge_base_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_knowledge_base(**mock_args) @@ -3924,6 +3932,7 @@ def test_update_knowledge_base_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.update_knowledge_base(request) @@ -3972,6 +3981,7 @@ def test_update_knowledge_base_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_knowledge_base(**mock_args) @@ -4412,6 +4422,7 @@ def test_list_knowledge_bases_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.list_knowledge_bases(request) @@ -4447,6 +4458,7 @@ def test_list_knowledge_bases_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_knowledge_bases(request) # Establish that the response is the type that we expect. @@ -4487,6 +4499,7 @@ def test_list_knowledge_bases_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 = knowledge_base.ListKnowledgeBasesResponse.to_json( knowledge_base.ListKnowledgeBasesResponse() ) @@ -4533,6 +4546,7 @@ def test_get_knowledge_base_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_knowledge_base(request) @@ -4570,6 +4584,7 @@ def test_get_knowledge_base_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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4612,6 +4627,7 @@ def test_get_knowledge_base_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 = knowledge_base.KnowledgeBase.to_json( knowledge_base.KnowledgeBase() ) @@ -4658,6 +4674,7 @@ def test_create_knowledge_base_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.create_knowledge_base(request) @@ -4769,6 +4786,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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4811,6 +4829,7 @@ def test_create_knowledge_base_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 = gcd_knowledge_base.KnowledgeBase.to_json( gcd_knowledge_base.KnowledgeBase() ) @@ -4857,6 +4876,7 @@ def test_delete_knowledge_base_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.delete_knowledge_base(request) @@ -4887,6 +4907,7 @@ def test_delete_knowledge_base_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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -4923,6 +4944,7 @@ def test_delete_knowledge_base_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 = knowledge_base.DeleteKnowledgeBaseRequest() metadata = [ @@ -4965,6 +4987,7 @@ def test_update_knowledge_base_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.update_knowledge_base(request) @@ -5078,6 +5101,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_knowledge_base(request) # Establish that the response is the type that we expect. @@ -5120,6 +5144,7 @@ def test_update_knowledge_base_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 = gcd_knowledge_base.KnowledgeBase.to_json( gcd_knowledge_base.KnowledgeBase() ) @@ -5166,6 +5191,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) @@ -5196,6 +5222,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) @@ -5224,6 +5251,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) @@ -5254,6 +5282,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) @@ -5284,6 +5313,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5314,6 +5344,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5344,6 +5375,7 @@ def test_get_operation_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.get_operation(request) @@ -5374,6 +5406,7 @@ def test_get_operation_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_operation(request) @@ -5402,6 +5435,7 @@ def test_list_operations_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_operations(request) @@ -5432,6 +5466,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_participants.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_participants.py index 441a94382857..eae2191cedc3 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_participants.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_participants.py @@ -5261,6 +5261,7 @@ def test_create_participant_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.create_participant(request) @@ -5315,6 +5316,7 @@ def test_create_participant_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_participant(**mock_args) @@ -5447,6 +5449,7 @@ def test_get_participant_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_participant(request) @@ -5494,6 +5497,7 @@ def test_get_participant_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_participant(**mock_args) @@ -5634,6 +5638,7 @@ def test_list_participants_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.list_participants(request) @@ -5687,6 +5692,7 @@ def test_list_participants_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_participants(**mock_args) @@ -5883,6 +5889,7 @@ def test_update_participant_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.update_participant(request) @@ -5941,6 +5948,7 @@ def test_update_participant_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_participant(**mock_args) @@ -6074,6 +6082,7 @@ def test_analyze_content_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.analyze_content(request) @@ -6121,6 +6130,7 @@ def test_analyze_content_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.analyze_content(**mock_args) @@ -6273,6 +6283,7 @@ def test_suggest_articles_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.suggest_articles(request) @@ -6320,6 +6331,7 @@ def test_suggest_articles_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.suggest_articles(**mock_args) @@ -6456,6 +6468,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) @@ -6503,6 +6516,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(**mock_args) @@ -6640,6 +6654,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) @@ -6687,6 +6702,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(**mock_args) @@ -6824,6 +6840,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) @@ -7712,6 +7729,7 @@ def test_create_participant_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.create_participant(request) @@ -7822,6 +7840,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_participant(request) # Establish that the response is the type that we expect. @@ -7864,6 +7883,7 @@ def test_create_participant_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 = gcd_participant.Participant.to_json( gcd_participant.Participant() ) @@ -7912,6 +7932,7 @@ def test_get_participant_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_participant(request) @@ -7951,6 +7972,7 @@ def test_get_participant_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_participant(request) # Establish that the response is the type that we expect. @@ -7993,6 +8015,7 @@ def test_get_participant_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 = participant.Participant.to_json(participant.Participant()) req.return_value.content = return_value @@ -8037,6 +8060,7 @@ def test_list_participants_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.list_participants(request) @@ -8072,6 +8096,7 @@ def test_list_participants_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_participants(request) # Establish that the response is the type that we expect. @@ -8112,6 +8137,7 @@ def test_list_participants_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 = participant.ListParticipantsResponse.to_json( participant.ListParticipantsResponse() ) @@ -8162,6 +8188,7 @@ def test_update_participant_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.update_participant(request) @@ -8276,6 +8303,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_participant(request) # Establish that the response is the type that we expect. @@ -8318,6 +8346,7 @@ def test_update_participant_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 = gcd_participant.Participant.to_json( gcd_participant.Participant() ) @@ -8366,6 +8395,7 @@ def test_analyze_content_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.analyze_content(request) @@ -8403,6 +8433,7 @@ def test_analyze_content_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.analyze_content(request) # Establish that the response is the type that we expect. @@ -8443,6 +8474,7 @@ def test_analyze_content_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 = gcd_participant.AnalyzeContentResponse.to_json( gcd_participant.AnalyzeContentResponse() ) @@ -8503,6 +8535,7 @@ def test_suggest_articles_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.suggest_articles(request) @@ -8541,6 +8574,7 @@ def test_suggest_articles_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.suggest_articles(request) # Establish that the response is the type that we expect. @@ -8582,6 +8616,7 @@ def test_suggest_articles_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 = participant.SuggestArticlesResponse.to_json( participant.SuggestArticlesResponse() ) @@ -8630,6 +8665,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) @@ -8668,6 +8704,7 @@ def test_suggest_faq_answers_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.suggest_faq_answers(request) # Establish that the response is the type that we expect. @@ -8709,6 +8746,7 @@ def test_suggest_faq_answers_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 = participant.SuggestFaqAnswersResponse.to_json( participant.SuggestFaqAnswersResponse() ) @@ -8757,6 +8795,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) @@ -8795,6 +8834,7 @@ def test_suggest_smart_replies_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.suggest_smart_replies(request) # Establish that the response is the type that we expect. @@ -8836,6 +8876,7 @@ def test_suggest_smart_replies_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 = participant.SuggestSmartRepliesResponse.to_json( participant.SuggestSmartRepliesResponse() ) @@ -8884,6 +8925,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) @@ -8922,6 +8964,7 @@ def test_suggest_knowledge_assist_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.suggest_knowledge_assist(request) # Establish that the response is the type that we expect. @@ -8963,6 +9006,7 @@ def test_suggest_knowledge_assist_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 = participant.SuggestKnowledgeAssistResponse.to_json( participant.SuggestKnowledgeAssistResponse() ) @@ -9011,6 +9055,7 @@ def test_list_suggestions_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.list_suggestions(request) @@ -9048,6 +9093,7 @@ def test_list_suggestions_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_suggestions(request) # Establish that the response is the type that we expect. @@ -9088,6 +9134,7 @@ def test_list_suggestions_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 = participant.ListSuggestionsResponse.to_json( participant.ListSuggestionsResponse() ) @@ -9136,6 +9183,7 @@ def test_compile_suggestion_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.compile_suggestion(request) @@ -9174,6 +9222,7 @@ def test_compile_suggestion_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.compile_suggestion(request) # Establish that the response is the type that we expect. @@ -9215,6 +9264,7 @@ def test_compile_suggestion_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 = participant.CompileSuggestionResponse.to_json( participant.CompileSuggestionResponse() ) @@ -9261,6 +9311,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) @@ -9291,6 +9342,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) @@ -9319,6 +9371,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) @@ -9349,6 +9402,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) @@ -9379,6 +9433,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -9409,6 +9464,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -9439,6 +9495,7 @@ def test_get_operation_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.get_operation(request) @@ -9469,6 +9526,7 @@ def test_get_operation_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_operation(request) @@ -9497,6 +9555,7 @@ def test_list_operations_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_operations(request) @@ -9527,6 +9586,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py index cab82c113e89..c38d1e16ab58 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py @@ -3203,6 +3203,7 @@ def test_list_session_entity_types_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.list_session_entity_types(request) @@ -3258,6 +3259,7 @@ def test_list_session_entity_types_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_session_entity_types(**mock_args) @@ -3460,6 +3462,7 @@ def test_get_session_entity_type_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_session_entity_type(request) @@ -3507,6 +3510,7 @@ def test_get_session_entity_type_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_session_entity_type(**mock_args) @@ -3644,6 +3648,7 @@ def test_create_session_entity_type_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.create_session_entity_type(request) @@ -3700,6 +3705,7 @@ def test_create_session_entity_type_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_session_entity_type(**mock_args) @@ -3837,6 +3843,7 @@ def test_update_session_entity_type_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.update_session_entity_type(request) @@ -3889,6 +3896,7 @@ def test_update_session_entity_type_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_session_entity_type(**mock_args) @@ -4025,6 +4033,7 @@ def test_delete_session_entity_type_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.delete_session_entity_type(request) @@ -4070,6 +4079,7 @@ def test_delete_session_entity_type_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_session_entity_type(**mock_args) @@ -4506,6 +4516,7 @@ def test_list_session_entity_types_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.list_session_entity_types(request) @@ -4543,6 +4554,7 @@ def test_list_session_entity_types_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_session_entity_types(request) # Establish that the response is the type that we expect. @@ -4583,6 +4595,7 @@ def test_list_session_entity_types_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 = session_entity_type.ListSessionEntityTypesResponse.to_json( session_entity_type.ListSessionEntityTypesResponse() ) @@ -4631,6 +4644,7 @@ def test_get_session_entity_type_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_session_entity_type(request) @@ -4669,6 +4683,7 @@ def test_get_session_entity_type_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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -4713,6 +4728,7 @@ def test_get_session_entity_type_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 = session_entity_type.SessionEntityType.to_json( session_entity_type.SessionEntityType() ) @@ -4759,6 +4775,7 @@ def test_create_session_entity_type_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.create_session_entity_type(request) @@ -4871,6 +4888,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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -4915,6 +4933,7 @@ def test_create_session_entity_type_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 = gcd_session_entity_type.SessionEntityType.to_json( gcd_session_entity_type.SessionEntityType() ) @@ -4965,6 +4984,7 @@ def test_update_session_entity_type_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.update_session_entity_type(request) @@ -5081,6 +5101,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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -5125,6 +5146,7 @@ def test_update_session_entity_type_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 = gcd_session_entity_type.SessionEntityType.to_json( gcd_session_entity_type.SessionEntityType() ) @@ -5173,6 +5195,7 @@ def test_delete_session_entity_type_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.delete_session_entity_type(request) @@ -5205,6 +5228,7 @@ def test_delete_session_entity_type_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_session_entity_type(request) # Establish that the response is the type that we expect. @@ -5241,6 +5265,7 @@ def test_delete_session_entity_type_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 = session_entity_type.DeleteSessionEntityTypeRequest() metadata = [ @@ -5281,6 +5306,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) @@ -5311,6 +5337,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) @@ -5339,6 +5366,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) @@ -5369,6 +5397,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) @@ -5399,6 +5428,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5429,6 +5459,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5459,6 +5490,7 @@ def test_get_operation_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.get_operation(request) @@ -5489,6 +5521,7 @@ def test_get_operation_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_operation(request) @@ -5517,6 +5550,7 @@ def test_list_operations_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_operations(request) @@ -5547,6 +5581,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py index 5c47b8df0b9b..deadb5739a04 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py @@ -1643,6 +1643,7 @@ def test_detect_intent_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.detect_intent(request) @@ -1701,6 +1702,7 @@ def test_detect_intent_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.detect_intent(**mock_args) @@ -1954,6 +1956,7 @@ def test_detect_intent_rest_bad_request(request_type=gcd_session.DetectIntentReq 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.detect_intent(request) @@ -1990,6 +1993,7 @@ def test_detect_intent_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.detect_intent(request) # Establish that the response is the type that we expect. @@ -2029,6 +2033,7 @@ def test_detect_intent_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 = gcd_session.DetectIntentResponse.to_json( gcd_session.DetectIntentResponse() ) @@ -2087,6 +2092,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) @@ -2117,6 +2123,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) @@ -2145,6 +2152,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) @@ -2175,6 +2183,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) @@ -2205,6 +2214,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2235,6 +2245,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -2265,6 +2276,7 @@ def test_get_operation_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.get_operation(request) @@ -2295,6 +2307,7 @@ def test_get_operation_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_operation(request) @@ -2323,6 +2336,7 @@ def test_list_operations_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_operations(request) @@ -2353,6 +2367,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sip_trunks.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sip_trunks.py index 0c47dac81b87..feddae956bdc 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sip_trunks.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_sip_trunks.py @@ -2971,6 +2971,7 @@ def test_create_sip_trunk_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.create_sip_trunk(request) @@ -3025,6 +3026,7 @@ def test_create_sip_trunk_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_sip_trunk(**mock_args) @@ -3156,6 +3158,7 @@ def test_delete_sip_trunk_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.delete_sip_trunk(request) @@ -3201,6 +3204,7 @@ def test_delete_sip_trunk_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_sip_trunk(**mock_args) @@ -3339,6 +3343,7 @@ def test_list_sip_trunks_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.list_sip_trunks(request) @@ -3392,6 +3397,7 @@ def test_list_sip_trunks_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_sip_trunks(**mock_args) @@ -3582,6 +3588,7 @@ def test_get_sip_trunk_rest_required_fields(request_type=sip_trunk.GetSipTrunkRe 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_sip_trunk(request) @@ -3629,6 +3636,7 @@ def test_get_sip_trunk_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_sip_trunk(**mock_args) @@ -3760,6 +3768,7 @@ def test_update_sip_trunk_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.update_sip_trunk(request) @@ -3810,6 +3819,7 @@ def test_update_sip_trunk_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_sip_trunk(**mock_args) @@ -4230,6 +4240,7 @@ def test_create_sip_trunk_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.create_sip_trunk(request) @@ -4350,6 +4361,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_sip_trunk(request) # Establish that the response is the type that we expect. @@ -4390,6 +4402,7 @@ def test_create_sip_trunk_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 = gcd_sip_trunk.SipTrunk.to_json(gcd_sip_trunk.SipTrunk()) req.return_value.content = return_value @@ -4434,6 +4447,7 @@ def test_delete_sip_trunk_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.delete_sip_trunk(request) @@ -4464,6 +4478,7 @@ def test_delete_sip_trunk_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_sip_trunk(request) # Establish that the response is the type that we expect. @@ -4498,6 +4513,7 @@ def test_delete_sip_trunk_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 = sip_trunk.DeleteSipTrunkRequest() metadata = [ @@ -4536,6 +4552,7 @@ def test_list_sip_trunks_rest_bad_request(request_type=sip_trunk.ListSipTrunksRe 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_sip_trunks(request) @@ -4571,6 +4588,7 @@ def test_list_sip_trunks_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_sip_trunks(request) # Establish that the response is the type that we expect. @@ -4607,6 +4625,7 @@ def test_list_sip_trunks_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 = sip_trunk.ListSipTrunksResponse.to_json( sip_trunk.ListSipTrunksResponse() ) @@ -4651,6 +4670,7 @@ def test_get_sip_trunk_rest_bad_request(request_type=sip_trunk.GetSipTrunkReques 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_sip_trunk(request) @@ -4688,6 +4708,7 @@ def test_get_sip_trunk_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_sip_trunk(request) # Establish that the response is the type that we expect. @@ -4726,6 +4747,7 @@ def test_get_sip_trunk_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 = sip_trunk.SipTrunk.to_json(sip_trunk.SipTrunk()) req.return_value.content = return_value @@ -4772,6 +4794,7 @@ def test_update_sip_trunk_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.update_sip_trunk(request) @@ -4894,6 +4917,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_sip_trunk(request) # Establish that the response is the type that we expect. @@ -4934,6 +4958,7 @@ def test_update_sip_trunk_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 = gcd_sip_trunk.SipTrunk.to_json(gcd_sip_trunk.SipTrunk()) req.return_value.content = return_value @@ -4978,6 +5003,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) @@ -5008,6 +5034,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) @@ -5036,6 +5063,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) @@ -5066,6 +5094,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) @@ -5096,6 +5125,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5126,6 +5156,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5156,6 +5187,7 @@ def test_get_operation_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.get_operation(request) @@ -5186,6 +5218,7 @@ def test_get_operation_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_operation(request) @@ -5214,6 +5247,7 @@ def test_list_operations_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_operations(request) @@ -5244,6 +5278,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_versions.py b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_versions.py index 869b25180e22..5559904b5510 100644 --- a/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_versions.py +++ b/packages/google-cloud-dialogflow/tests/unit/gapic/dialogflow_v2beta1/test_versions.py @@ -2958,6 +2958,7 @@ def test_list_versions_rest_required_fields(request_type=version.ListVersionsReq 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_versions(request) @@ -3011,6 +3012,7 @@ def test_list_versions_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_versions(**mock_args) @@ -3200,6 +3202,7 @@ def test_get_version_rest_required_fields(request_type=version.GetVersionRequest 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_version(request) @@ -3245,6 +3248,7 @@ def test_get_version_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_version(**mock_args) @@ -3376,6 +3380,7 @@ def test_create_version_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.create_version(request) @@ -3430,6 +3435,7 @@ def test_create_version_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_version(**mock_args) @@ -3559,6 +3565,7 @@ def test_update_version_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.update_version(request) @@ -3615,6 +3622,7 @@ def test_update_version_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_version(**mock_args) @@ -3742,6 +3750,7 @@ def test_delete_version_rest_required_fields(request_type=version.DeleteVersionR 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_version(request) @@ -3785,6 +3794,7 @@ def test_delete_version_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_version(**mock_args) @@ -4204,6 +4214,7 @@ def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest 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_versions(request) @@ -4239,6 +4250,7 @@ def test_list_versions_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_versions(request) # Establish that the response is the type that we expect. @@ -4275,6 +4287,7 @@ def test_list_versions_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 = version.ListVersionsResponse.to_json( version.ListVersionsResponse() ) @@ -4319,6 +4332,7 @@ def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): 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_version(request) @@ -4357,6 +4371,7 @@ def test_get_version_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_version(request) # Establish that the response is the type that we expect. @@ -4396,6 +4411,7 @@ def test_get_version_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 = version.Version.to_json(version.Version()) req.return_value.content = return_value @@ -4438,6 +4454,7 @@ def test_create_version_rest_bad_request(request_type=gcd_version.CreateVersionR 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_version(request) @@ -4550,6 +4567,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_version(request) # Establish that the response is the type that we expect. @@ -4591,6 +4609,7 @@ def test_create_version_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 = gcd_version.Version.to_json(gcd_version.Version()) req.return_value.content = return_value @@ -4633,6 +4652,7 @@ def test_update_version_rest_bad_request(request_type=gcd_version.UpdateVersionR 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_version(request) @@ -4745,6 +4765,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_version(request) # Establish that the response is the type that we expect. @@ -4786,6 +4807,7 @@ def test_update_version_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 = gcd_version.Version.to_json(gcd_version.Version()) req.return_value.content = return_value @@ -4828,6 +4850,7 @@ def test_delete_version_rest_bad_request(request_type=version.DeleteVersionReque 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_version(request) @@ -4858,6 +4881,7 @@ def test_delete_version_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_version(request) # Establish that the response is the type that we expect. @@ -4890,6 +4914,7 @@ def test_delete_version_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 = version.DeleteVersionRequest() metadata = [ @@ -4930,6 +4955,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) @@ -4960,6 +4986,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) @@ -4988,6 +5015,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) @@ -5018,6 +5046,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) @@ -5048,6 +5077,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5078,6 +5108,7 @@ def test_cancel_operation_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.cancel_operation(request) @@ -5108,6 +5139,7 @@ def test_get_operation_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.get_operation(request) @@ -5138,6 +5170,7 @@ def test_get_operation_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_operation(request) @@ -5166,6 +5199,7 @@ def test_list_operations_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_operations(request) @@ -5196,6 +5230,7 @@ def test_list_operations_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_operations(request) 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 14/16] 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) From 8c53239ba1ddcbb7691f99db47bce7a8e0b737cd 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 19:09:25 +0500 Subject: [PATCH 15/16] feat: [google-cloud-automl] Add support for opt-in debug logging (#13332) 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 docs: Update io.proto to use markdown headings instead of HTML, remove some unused HTML from 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWF1dG9tbC8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT docs: [google-cloud-automl] Update io.proto to use markdown headings instead of HTML, remove some unused HTML from markdown PiperOrigin-RevId: 703192272 Source-Link: https://github.com/googleapis/googleapis/commit/05347e0a68ac16ec35146249d598fcdc6dd8c0c5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/71b95495d6fb29d970ead6a17752d58d1efc8ffb Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWF1dG9tbC8uT3dsQm90LnlhbWwiLCJoIjoiNzFiOTU0OTVkNmZiMjlkOTcwZWFkNmExNzc1MmQ1OGQxZWZjOGZmYiJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/automl/gapic_version.py | 2 +- .../google/cloud/automl_v1/gapic_version.py | 2 +- .../services/auto_ml/async_client.py | 176 +- .../automl_v1/services/auto_ml/client.py | 181 +- .../automl_v1/services/auto_ml/pagers.py | 48 +- .../services/auto_ml/transports/grpc.py | 130 +- .../auto_ml/transports/grpc_asyncio.py | 127 +- .../services/auto_ml/transports/rest.py | 1166 ++++++++++++- .../prediction_service/async_client.py | 48 +- .../services/prediction_service/client.py | 53 +- .../prediction_service/transports/grpc.py | 98 +- .../transports/grpc_asyncio.py | 95 +- .../prediction_service/transports/rest.py | 140 +- .../google/cloud/automl_v1/types/io.py | 149 +- .../cloud/automl_v1beta1/gapic_version.py | 2 +- .../services/auto_ml/async_client.py | 224 ++- .../automl_v1beta1/services/auto_ml/client.py | 229 ++- .../automl_v1beta1/services/auto_ml/pagers.py | 80 +- .../services/auto_ml/transports/grpc.py | 142 +- .../auto_ml/transports/grpc_asyncio.py | 139 +- .../services/auto_ml/transports/rest.py | 1544 +++++++++++++++-- .../prediction_service/async_client.py | 48 +- .../services/prediction_service/client.py | 53 +- .../prediction_service/transports/grpc.py | 98 +- .../transports/grpc_asyncio.py | 95 +- .../prediction_service/transports/rest.py | 140 +- ...ippet_metadata_google.cloud.automl.v1.json | 82 +- ..._metadata_google.cloud.automl.v1beta1.json | 106 +- .../unit/gapic/automl_v1/test_auto_ml.py | 90 + .../automl_v1/test_prediction_service.py | 10 + .../unit/gapic/automl_v1beta1/test_auto_ml.py | 120 ++ .../automl_v1beta1/test_prediction_service.py | 10 + 32 files changed, 4757 insertions(+), 870 deletions(-) diff --git a/packages/google-cloud-automl/google/cloud/automl/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-automl/google/cloud/automl/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/async_client.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/async_client.py index 84852b458c9f..324a8847294a 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/async_client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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, @@ -69,6 +70,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AutoMlTransport from .transports.grpc_asyncio import AutoMlGrpcAsyncIOTransport +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 AutoMlAsyncClient: """AutoML Server API. @@ -285,6 +295,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.automl_v1.AutoMlAsyncClient`.", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "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.automl.v1.AutoMl", + "credentialsType": None, + }, + ) + async def create_dataset( self, request: Optional[Union[service.CreateDatasetRequest, dict]] = None, @@ -293,7 +325,7 @@ async def create_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a dataset. @@ -351,8 +383,10 @@ async def sample_create_dataset(): 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.api_core.operation_async.AsyncOperation: @@ -425,7 +459,7 @@ async def get_dataset( 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]]] = (), ) -> dataset.Dataset: r"""Gets a dataset. @@ -469,8 +503,10 @@ async def sample_get_dataset(): 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.automl_v1.types.Dataset: @@ -533,7 +569,7 @@ async def list_datasets( 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.ListDatasetsAsyncPager: r"""Lists datasets in a project. @@ -578,8 +614,10 @@ async def sample_list_datasets(): 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.automl_v1.services.auto_ml.pagers.ListDatasetsAsyncPager: @@ -655,7 +693,7 @@ async def update_dataset( 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]]] = (), ) -> gca_dataset.Dataset: r"""Updates a dataset. @@ -710,8 +748,10 @@ async def sample_update_dataset(): 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.automl_v1.types.Dataset: @@ -778,7 +818,7 @@ async def delete_dataset( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a dataset and all of its contents. Returns empty response in the @@ -830,8 +870,10 @@ async def sample_delete_dataset(): 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.api_core.operation_async.AsyncOperation: @@ -911,7 +953,7 @@ async def import_data( input_config: Optional[io.InputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Imports data into a dataset. For Tables this method can only be called on an empty Dataset. @@ -981,8 +1023,10 @@ async def sample_import_data(): 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.api_core.operation_async.AsyncOperation: @@ -1064,7 +1108,7 @@ async def export_data( output_config: Optional[io.OutputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports dataset's data to the provided output location. Returns an empty response in the @@ -1126,8 +1170,10 @@ async def sample_export_data(): 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.api_core.operation_async.AsyncOperation: @@ -1208,7 +1254,7 @@ async def get_annotation_spec( 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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. @@ -1252,8 +1298,10 @@ async def sample_get_annotation_spec(): 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.automl_v1.types.AnnotationSpec: @@ -1313,7 +1361,7 @@ async def create_model( model: Optional[gca_model.Model] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a model. Returns a Model in the [response][google.longrunning.Operation.response] field when it @@ -1371,8 +1419,10 @@ async def sample_create_model(): 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.api_core.operation_async.AsyncOperation: @@ -1446,7 +1496,7 @@ async def get_model( 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]]] = (), ) -> model.Model: r"""Gets a model. @@ -1488,8 +1538,10 @@ async def sample_get_model(): 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.automl_v1.types.Model: @@ -1550,7 +1602,7 @@ async def list_models( 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.ListModelsAsyncPager: r"""Lists models. @@ -1595,8 +1647,10 @@ async def sample_list_models(): 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.automl_v1.services.auto_ml.pagers.ListModelsAsyncPager: @@ -1671,7 +1725,7 @@ async def delete_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a model. Returns ``google.protobuf.Empty`` in the [response][google.longrunning.Operation.response] field when it @@ -1722,8 +1776,10 @@ async def sample_delete_model(): 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.api_core.operation_async.AsyncOperation: @@ -1803,7 +1859,7 @@ async def update_model( 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]]] = (), ) -> gca_model.Model: r"""Updates a model. @@ -1853,8 +1909,10 @@ async def sample_update_model(): 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.automl_v1.types.Model: @@ -1919,7 +1977,7 @@ async def deploy_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different @@ -1980,8 +2038,10 @@ async def sample_deploy_model(): 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.api_core.operation_async.AsyncOperation: @@ -2060,7 +2120,7 @@ async def undeploy_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys a model. If the model is not deployed this method has no effect. @@ -2116,8 +2176,10 @@ async def sample_undeploy_model(): 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.api_core.operation_async.AsyncOperation: @@ -2197,7 +2259,7 @@ async def export_model( output_config: Optional[io.ModelExportOutputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able @@ -2265,8 +2327,10 @@ async def sample_export_model(): 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.api_core.operation_async.AsyncOperation: @@ -2347,7 +2411,7 @@ async def get_model_evaluation( 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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. @@ -2391,8 +2455,10 @@ async def sample_get_model_evaluation(): 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.automl_v1.types.ModelEvaluation: @@ -2452,7 +2518,7 @@ async def list_model_evaluations( filter: 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.ListModelEvaluationsAsyncPager: r"""Lists model evaluations. @@ -2519,8 +2585,10 @@ async def sample_list_model_evaluations(): 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.automl_v1.services.auto_ml.pagers.ListModelEvaluationsAsyncPager: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/client.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/client.py index 187d7c17a984..0883ef0ea2e5 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -681,6 +691,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( @@ -743,6 +757,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.automl_v1.AutoMlClient`.", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "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.automl.v1.AutoMl", + "credentialsType": None, + }, + ) + def create_dataset( self, request: Optional[Union[service.CreateDatasetRequest, dict]] = None, @@ -751,7 +788,7 @@ def create_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> operation.Operation: r"""Creates a dataset. @@ -809,8 +846,10 @@ def sample_create_dataset(): 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.api_core.operation.Operation: @@ -880,7 +919,7 @@ def get_dataset( 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]]] = (), ) -> dataset.Dataset: r"""Gets a dataset. @@ -924,8 +963,10 @@ def sample_get_dataset(): 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.automl_v1.types.Dataset: @@ -985,7 +1026,7 @@ def list_datasets( 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.ListDatasetsPager: r"""Lists datasets in a project. @@ -1030,8 +1071,10 @@ def sample_list_datasets(): 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.automl_v1.services.auto_ml.pagers.ListDatasetsPager: @@ -1104,7 +1147,7 @@ def update_dataset( 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]]] = (), ) -> gca_dataset.Dataset: r"""Updates a dataset. @@ -1159,8 +1202,10 @@ def sample_update_dataset(): 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.automl_v1.types.Dataset: @@ -1224,7 +1269,7 @@ def delete_dataset( 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]]] = (), ) -> operation.Operation: r"""Deletes a dataset and all of its contents. Returns empty response in the @@ -1276,8 +1321,10 @@ def sample_delete_dataset(): 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.api_core.operation.Operation: @@ -1354,7 +1401,7 @@ def import_data( input_config: Optional[io.InputConfig] = 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]]] = (), ) -> operation.Operation: r"""Imports data into a dataset. For Tables this method can only be called on an empty Dataset. @@ -1424,8 +1471,10 @@ def sample_import_data(): 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.api_core.operation.Operation: @@ -1504,7 +1553,7 @@ def export_data( output_config: Optional[io.OutputConfig] = 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]]] = (), ) -> operation.Operation: r"""Exports dataset's data to the provided output location. Returns an empty response in the @@ -1566,8 +1615,10 @@ def sample_export_data(): 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.api_core.operation.Operation: @@ -1645,7 +1696,7 @@ def get_annotation_spec( 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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. @@ -1689,8 +1740,10 @@ def sample_get_annotation_spec(): 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.automl_v1.types.AnnotationSpec: @@ -1747,7 +1800,7 @@ def create_model( model: Optional[gca_model.Model] = 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]]] = (), ) -> operation.Operation: r"""Creates a model. Returns a Model in the [response][google.longrunning.Operation.response] field when it @@ -1805,8 +1858,10 @@ def sample_create_model(): 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.api_core.operation.Operation: @@ -1877,7 +1932,7 @@ def get_model( 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]]] = (), ) -> model.Model: r"""Gets a model. @@ -1919,8 +1974,10 @@ def sample_get_model(): 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.automl_v1.types.Model: @@ -1978,7 +2035,7 @@ def list_models( 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.ListModelsPager: r"""Lists models. @@ -2023,8 +2080,10 @@ def sample_list_models(): 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.automl_v1.services.auto_ml.pagers.ListModelsPager: @@ -2096,7 +2155,7 @@ def delete_model( 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]]] = (), ) -> operation.Operation: r"""Deletes a model. Returns ``google.protobuf.Empty`` in the [response][google.longrunning.Operation.response] field when it @@ -2147,8 +2206,10 @@ def sample_delete_model(): 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.api_core.operation.Operation: @@ -2225,7 +2286,7 @@ def update_model( 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]]] = (), ) -> gca_model.Model: r"""Updates a model. @@ -2275,8 +2336,10 @@ def sample_update_model(): 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.automl_v1.types.Model: @@ -2338,7 +2401,7 @@ def deploy_model( 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]]] = (), ) -> operation.Operation: r"""Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different @@ -2399,8 +2462,10 @@ def sample_deploy_model(): 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.api_core.operation.Operation: @@ -2476,7 +2541,7 @@ def undeploy_model( 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]]] = (), ) -> operation.Operation: r"""Undeploys a model. If the model is not deployed this method has no effect. @@ -2532,8 +2597,10 @@ def sample_undeploy_model(): 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.api_core.operation.Operation: @@ -2610,7 +2677,7 @@ def export_model( output_config: Optional[io.ModelExportOutputConfig] = 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]]] = (), ) -> operation.Operation: r"""Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able @@ -2678,8 +2745,10 @@ def sample_export_model(): 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.api_core.operation.Operation: @@ -2757,7 +2826,7 @@ def get_model_evaluation( 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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. @@ -2801,8 +2870,10 @@ def sample_get_model_evaluation(): 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.automl_v1.types.ModelEvaluation: @@ -2859,7 +2930,7 @@ def list_model_evaluations( filter: 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.ListModelEvaluationsPager: r"""Lists model evaluations. @@ -2926,8 +2997,10 @@ def sample_list_model_evaluations(): 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.automl_v1.services.auto_ml.pagers.ListModelEvaluationsPager: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/pagers.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/pagers.py index 1f3b1628ff8d..e03963510a25 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/pagers.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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 = service.ListDatasetsRequest(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 = service.ListDatasetsRequest(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 = service.ListModelsRequest(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 = service.ListModelsRequest(request) @@ -371,7 +379,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. @@ -385,8 +393,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 = service.ListModelEvaluationsRequest(request) @@ -445,7 +455,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. @@ -459,8 +469,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 = service.ListModelEvaluationsRequest(request) diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc.py index 0715c847081b..b95bc3906f7e 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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 @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1.types import annotation_spec from google.cloud.automl_v1.types import dataset @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, AutoMlTransport +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.automl.v1.AutoMl", + "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.automl.v1.AutoMl", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AutoMlGrpcTransport(AutoMlTransport): """gRPC backend transport for AutoMl. @@ -200,7 +281,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,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -288,7 +376,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/CreateDataset", request_serializer=service.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +400,7 @@ def get_dataset(self) -> Callable[[service.GetDatasetRequest], dataset.Dataset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetDataset", request_serializer=service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, @@ -338,7 +426,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListDatasets", request_serializer=service.ListDatasetsRequest.serialize, response_deserializer=service.ListDatasetsResponse.deserialize, @@ -364,7 +452,7 @@ def update_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dataset" not in self._stubs: - self._stubs["update_dataset"] = self.grpc_channel.unary_unary( + self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UpdateDataset", request_serializer=service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -394,7 +482,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeleteDataset", request_serializer=service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +517,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ImportData", request_serializer=service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -458,7 +546,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ExportData", request_serializer=service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -484,7 +572,7 @@ def get_annotation_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation_spec" not in self._stubs: - self._stubs["get_annotation_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetAnnotationSpec", request_serializer=service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, @@ -514,7 +602,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/CreateModel", request_serializer=service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -538,7 +626,7 @@ def get_model(self) -> Callable[[service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetModel", request_serializer=service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -564,7 +652,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListModels", request_serializer=service.ListModelsRequest.serialize, response_deserializer=service.ListModelsResponse.deserialize, @@ -593,7 +681,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeleteModel", request_serializer=service.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -617,7 +705,7 @@ def update_model(self) -> Callable[[service.UpdateModelRequest], gca_model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UpdateModel", request_serializer=service.UpdateModelRequest.serialize, response_deserializer=gca_model.Model.deserialize, @@ -656,7 +744,7 @@ def deploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_model" not in self._stubs: - self._stubs["deploy_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeployModel", request_serializer=service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -690,7 +778,7 @@ def undeploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_model" not in self._stubs: - self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UndeployModel", request_serializer=service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -723,7 +811,7 @@ def export_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_model" not in self._stubs: - self._stubs["export_model"] = self.grpc_channel.unary_unary( + self._stubs["export_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ExportModel", request_serializer=service.ExportModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -751,7 +839,7 @@ def get_model_evaluation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model_evaluation" not in self._stubs: - self._stubs["get_model_evaluation"] = self.grpc_channel.unary_unary( + self._stubs["get_model_evaluation"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetModelEvaluation", request_serializer=service.GetModelEvaluationRequest.serialize, response_deserializer=model_evaluation.ModelEvaluation.deserialize, @@ -779,7 +867,7 @@ def list_model_evaluations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_model_evaluations" not in self._stubs: - self._stubs["list_model_evaluations"] = self.grpc_channel.unary_unary( + self._stubs["list_model_evaluations"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListModelEvaluations", request_serializer=service.ListModelEvaluationsRequest.serialize, response_deserializer=service.ListModelEvaluationsResponse.deserialize, @@ -787,7 +875,7 @@ def list_model_evaluations( return self._stubs["list_model_evaluations"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py index f9172d736fb3..68562bb5abd5 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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 @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1.types import annotation_spec from google.cloud.automl_v1.types import dataset @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, AutoMlTransport from .grpc import AutoMlGrpcTransport +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.automl.v1.AutoMl", + "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.automl.v1.AutoMl", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AutoMlGrpcAsyncIOTransport(AutoMlTransport): """gRPC AsyncIO backend transport for AutoMl. @@ -247,10 +329,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 @@ -273,7 +358,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -298,7 +383,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/CreateDataset", request_serializer=service.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -324,7 +409,7 @@ def get_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetDataset", request_serializer=service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, @@ -352,7 +437,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListDatasets", request_serializer=service.ListDatasetsRequest.serialize, response_deserializer=service.ListDatasetsResponse.deserialize, @@ -378,7 +463,7 @@ def update_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dataset" not in self._stubs: - self._stubs["update_dataset"] = self.grpc_channel.unary_unary( + self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UpdateDataset", request_serializer=service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -408,7 +493,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeleteDataset", request_serializer=service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -443,7 +528,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ImportData", request_serializer=service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -472,7 +557,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ExportData", request_serializer=service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -500,7 +585,7 @@ def get_annotation_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation_spec" not in self._stubs: - self._stubs["get_annotation_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetAnnotationSpec", request_serializer=service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, @@ -530,7 +615,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/CreateModel", request_serializer=service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -554,7 +639,7 @@ def get_model(self) -> Callable[[service.GetModelRequest], Awaitable[model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetModel", request_serializer=service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -580,7 +665,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListModels", request_serializer=service.ListModelsRequest.serialize, response_deserializer=service.ListModelsResponse.deserialize, @@ -609,7 +694,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeleteModel", request_serializer=service.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -635,7 +720,7 @@ def update_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_model" not in self._stubs: - self._stubs["update_model"] = self.grpc_channel.unary_unary( + self._stubs["update_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UpdateModel", request_serializer=service.UpdateModelRequest.serialize, response_deserializer=gca_model.Model.deserialize, @@ -674,7 +759,7 @@ def deploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_model" not in self._stubs: - self._stubs["deploy_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/DeployModel", request_serializer=service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -708,7 +793,7 @@ def undeploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_model" not in self._stubs: - self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/UndeployModel", request_serializer=service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +826,7 @@ def export_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_model" not in self._stubs: - self._stubs["export_model"] = self.grpc_channel.unary_unary( + self._stubs["export_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ExportModel", request_serializer=service.ExportModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -769,7 +854,7 @@ def get_model_evaluation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model_evaluation" not in self._stubs: - self._stubs["get_model_evaluation"] = self.grpc_channel.unary_unary( + self._stubs["get_model_evaluation"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/GetModelEvaluation", request_serializer=service.GetModelEvaluationRequest.serialize, response_deserializer=model_evaluation.ModelEvaluation.deserialize, @@ -798,7 +883,7 @@ def list_model_evaluations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_model_evaluations" not in self._stubs: - self._stubs["list_model_evaluations"] = self.grpc_channel.unary_unary( + self._stubs["list_model_evaluations"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.AutoMl/ListModelEvaluations", request_serializer=service.ListModelEvaluationsRequest.serialize, response_deserializer=service.ListModelEvaluationsResponse.deserialize, @@ -996,7 +1081,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: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/rest.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/rest.py index bf07aec84ac8..e94c4df2a09e 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/transports/rest.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/auto_ml/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 @@ -43,6 +43,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, @@ -217,8 +225,10 @@ def post_update_model(self, response): """ def pre_create_dataset( - self, request: service.CreateDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_dataset Override in a subclass to manipulate the request or metadata @@ -238,8 +248,10 @@ def post_create_dataset( return response def pre_create_model( - self, request: service.CreateModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -259,8 +271,10 @@ def post_create_model( return response def pre_delete_dataset( - self, request: service.DeleteDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_dataset Override in a subclass to manipulate the request or metadata @@ -280,8 +294,10 @@ def post_delete_dataset( return response def pre_delete_model( - self, request: service.DeleteModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -301,8 +317,10 @@ def post_delete_model( return response def pre_deploy_model( - self, request: service.DeployModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeployModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeployModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeployModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for deploy_model Override in a subclass to manipulate the request or metadata @@ -322,8 +340,10 @@ def post_deploy_model( return response def pre_export_data( - self, request: service.ExportDataRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExportDataRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExportDataRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -343,8 +363,10 @@ def post_export_data( return response def pre_export_model( - self, request: service.ExportModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExportModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExportModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExportModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_model Override in a subclass to manipulate the request or metadata @@ -366,8 +388,10 @@ def post_export_model( def pre_get_annotation_spec( self, request: service.GetAnnotationSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetAnnotationSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetAnnotationSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_annotation_spec Override in a subclass to manipulate the request or metadata @@ -387,8 +411,10 @@ def post_get_annotation_spec( return response def pre_get_dataset( - self, request: service.GetDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_dataset Override in a subclass to manipulate the request or metadata @@ -406,8 +432,10 @@ def post_get_dataset(self, response: dataset.Dataset) -> dataset.Dataset: return response def pre_get_model( - self, request: service.GetModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -427,8 +455,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_get_model_evaluation( self, request: service.GetModelEvaluationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetModelEvaluationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetModelEvaluationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_model_evaluation Override in a subclass to manipulate the request or metadata @@ -448,8 +478,10 @@ def post_get_model_evaluation( return response def pre_import_data( - self, request: service.ImportDataRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ImportDataRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ImportDataRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -469,8 +501,10 @@ def post_import_data( return response def pre_list_datasets( - self, request: service.ListDatasetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListDatasetsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListDatasetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListDatasetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_datasets Override in a subclass to manipulate the request or metadata @@ -492,8 +526,10 @@ def post_list_datasets( def pre_list_model_evaluations( self, request: service.ListModelEvaluationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListModelEvaluationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListModelEvaluationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_model_evaluations Override in a subclass to manipulate the request or metadata @@ -513,8 +549,10 @@ def post_list_model_evaluations( return response def pre_list_models( - self, request: service.ListModelsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListModelsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListModelsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -534,8 +572,10 @@ def post_list_models( return response def pre_undeploy_model( - self, request: service.UndeployModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UndeployModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UndeployModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UndeployModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undeploy_model Override in a subclass to manipulate the request or metadata @@ -555,8 +595,10 @@ def post_undeploy_model( return response def pre_update_dataset( - self, request: service.UpdateDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_dataset Override in a subclass to manipulate the request or metadata @@ -574,8 +616,10 @@ def post_update_dataset(self, response: gca_dataset.Dataset) -> gca_dataset.Data return response def pre_update_model( - self, request: service.UpdateModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_model Override in a subclass to manipulate the request or metadata @@ -787,7 +831,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create dataset method over HTTP. @@ -798,8 +842,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: ~.operations_pb2.Operation: @@ -812,6 +858,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseCreateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseCreateDataset._get_transcoded_request( @@ -830,6 +877,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.automl_v1.AutoMlClient.CreateDataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "CreateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._CreateDataset._get_response( self._host, @@ -849,7 +923,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_dataset(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.automl_v1.AutoMlClient.create_dataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "CreateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateModel(_BaseAutoMlRestTransport._BaseCreateModel, AutoMlRestStub): @@ -885,7 +981,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -896,8 +992,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: ~.operations_pb2.Operation: @@ -908,6 +1006,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseCreateModel._get_http_options() + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseCreateModel._get_transcoded_request( @@ -926,6 +1025,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.automl_v1.AutoMlClient.CreateModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._CreateModel._get_response( self._host, @@ -945,7 +1071,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.automl_v1.AutoMlClient.create_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDataset(_BaseAutoMlRestTransport._BaseDeleteDataset, AutoMlRestStub): @@ -980,7 +1128,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete dataset method over HTTP. @@ -991,8 +1139,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: ~.operations_pb2.Operation: @@ -1005,6 +1155,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseDeleteDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeleteDataset._get_transcoded_request( @@ -1019,6 +1170,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.automl_v1.AutoMlClient.DeleteDataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeleteDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeleteDataset._get_response( self._host, @@ -1037,7 +1215,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_dataset(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.automl_v1.AutoMlClient.delete_dataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeleteDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteModel(_BaseAutoMlRestTransport._BaseDeleteModel, AutoMlRestStub): @@ -1072,7 +1272,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete model method over HTTP. @@ -1083,8 +1283,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: ~.operations_pb2.Operation: @@ -1095,6 +1297,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseDeleteModel._get_http_options() + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeleteModel._get_transcoded_request( @@ -1109,6 +1312,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.automl_v1.AutoMlClient.DeleteModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeleteModel._get_response( self._host, @@ -1127,7 +1357,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_model(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.automl_v1.AutoMlClient.delete_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeleteModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployModel(_BaseAutoMlRestTransport._BaseDeployModel, AutoMlRestStub): @@ -1163,7 +1415,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]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy model method over HTTP. @@ -1174,8 +1426,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: ~.operations_pb2.Operation: @@ -1186,6 +1440,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseDeployModel._get_http_options() + request, metadata = self._interceptor.pre_deploy_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeployModel._get_transcoded_request( @@ -1204,6 +1459,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.automl_v1.AutoMlClient.DeployModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeployModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeployModel._get_response( self._host, @@ -1223,7 +1505,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_model(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.automl_v1.AutoMlClient.deploy_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "DeployModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData(_BaseAutoMlRestTransport._BaseExportData, AutoMlRestStub): @@ -1259,7 +1563,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export data method over HTTP. @@ -1270,8 +1574,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: ~.operations_pb2.Operation: @@ -1282,6 +1588,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseExportData._get_http_options() + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseExportData._get_transcoded_request( @@ -1300,6 +1607,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.automl_v1.AutoMlClient.ExportData", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ExportData._get_response( self._host, @@ -1319,7 +1653,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_data(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.automl_v1.AutoMlClient.export_data", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportModel(_BaseAutoMlRestTransport._BaseExportModel, AutoMlRestStub): @@ -1355,7 +1711,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export model method over HTTP. @@ -1368,8 +1724,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: ~.operations_pb2.Operation: @@ -1380,6 +1738,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseExportModel._get_http_options() + request, metadata = self._interceptor.pre_export_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseExportModel._get_transcoded_request( @@ -1398,6 +1757,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.automl_v1.AutoMlClient.ExportModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ExportModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ExportModel._get_response( self._host, @@ -1417,7 +1803,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_model(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.automl_v1.AutoMlClient.export_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ExportModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotationSpec( @@ -1454,7 +1862,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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Call the get annotation spec method over HTTP. @@ -1465,8 +1873,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: ~.annotation_spec.AnnotationSpec: @@ -1476,6 +1886,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetAnnotationSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation_spec( request, metadata ) @@ -1492,6 +1903,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.automl_v1.AutoMlClient.GetAnnotationSpec", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetAnnotationSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetAnnotationSpec._get_response( self._host, @@ -1512,7 +1950,29 @@ def __call__( pb_resp = annotation_spec.AnnotationSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = annotation_spec.AnnotationSpec.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.automl_v1.AutoMlClient.get_annotation_spec", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetAnnotationSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataset(_BaseAutoMlRestTransport._BaseGetDataset, AutoMlRestStub): @@ -1547,7 +2007,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]]] = (), ) -> dataset.Dataset: r"""Call the get dataset method over HTTP. @@ -1558,8 +2018,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: ~.dataset.Dataset: @@ -1571,6 +2033,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseGetDataset._get_http_options() + request, metadata = self._interceptor.pre_get_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetDataset._get_transcoded_request( @@ -1585,6 +2048,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.automl_v1.AutoMlClient.GetDataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetDataset._get_response( self._host, @@ -1605,7 +2095,29 @@ def __call__( pb_resp = dataset.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = dataset.Dataset.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.automl_v1.AutoMlClient.get_dataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModel(_BaseAutoMlRestTransport._BaseGetModel, AutoMlRestStub): @@ -1640,7 +2152,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]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -1651,8 +2163,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: ~.model.Model: @@ -1662,6 +2176,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseGetModel._get_http_options() + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetModel._get_transcoded_request( @@ -1676,6 +2191,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.automl_v1.AutoMlClient.GetModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetModel._get_response( self._host, @@ -1696,7 +2238,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.automl_v1.AutoMlClient.get_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModelEvaluation( @@ -1733,7 +2297,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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Call the get model evaluation method over HTTP. @@ -1744,8 +2308,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: ~.model_evaluation.ModelEvaluation: @@ -1755,6 +2321,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetModelEvaluation._get_http_options() ) + request, metadata = self._interceptor.pre_get_model_evaluation( request, metadata ) @@ -1769,6 +2336,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.automl_v1.AutoMlClient.GetModelEvaluation", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetModelEvaluation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetModelEvaluation._get_response( self._host, @@ -1789,7 +2383,31 @@ def __call__( pb_resp = model_evaluation.ModelEvaluation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model_evaluation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_evaluation.ModelEvaluation.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.automl_v1.AutoMlClient.get_model_evaluation", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "GetModelEvaluation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData(_BaseAutoMlRestTransport._BaseImportData, AutoMlRestStub): @@ -1825,7 +2443,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import data method over HTTP. @@ -1836,8 +2454,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: ~.operations_pb2.Operation: @@ -1848,6 +2468,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseImportData._get_http_options() + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseImportData._get_transcoded_request( @@ -1866,6 +2487,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.automl_v1.AutoMlClient.ImportData", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ImportData._get_response( self._host, @@ -1885,7 +2533,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_data(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.automl_v1.AutoMlClient.import_data", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatasets(_BaseAutoMlRestTransport._BaseListDatasets, AutoMlRestStub): @@ -1920,7 +2590,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]]] = (), ) -> service.ListDatasetsResponse: r"""Call the list datasets method over HTTP. @@ -1931,8 +2601,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: ~.service.ListDatasetsResponse: @@ -1944,6 +2616,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_datasets(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseListDatasets._get_transcoded_request( @@ -1958,6 +2631,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.automl_v1.AutoMlClient.ListDatasets", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListDatasets._get_response( self._host, @@ -1978,7 +2678,29 @@ def __call__( pb_resp = service.ListDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListDatasetsResponse.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.automl_v1.AutoMlClient.list_datasets", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModelEvaluations( @@ -2015,7 +2737,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]]] = (), ) -> service.ListModelEvaluationsResponse: r"""Call the list model evaluations method over HTTP. @@ -2026,8 +2748,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: ~.service.ListModelEvaluationsResponse: @@ -2039,6 +2763,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListModelEvaluations._get_http_options() ) + request, metadata = self._interceptor.pre_list_model_evaluations( request, metadata ) @@ -2051,6 +2776,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 = 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.automl_v1.AutoMlClient.ListModelEvaluations", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListModelEvaluations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListModelEvaluations._get_response( self._host, @@ -2071,7 +2823,31 @@ def __call__( pb_resp = service.ListModelEvaluationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_model_evaluations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListModelEvaluationsResponse.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.automl_v1.AutoMlClient.list_model_evaluations", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListModelEvaluations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels(_BaseAutoMlRestTransport._BaseListModels, AutoMlRestStub): @@ -2106,7 +2882,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]]] = (), ) -> service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -2117,8 +2893,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: ~.service.ListModelsResponse: @@ -2128,6 +2906,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseListModels._get_http_options() + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseListModels._get_transcoded_request( @@ -2142,6 +2921,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.automl_v1.AutoMlClient.ListModels", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListModels._get_response( self._host, @@ -2162,7 +2968,29 @@ def __call__( pb_resp = service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListModelsResponse.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.automl_v1.AutoMlClient.list_models", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployModel(_BaseAutoMlRestTransport._BaseUndeployModel, AutoMlRestStub): @@ -2198,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]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy model method over HTTP. @@ -2209,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: ~.operations_pb2.Operation: @@ -2223,6 +3053,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUndeployModel._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseUndeployModel._get_transcoded_request( @@ -2241,6 +3072,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.automl_v1.AutoMlClient.UndeployModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UndeployModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UndeployModel._get_response( self._host, @@ -2260,7 +3118,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_model(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.automl_v1.AutoMlClient.undeploy_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UndeployModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataset(_BaseAutoMlRestTransport._BaseUpdateDataset, AutoMlRestStub): @@ -2296,7 +3176,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]]] = (), ) -> gca_dataset.Dataset: r"""Call the update dataset method over HTTP. @@ -2307,8 +3187,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: ~.gca_dataset.Dataset: @@ -2322,6 +3204,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUpdateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_update_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseUpdateDataset._get_transcoded_request( @@ -2340,6 +3223,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.automl_v1.AutoMlClient.UpdateDataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UpdateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UpdateDataset._get_response( self._host, @@ -2361,7 +3271,29 @@ def __call__( pb_resp = gca_dataset.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_dataset.Dataset.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.automl_v1.AutoMlClient.update_dataset", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UpdateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateModel(_BaseAutoMlRestTransport._BaseUpdateModel, AutoMlRestStub): @@ -2397,7 +3329,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]]] = (), ) -> gca_model.Model: r"""Call the update model method over HTTP. @@ -2408,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: ~.gca_model.Model: @@ -2419,6 +3353,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseUpdateModel._get_http_options() + request, metadata = self._interceptor.pre_update_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseUpdateModel._get_transcoded_request( @@ -2437,6 +3372,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.automl_v1.AutoMlClient.UpdateModel", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UpdateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UpdateModel._get_response( self._host, @@ -2458,7 +3420,29 @@ def __call__( pb_resp = gca_model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_model.Model.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.automl_v1.AutoMlClient.update_model", + extra={ + "serviceName": "google.cloud.automl.v1.AutoMl", + "rpcName": "UpdateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/async_client.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/async_client.py index d82bdf58cd78..424d228937c1 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/async_client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """AutoML Prediction API. @@ -270,6 +280,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.automl_v1.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "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.automl.v1.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -279,7 +311,7 @@ async def predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> prediction_service.PredictResponse: r"""Perform an online prediction. The prediction result is directly returned in the response. Available for following ML scenarios, @@ -406,8 +438,10 @@ async def sample_predict(): 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.automl_v1.types.PredictResponse: @@ -474,7 +508,7 @@ async def batch_predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], @@ -653,8 +687,10 @@ async def sample_batch_predict(): 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.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/client.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/client.py index ba4d427b59db..0ca9e7b01946 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -594,6 +604,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( @@ -660,6 +674,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.automl_v1.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "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.automl.v1.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -669,7 +706,7 @@ def predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> prediction_service.PredictResponse: r"""Perform an online prediction. The prediction result is directly returned in the response. Available for following ML scenarios, @@ -796,8 +833,10 @@ def sample_predict(): 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.automl_v1.types.PredictResponse: @@ -862,7 +901,7 @@ def batch_predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> operation.Operation: r"""Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], @@ -1041,8 +1080,10 @@ def sample_batch_predict(): 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.api_core.operation.Operation: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc.py index 1db17b092455..0ca68c269136 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.automl.v1.PredictionService", + "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.automl.v1.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -310,7 +398,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -355,7 +443,7 @@ def batch_predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_predict" not in self._stubs: - self._stubs["batch_predict"] = self.grpc_channel.unary_unary( + self._stubs["batch_predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.PredictionService/BatchPredict", request_serializer=prediction_service.BatchPredictRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -363,7 +451,7 @@ def batch_predict( return self._stubs["batch_predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py index 7141a3b758f4..64d0a8d8fcad 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.automl.v1.PredictionService", + "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.automl.v1.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -321,7 +406,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -368,7 +453,7 @@ def batch_predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_predict" not in self._stubs: - self._stubs["batch_predict"] = self.grpc_channel.unary_unary( + self._stubs["batch_predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1.PredictionService/BatchPredict", request_serializer=prediction_service.BatchPredictRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -396,7 +481,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: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/rest.py b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/rest.py index c6b8978f3d62..5b8981acfe35 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/services/prediction_service/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 @@ -38,6 +38,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, @@ -86,8 +94,10 @@ def post_predict(self, response): def pre_batch_predict( self, request: prediction_service.BatchPredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.BatchPredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.BatchPredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_predict Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_batch_predict( def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -315,7 +327,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch predict method over HTTP. @@ -326,8 +338,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: ~.operations_pb2.Operation: @@ -340,6 +354,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseBatchPredict._get_http_options() ) + request, metadata = self._interceptor.pre_batch_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseBatchPredict._get_transcoded_request( http_options, request @@ -354,6 +369,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.automl_v1.PredictionServiceClient.BatchPredict", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "rpcName": "BatchPredict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._BatchPredict._get_response( self._host, @@ -373,7 +415,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_predict(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.automl_v1.PredictionServiceClient.batch_predict", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "rpcName": "BatchPredict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Predict( @@ -411,7 +475,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]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -422,8 +486,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: ~.prediction_service.PredictResponse: @@ -435,6 +501,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -453,6 +520,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.automl_v1.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -474,7 +568,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.automl_v1.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.automl.v1.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-automl/google/cloud/automl_v1/types/io.py b/packages/google-cloud-automl/google/cloud/automl_v1/types/io.py index 5a9d6762302f..8b14c11e07d4 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1/types/io.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1/types/io.py @@ -55,13 +55,11 @@ class InputConfig(proto.Message): with non-terminal symbols defined near the end of this comment. The formats are: - .. raw:: html - -

AutoML Vision

+ AutoML Vision + ^^^^^^^^^^^^^ - .. raw:: html - -
Classification
+ Classification + '''''''''''''' See `Preparing your training data `__ for @@ -102,12 +100,12 @@ class InputConfig(proto.Message): UNASSIGNED,gs://folder/image3.jpg,daisy UNASSIGNED,gs://folder/image4.jpg - .. raw:: html + Object Detection + '''''''''''''''' -
Object Detection
- See [Preparing your training - data](https://cloud.google.com/vision/automl/object-detection/docs/prepare) - for more information. + See `Preparing your training + data `__ + for more information. A CSV file(s) with each line in format: @@ -153,13 +151,11 @@ class InputConfig(proto.Message):
- .. raw:: html - -

AutoML Video Intelligence

+ AutoML Video Intelligence + ^^^^^^^^^^^^^^^^^^^^^^^^^ - .. raw:: html - -
Classification
+ Classification + '''''''''''''' See `Preparing your training data `__ @@ -209,9 +205,8 @@ class InputConfig(proto.Message): gs://folder/vid2.avi,car,0,60.5 gs://folder/vid3.avi,,, - .. raw:: html - -
Object Tracking
+ Object Tracking + ''''''''''''''' See `Preparing your training data `__ @@ -274,18 +269,11 @@ class InputConfig(proto.Message): gs://folder/video2.avi,car,1,0,.1,.9,,,.9,.1,, gs://folder/video2.avi,,,,,,,,,,, - .. raw:: html - -
-
- - .. raw:: html - -

AutoML Natural Language

+ AutoML Natural Language + ^^^^^^^^^^^^^^^^^^^^^^^ - .. raw:: html - -
Entity Extraction
+ Entity Extraction + ''''''''''''''''' See `Preparing your training data `__ for @@ -479,9 +467,8 @@ class InputConfig(proto.Message): }, ], - .. raw:: html - -
Classification
+ Classification + '''''''''''''' See `Preparing your training data `__ @@ -533,9 +520,8 @@ class InputConfig(proto.Message): TEST,gs://folder/document.pdf VALIDATE,gs://folder/text_files.zip,BadFood - .. raw:: html - -
Sentiment Analysis
+ Sentiment Analysis + '''''''''''''''''' See `Preparing your training data `__ @@ -598,15 +584,8 @@ class InputConfig(proto.Message): TEST,gs://folder/document.pdf VALIDATE,gs://folder/text_files.zip,2 - .. raw:: html - -
-
- - .. raw:: html - -

AutoML Tables

+ AutoML Tables + ^^^^^^^^^^^^^ See `Preparing your training data `__ for @@ -647,11 +626,6 @@ class InputConfig(proto.Message): and between 1000 and 100,000,000 rows, inclusive. There are at most 5 import data running in parallel. - .. raw:: html - -
-
- **Input field definitions:** ``ML_USE`` : ("TRAIN" \| "VALIDATE" \| "TEST" \| "UNASSIGNED") @@ -728,9 +702,8 @@ class InputConfig(proto.Message): semantic of the imported data, any string must be up to 25000 characters long. - .. raw:: html - -

AutoML Tables

+ AutoML Tables + ^^^^^^^^^^^^^ ``schema_inference_version`` : (integer) This value must be supplied. The version of the algorithm to use for the @@ -763,10 +736,11 @@ class BatchPredictInputConfig(proto.Message): with non-terminal symbols defined near the end of this comment. The formats are: - .. raw:: html + AutoML Vision + ^^^^^^^^^^^^^ -

AutoML Vision

-
Classification
+ Classification + '''''''''''''' One or more CSV files where each line is a single column: @@ -786,9 +760,8 @@ class BatchPredictInputConfig(proto.Message): gs://folder/image2.gif gs://folder/image3.png - .. raw:: html - -
Object Detection
+ Object Detection + '''''''''''''''' One or more CSV files where each line is a single column: @@ -808,15 +781,11 @@ class BatchPredictInputConfig(proto.Message): gs://folder/image2.gif gs://folder/image3.png - .. raw:: html - -
-
- - .. raw:: html + AutoML Video Intelligence + ^^^^^^^^^^^^^^^^^^^^^^^^^ -

AutoML Video Intelligence

-
Classification
+ Classification + '''''''''''''' One or more CSV files where each line is a single column: @@ -839,9 +808,8 @@ class BatchPredictInputConfig(proto.Message): gs://folder/video1.mp4,20,60 gs://folder/vid2.mov,0,inf - .. raw:: html - -
Object Tracking
+ Object Tracking + ''''''''''''''' One or more CSV files where each line is a single column: @@ -864,15 +832,11 @@ class BatchPredictInputConfig(proto.Message): gs://folder/video1.mp4,20,60 gs://folder/vid2.mov,0,inf - .. raw:: html - -
-
- - .. raw:: html + AutoML Natural Language + ^^^^^^^^^^^^^^^^^^^^^^^ -

AutoML Natural Language

-
Classification
+ Classification + '''''''''''''' One or more CSV files where each line is a single column: @@ -893,10 +857,10 @@ class BatchPredictInputConfig(proto.Message): gs://folder/text2.pdf gs://folder/text3.tif - .. raw:: html + Sentiment Analysis + '''''''''''''''''' -
Sentiment Analysis
- One or more CSV files where each line is a single column: + One or more CSV files where each line is a single column: :: @@ -915,9 +879,8 @@ class BatchPredictInputConfig(proto.Message): gs://folder/text2.pdf gs://folder/text3.tif - .. raw:: html - -
Entity Extraction
+ Entity Extraction + ''''''''''''''''' One or more JSONL (JSON Lines) files that either provide inline text or documents. You can only use one format, either inline text or @@ -992,15 +955,8 @@ class BatchPredictInputConfig(proto.Message): } } - .. raw:: html - -
-
- - .. raw:: html - -

AutoML Tables

+ AutoML Tables + ^^^^^^^^^^^^^ See `Preparing your training data `__ @@ -1049,11 +1005,6 @@ class BatchPredictInputConfig(proto.Message): column spec's data types. Prediction on all the rows of the table will be attempted. - .. raw:: html - -
-
- **Input field definitions:** ``GCS_FILE_PATH`` : The path to a file on Google Cloud Storage. For diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py index 2523dfbe9e23..558c8aab67c5 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/async_client.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/async_client.py index 665e597dd641..0513f1f38e17 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/async_client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/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, @@ -78,6 +79,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AutoMlTransport from .transports.grpc_asyncio import AutoMlGrpcAsyncIOTransport +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 AutoMlAsyncClient: """AutoML Server API. @@ -298,6 +308,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.automl_v1beta1.AutoMlAsyncClient`.", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "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.automl.v1beta1.AutoMl", + "credentialsType": None, + }, + ) + async def create_dataset( self, request: Optional[Union[service.CreateDatasetRequest, dict]] = None, @@ -306,7 +338,7 @@ async def create_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> gca_dataset.Dataset: r"""Creates a dataset. @@ -360,8 +392,10 @@ async def sample_create_dataset(): 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.automl_v1beta1.types.Dataset: @@ -426,7 +460,7 @@ async def get_dataset( 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]]] = (), ) -> dataset.Dataset: r"""Gets a dataset. @@ -470,8 +504,10 @@ async def sample_get_dataset(): 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.automl_v1beta1.types.Dataset: @@ -534,7 +570,7 @@ async def list_datasets( 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.ListDatasetsAsyncPager: r"""Lists datasets in a project. @@ -579,8 +615,10 @@ async def sample_list_datasets(): 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.automl_v1beta1.services.auto_ml.pagers.ListDatasetsAsyncPager: @@ -655,7 +693,7 @@ async def update_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> gca_dataset.Dataset: r"""Updates a dataset. @@ -703,8 +741,10 @@ async def sample_update_dataset(): 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.automl_v1beta1.types.Dataset: @@ -769,7 +809,7 @@ async def delete_dataset( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a dataset and all of its contents. Returns empty response in the @@ -821,8 +861,10 @@ async def sample_delete_dataset(): 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.api_core.operation_async.AsyncOperation: @@ -902,7 +944,7 @@ async def import_data( input_config: Optional[io.InputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Imports data into a dataset. For Tables this method can only be called on an empty Dataset. @@ -968,8 +1010,10 @@ async def sample_import_data(): 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.api_core.operation_async.AsyncOperation: @@ -1051,7 +1095,7 @@ async def export_data( output_config: Optional[io.OutputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports dataset's data to the provided output location. Returns an empty response in the @@ -1109,8 +1153,10 @@ async def sample_export_data(): 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.api_core.operation_async.AsyncOperation: @@ -1191,7 +1237,7 @@ async def get_annotation_spec( 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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. @@ -1235,8 +1281,10 @@ async def sample_get_annotation_spec(): 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.automl_v1beta1.types.AnnotationSpec: @@ -1295,7 +1343,7 @@ async def get_table_spec( 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]]] = (), ) -> table_spec.TableSpec: r"""Gets a table spec. @@ -1339,8 +1387,10 @@ async def sample_get_table_spec(): 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.automl_v1beta1.types.TableSpec: @@ -1409,7 +1459,7 @@ async def list_table_specs( 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.ListTableSpecsAsyncPager: r"""Lists table specs in a dataset. @@ -1454,8 +1504,10 @@ async def sample_list_table_specs(): 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.automl_v1beta1.services.auto_ml.pagers.ListTableSpecsAsyncPager: @@ -1530,7 +1582,7 @@ async def update_table_spec( table_spec: Optional[gca_table_spec.TableSpec] = 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]]] = (), ) -> gca_table_spec.TableSpec: r"""Updates a table spec. @@ -1573,8 +1625,10 @@ async def sample_update_table_spec(): 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.automl_v1beta1.types.TableSpec: @@ -1645,7 +1699,7 @@ async def get_column_spec( 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]]] = (), ) -> column_spec.ColumnSpec: r"""Gets a column spec. @@ -1689,8 +1743,10 @@ async def sample_get_column_spec(): 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.automl_v1beta1.types.ColumnSpec: @@ -1751,7 +1807,7 @@ async def list_column_specs( 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.ListColumnSpecsAsyncPager: r"""Lists column specs in a table spec. @@ -1796,8 +1852,10 @@ async def sample_list_column_specs(): 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.automl_v1beta1.services.auto_ml.pagers.ListColumnSpecsAsyncPager: @@ -1872,7 +1930,7 @@ async def update_column_spec( column_spec: Optional[gca_column_spec.ColumnSpec] = 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]]] = (), ) -> gca_column_spec.ColumnSpec: r"""Updates a column spec. @@ -1915,8 +1973,10 @@ async def sample_update_column_spec(): 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.automl_v1beta1.types.ColumnSpec: @@ -1980,7 +2040,7 @@ async def create_model( model: Optional[gca_model.Model] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a model. Returns a Model in the [response][google.longrunning.Operation.response] field when it @@ -2038,8 +2098,10 @@ async def sample_create_model(): 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.api_core.operation_async.AsyncOperation: @@ -2113,7 +2175,7 @@ async def get_model( 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]]] = (), ) -> model.Model: r"""Gets a model. @@ -2155,8 +2217,10 @@ async def sample_get_model(): 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.automl_v1beta1.types.Model: @@ -2217,7 +2281,7 @@ async def list_models( 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.ListModelsAsyncPager: r"""Lists models. @@ -2262,8 +2326,10 @@ async def sample_list_models(): 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.automl_v1beta1.services.auto_ml.pagers.ListModelsAsyncPager: @@ -2338,7 +2404,7 @@ async def delete_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a model. Returns ``google.protobuf.Empty`` in the [response][google.longrunning.Operation.response] field when it @@ -2389,8 +2455,10 @@ async def sample_delete_model(): 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.api_core.operation_async.AsyncOperation: @@ -2469,7 +2537,7 @@ async def deploy_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different @@ -2531,8 +2599,10 @@ async def sample_deploy_model(): 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.api_core.operation_async.AsyncOperation: @@ -2611,7 +2681,7 @@ async def undeploy_model( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Undeploys a model. If the model is not deployed this method has no effect. @@ -2667,8 +2737,10 @@ async def sample_undeploy_model(): 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.api_core.operation_async.AsyncOperation: @@ -2748,7 +2820,7 @@ async def export_model( output_config: Optional[io.ModelExportOutputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able @@ -2813,8 +2885,10 @@ async def sample_export_model(): 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.api_core.operation_async.AsyncOperation: @@ -2896,7 +2970,7 @@ async def export_evaluated_examples( output_config: Optional[io.ExportEvaluatedExamplesOutputConfig] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports examples on which the model was evaluated (i.e. which were in the TEST set of the dataset the model was created from), @@ -2966,8 +3040,10 @@ async def sample_export_evaluated_examples(): 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.api_core.operation_async.AsyncOperation: @@ -3048,7 +3124,7 @@ async def get_model_evaluation( 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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. @@ -3092,8 +3168,10 @@ async def sample_get_model_evaluation(): 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.automl_v1beta1.types.ModelEvaluation: @@ -3152,7 +3230,7 @@ async def list_model_evaluations( 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.ListModelEvaluationsAsyncPager: r"""Lists model evaluations. @@ -3200,8 +3278,10 @@ async def sample_list_model_evaluations(): 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.automl_v1beta1.services.auto_ml.pagers.ListModelEvaluationsAsyncPager: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/client.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/client.py index 06f15fd1ec6f..779ea8ffc620 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -740,6 +750,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( @@ -802,6 +816,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.automl_v1beta1.AutoMlClient`.", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "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.automl.v1beta1.AutoMl", + "credentialsType": None, + }, + ) + def create_dataset( self, request: Optional[Union[service.CreateDatasetRequest, dict]] = None, @@ -810,7 +847,7 @@ def create_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> gca_dataset.Dataset: r"""Creates a dataset. @@ -864,8 +901,10 @@ def sample_create_dataset(): 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.automl_v1beta1.types.Dataset: @@ -927,7 +966,7 @@ def get_dataset( 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]]] = (), ) -> dataset.Dataset: r"""Gets a dataset. @@ -971,8 +1010,10 @@ def sample_get_dataset(): 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.automl_v1beta1.types.Dataset: @@ -1032,7 +1073,7 @@ def list_datasets( 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.ListDatasetsPager: r"""Lists datasets in a project. @@ -1077,8 +1118,10 @@ def sample_list_datasets(): 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.automl_v1beta1.services.auto_ml.pagers.ListDatasetsPager: @@ -1150,7 +1193,7 @@ def update_dataset( dataset: Optional[gca_dataset.Dataset] = 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]]] = (), ) -> gca_dataset.Dataset: r"""Updates a dataset. @@ -1198,8 +1241,10 @@ def sample_update_dataset(): 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.automl_v1beta1.types.Dataset: @@ -1261,7 +1306,7 @@ def delete_dataset( 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]]] = (), ) -> operation.Operation: r"""Deletes a dataset and all of its contents. Returns empty response in the @@ -1313,8 +1358,10 @@ def sample_delete_dataset(): 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.api_core.operation.Operation: @@ -1391,7 +1438,7 @@ def import_data( input_config: Optional[io.InputConfig] = 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]]] = (), ) -> operation.Operation: r"""Imports data into a dataset. For Tables this method can only be called on an empty Dataset. @@ -1457,8 +1504,10 @@ def sample_import_data(): 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.api_core.operation.Operation: @@ -1537,7 +1586,7 @@ def export_data( output_config: Optional[io.OutputConfig] = 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]]] = (), ) -> operation.Operation: r"""Exports dataset's data to the provided output location. Returns an empty response in the @@ -1595,8 +1644,10 @@ def sample_export_data(): 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.api_core.operation.Operation: @@ -1674,7 +1725,7 @@ def get_annotation_spec( 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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. @@ -1718,8 +1769,10 @@ def sample_get_annotation_spec(): 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.automl_v1beta1.types.AnnotationSpec: @@ -1775,7 +1828,7 @@ def get_table_spec( 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]]] = (), ) -> table_spec.TableSpec: r"""Gets a table spec. @@ -1819,8 +1872,10 @@ def sample_get_table_spec(): 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.automl_v1beta1.types.TableSpec: @@ -1886,7 +1941,7 @@ def list_table_specs( 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.ListTableSpecsPager: r"""Lists table specs in a dataset. @@ -1931,8 +1986,10 @@ def sample_list_table_specs(): 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.automl_v1beta1.services.auto_ml.pagers.ListTableSpecsPager: @@ -2004,7 +2061,7 @@ def update_table_spec( table_spec: Optional[gca_table_spec.TableSpec] = 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]]] = (), ) -> gca_table_spec.TableSpec: r"""Updates a table spec. @@ -2047,8 +2104,10 @@ def sample_update_table_spec(): 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.automl_v1beta1.types.TableSpec: @@ -2116,7 +2175,7 @@ def get_column_spec( 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]]] = (), ) -> column_spec.ColumnSpec: r"""Gets a column spec. @@ -2160,8 +2219,10 @@ def sample_get_column_spec(): 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.automl_v1beta1.types.ColumnSpec: @@ -2219,7 +2280,7 @@ def list_column_specs( 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.ListColumnSpecsPager: r"""Lists column specs in a table spec. @@ -2264,8 +2325,10 @@ def sample_list_column_specs(): 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.automl_v1beta1.services.auto_ml.pagers.ListColumnSpecsPager: @@ -2337,7 +2400,7 @@ def update_column_spec( column_spec: Optional[gca_column_spec.ColumnSpec] = 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]]] = (), ) -> gca_column_spec.ColumnSpec: r"""Updates a column spec. @@ -2380,8 +2443,10 @@ def sample_update_column_spec(): 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.automl_v1beta1.types.ColumnSpec: @@ -2442,7 +2507,7 @@ def create_model( model: Optional[gca_model.Model] = 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]]] = (), ) -> operation.Operation: r"""Creates a model. Returns a Model in the [response][google.longrunning.Operation.response] field when it @@ -2500,8 +2565,10 @@ def sample_create_model(): 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.api_core.operation.Operation: @@ -2572,7 +2639,7 @@ def get_model( 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]]] = (), ) -> model.Model: r"""Gets a model. @@ -2614,8 +2681,10 @@ def sample_get_model(): 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.automl_v1beta1.types.Model: @@ -2673,7 +2742,7 @@ def list_models( 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.ListModelsPager: r"""Lists models. @@ -2718,8 +2787,10 @@ def sample_list_models(): 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.automl_v1beta1.services.auto_ml.pagers.ListModelsPager: @@ -2791,7 +2862,7 @@ def delete_model( 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]]] = (), ) -> operation.Operation: r"""Deletes a model. Returns ``google.protobuf.Empty`` in the [response][google.longrunning.Operation.response] field when it @@ -2842,8 +2913,10 @@ def sample_delete_model(): 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.api_core.operation.Operation: @@ -2919,7 +2992,7 @@ def deploy_model( 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]]] = (), ) -> operation.Operation: r"""Deploys a model. If a model is already deployed, deploying it with the same parameters has no effect. Deploying with different @@ -2981,8 +3054,10 @@ def sample_deploy_model(): 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.api_core.operation.Operation: @@ -3058,7 +3133,7 @@ def undeploy_model( 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]]] = (), ) -> operation.Operation: r"""Undeploys a model. If the model is not deployed this method has no effect. @@ -3114,8 +3189,10 @@ def sample_undeploy_model(): 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.api_core.operation.Operation: @@ -3192,7 +3269,7 @@ def export_model( output_config: Optional[io.ModelExportOutputConfig] = 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]]] = (), ) -> operation.Operation: r"""Exports a trained, "export-able", model to a user specified Google Cloud Storage location. A model is considered export-able @@ -3257,8 +3334,10 @@ def sample_export_model(): 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.api_core.operation.Operation: @@ -3337,7 +3416,7 @@ def export_evaluated_examples( output_config: Optional[io.ExportEvaluatedExamplesOutputConfig] = 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]]] = (), ) -> operation.Operation: r"""Exports examples on which the model was evaluated (i.e. which were in the TEST set of the dataset the model was created from), @@ -3407,8 +3486,10 @@ def sample_export_evaluated_examples(): 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.api_core.operation.Operation: @@ -3488,7 +3569,7 @@ def get_model_evaluation( 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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. @@ -3532,8 +3613,10 @@ def sample_get_model_evaluation(): 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.automl_v1beta1.types.ModelEvaluation: @@ -3589,7 +3672,7 @@ def list_model_evaluations( 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.ListModelEvaluationsPager: r"""Lists model evaluations. @@ -3637,8 +3720,10 @@ def sample_list_model_evaluations(): 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.automl_v1beta1.services.auto_ml.pagers.ListModelEvaluationsPager: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/pagers.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/pagers.py index 115fe7f20cbc..36de7fbf3906 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/pagers.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/pagers.py @@ -74,7 +74,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. @@ -88,8 +88,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 = service.ListDatasetsRequest(request) @@ -148,7 +150,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. @@ -162,8 +164,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 = service.ListDatasetsRequest(request) @@ -226,7 +230,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. @@ -240,8 +244,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 = service.ListTableSpecsRequest(request) @@ -300,7 +306,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. @@ -314,8 +320,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 = service.ListTableSpecsRequest(request) @@ -378,7 +386,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. @@ -392,8 +400,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 = service.ListColumnSpecsRequest(request) @@ -452,7 +462,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. @@ -466,8 +476,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 = service.ListColumnSpecsRequest(request) @@ -530,7 +542,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. @@ -544,8 +556,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 = service.ListModelsRequest(request) @@ -604,7 +618,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. @@ -618,8 +632,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 = service.ListModelsRequest(request) @@ -682,7 +698,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. @@ -696,8 +712,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 = service.ListModelEvaluationsRequest(request) @@ -756,7 +774,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. @@ -770,8 +788,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 = service.ListModelEvaluationsRequest(request) diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py index bedc251aea3a..672e5ce0c5f3 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/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 @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1beta1.types import annotation_spec from google.cloud.automl_v1beta1.types import column_spec @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, AutoMlTransport +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.automl.v1beta1.AutoMl", + "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.automl.v1beta1.AutoMl", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AutoMlGrpcTransport(AutoMlTransport): """gRPC backend transport for AutoMl. @@ -202,7 +283,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 @@ -266,7 +352,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -290,7 +378,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/CreateDataset", request_serializer=service.CreateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -314,7 +402,7 @@ def get_dataset(self) -> Callable[[service.GetDatasetRequest], dataset.Dataset]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetDataset", request_serializer=service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, @@ -340,7 +428,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListDatasets", request_serializer=service.ListDatasetsRequest.serialize, response_deserializer=service.ListDatasetsResponse.deserialize, @@ -366,7 +454,7 @@ def update_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dataset" not in self._stubs: - self._stubs["update_dataset"] = self.grpc_channel.unary_unary( + self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateDataset", request_serializer=service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -396,7 +484,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeleteDataset", request_serializer=service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ImportData", request_serializer=service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +548,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportData", request_serializer=service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -486,7 +574,7 @@ def get_annotation_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation_spec" not in self._stubs: - self._stubs["get_annotation_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetAnnotationSpec", request_serializer=service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, @@ -512,7 +600,7 @@ def get_table_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_table_spec" not in self._stubs: - self._stubs["get_table_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_table_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetTableSpec", request_serializer=service.GetTableSpecRequest.serialize, response_deserializer=table_spec.TableSpec.deserialize, @@ -538,7 +626,7 @@ def list_table_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_table_specs" not in self._stubs: - self._stubs["list_table_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_table_specs"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListTableSpecs", request_serializer=service.ListTableSpecsRequest.serialize, response_deserializer=service.ListTableSpecsResponse.deserialize, @@ -564,7 +652,7 @@ def update_table_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table_spec" not in self._stubs: - self._stubs["update_table_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_table_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateTableSpec", request_serializer=service.UpdateTableSpecRequest.serialize, response_deserializer=gca_table_spec.TableSpec.deserialize, @@ -590,7 +678,7 @@ def get_column_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_column_spec" not in self._stubs: - self._stubs["get_column_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_column_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetColumnSpec", request_serializer=service.GetColumnSpecRequest.serialize, response_deserializer=column_spec.ColumnSpec.deserialize, @@ -616,7 +704,7 @@ def list_column_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_column_specs" not in self._stubs: - self._stubs["list_column_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_column_specs"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListColumnSpecs", request_serializer=service.ListColumnSpecsRequest.serialize, response_deserializer=service.ListColumnSpecsResponse.deserialize, @@ -642,7 +730,7 @@ def update_column_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_column_spec" not in self._stubs: - self._stubs["update_column_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_column_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateColumnSpec", request_serializer=service.UpdateColumnSpecRequest.serialize, response_deserializer=gca_column_spec.ColumnSpec.deserialize, @@ -672,7 +760,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/CreateModel", request_serializer=service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -696,7 +784,7 @@ def get_model(self) -> Callable[[service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetModel", request_serializer=service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -722,7 +810,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListModels", request_serializer=service.ListModelsRequest.serialize, response_deserializer=service.ListModelsResponse.deserialize, @@ -751,7 +839,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeleteModel", request_serializer=service.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -791,7 +879,7 @@ def deploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_model" not in self._stubs: - self._stubs["deploy_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeployModel", request_serializer=service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -825,7 +913,7 @@ def undeploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_model" not in self._stubs: - self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UndeployModel", request_serializer=service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -859,7 +947,7 @@ def export_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_model" not in self._stubs: - self._stubs["export_model"] = self.grpc_channel.unary_unary( + self._stubs["export_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportModel", request_serializer=service.ExportModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -899,7 +987,7 @@ def export_evaluated_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_evaluated_examples" not in self._stubs: - self._stubs["export_evaluated_examples"] = self.grpc_channel.unary_unary( + self._stubs["export_evaluated_examples"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportEvaluatedExamples", request_serializer=service.ExportEvaluatedExamplesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -927,7 +1015,7 @@ def get_model_evaluation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model_evaluation" not in self._stubs: - self._stubs["get_model_evaluation"] = self.grpc_channel.unary_unary( + self._stubs["get_model_evaluation"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetModelEvaluation", request_serializer=service.GetModelEvaluationRequest.serialize, response_deserializer=model_evaluation.ModelEvaluation.deserialize, @@ -955,7 +1043,7 @@ def list_model_evaluations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_model_evaluations" not in self._stubs: - self._stubs["list_model_evaluations"] = self.grpc_channel.unary_unary( + self._stubs["list_model_evaluations"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListModelEvaluations", request_serializer=service.ListModelEvaluationsRequest.serialize, response_deserializer=service.ListModelEvaluationsResponse.deserialize, @@ -963,7 +1051,7 @@ def list_model_evaluations( return self._stubs["list_model_evaluations"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py index 1d95ca5511ef..d4a20bd93014 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/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 @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1beta1.types import annotation_spec from google.cloud.automl_v1beta1.types import column_spec @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, AutoMlTransport from .grpc import AutoMlGrpcTransport +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.automl.v1beta1.AutoMl", + "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.automl.v1beta1.AutoMl", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AutoMlGrpcAsyncIOTransport(AutoMlTransport): """gRPC AsyncIO backend transport for AutoMl. @@ -249,10 +331,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 @@ -275,7 +360,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -300,7 +385,7 @@ def create_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dataset" not in self._stubs: - self._stubs["create_dataset"] = self.grpc_channel.unary_unary( + self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/CreateDataset", request_serializer=service.CreateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -326,7 +411,7 @@ def get_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dataset" not in self._stubs: - self._stubs["get_dataset"] = self.grpc_channel.unary_unary( + self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetDataset", request_serializer=service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, @@ -354,7 +439,7 @@ def list_datasets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_datasets" not in self._stubs: - self._stubs["list_datasets"] = self.grpc_channel.unary_unary( + self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListDatasets", request_serializer=service.ListDatasetsRequest.serialize, response_deserializer=service.ListDatasetsResponse.deserialize, @@ -380,7 +465,7 @@ def update_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dataset" not in self._stubs: - self._stubs["update_dataset"] = self.grpc_channel.unary_unary( + self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateDataset", request_serializer=service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, @@ -410,7 +495,7 @@ def delete_dataset( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dataset" not in self._stubs: - self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( + self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeleteDataset", request_serializer=service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -445,7 +530,7 @@ def import_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_data" not in self._stubs: - self._stubs["import_data"] = self.grpc_channel.unary_unary( + self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ImportData", request_serializer=service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -474,7 +559,7 @@ def export_data( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_data" not in self._stubs: - self._stubs["export_data"] = self.grpc_channel.unary_unary( + self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportData", request_serializer=service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -502,7 +587,7 @@ def get_annotation_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_annotation_spec" not in self._stubs: - self._stubs["get_annotation_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetAnnotationSpec", request_serializer=service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, @@ -528,7 +613,7 @@ def get_table_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_table_spec" not in self._stubs: - self._stubs["get_table_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_table_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetTableSpec", request_serializer=service.GetTableSpecRequest.serialize, response_deserializer=table_spec.TableSpec.deserialize, @@ -556,7 +641,7 @@ def list_table_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_table_specs" not in self._stubs: - self._stubs["list_table_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_table_specs"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListTableSpecs", request_serializer=service.ListTableSpecsRequest.serialize, response_deserializer=service.ListTableSpecsResponse.deserialize, @@ -584,7 +669,7 @@ def update_table_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table_spec" not in self._stubs: - self._stubs["update_table_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_table_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateTableSpec", request_serializer=service.UpdateTableSpecRequest.serialize, response_deserializer=gca_table_spec.TableSpec.deserialize, @@ -610,7 +695,7 @@ def get_column_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_column_spec" not in self._stubs: - self._stubs["get_column_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_column_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetColumnSpec", request_serializer=service.GetColumnSpecRequest.serialize, response_deserializer=column_spec.ColumnSpec.deserialize, @@ -638,7 +723,7 @@ def list_column_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_column_specs" not in self._stubs: - self._stubs["list_column_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_column_specs"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListColumnSpecs", request_serializer=service.ListColumnSpecsRequest.serialize, response_deserializer=service.ListColumnSpecsResponse.deserialize, @@ -666,7 +751,7 @@ def update_column_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_column_spec" not in self._stubs: - self._stubs["update_column_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_column_spec"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UpdateColumnSpec", request_serializer=service.UpdateColumnSpecRequest.serialize, response_deserializer=gca_column_spec.ColumnSpec.deserialize, @@ -696,7 +781,7 @@ def create_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_model" not in self._stubs: - self._stubs["create_model"] = self.grpc_channel.unary_unary( + self._stubs["create_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/CreateModel", request_serializer=service.CreateModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -720,7 +805,7 @@ def get_model(self) -> Callable[[service.GetModelRequest], Awaitable[model.Model # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetModel", request_serializer=service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -746,7 +831,7 @@ def list_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_models" not in self._stubs: - self._stubs["list_models"] = self.grpc_channel.unary_unary( + self._stubs["list_models"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListModels", request_serializer=service.ListModelsRequest.serialize, response_deserializer=service.ListModelsResponse.deserialize, @@ -775,7 +860,7 @@ def delete_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_model" not in self._stubs: - self._stubs["delete_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeleteModel", request_serializer=service.DeleteModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -815,7 +900,7 @@ def deploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "deploy_model" not in self._stubs: - self._stubs["deploy_model"] = self.grpc_channel.unary_unary( + self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/DeployModel", request_serializer=service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -849,7 +934,7 @@ def undeploy_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undeploy_model" not in self._stubs: - self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( + self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/UndeployModel", request_serializer=service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -883,7 +968,7 @@ def export_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_model" not in self._stubs: - self._stubs["export_model"] = self.grpc_channel.unary_unary( + self._stubs["export_model"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportModel", request_serializer=service.ExportModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -925,7 +1010,7 @@ def export_evaluated_examples( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_evaluated_examples" not in self._stubs: - self._stubs["export_evaluated_examples"] = self.grpc_channel.unary_unary( + self._stubs["export_evaluated_examples"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ExportEvaluatedExamples", request_serializer=service.ExportEvaluatedExamplesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -953,7 +1038,7 @@ def get_model_evaluation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model_evaluation" not in self._stubs: - self._stubs["get_model_evaluation"] = self.grpc_channel.unary_unary( + self._stubs["get_model_evaluation"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/GetModelEvaluation", request_serializer=service.GetModelEvaluationRequest.serialize, response_deserializer=model_evaluation.ModelEvaluation.deserialize, @@ -982,7 +1067,7 @@ def list_model_evaluations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_model_evaluations" not in self._stubs: - self._stubs["list_model_evaluations"] = self.grpc_channel.unary_unary( + self._stubs["list_model_evaluations"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.AutoMl/ListModelEvaluations", request_serializer=service.ListModelEvaluationsRequest.serialize, response_deserializer=service.ListModelEvaluationsResponse.deserialize, @@ -1240,7 +1325,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: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/rest.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/rest.py index ee4428d21399..5724fc0eed1b 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/transports/rest.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/auto_ml/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, @@ -267,8 +275,10 @@ def post_update_table_spec(self, response): """ def pre_create_dataset( - self, request: service.CreateDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_dataset Override in a subclass to manipulate the request or metadata @@ -286,8 +296,10 @@ def post_create_dataset(self, response: gca_dataset.Dataset) -> gca_dataset.Data return response def pre_create_model( - self, request: service.CreateModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_model Override in a subclass to manipulate the request or metadata @@ -307,8 +319,10 @@ def post_create_model( return response def pre_delete_dataset( - self, request: service.DeleteDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_dataset Override in a subclass to manipulate the request or metadata @@ -328,8 +342,10 @@ def post_delete_dataset( return response def pre_delete_model( - self, request: service.DeleteModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_model Override in a subclass to manipulate the request or metadata @@ -349,8 +365,10 @@ def post_delete_model( return response def pre_deploy_model( - self, request: service.DeployModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeployModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeployModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeployModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for deploy_model Override in a subclass to manipulate the request or metadata @@ -370,8 +388,10 @@ def post_deploy_model( return response def pre_export_data( - self, request: service.ExportDataRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExportDataRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExportDataRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExportDataRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_data Override in a subclass to manipulate the request or metadata @@ -393,8 +413,10 @@ def post_export_data( def pre_export_evaluated_examples( self, request: service.ExportEvaluatedExamplesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ExportEvaluatedExamplesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ExportEvaluatedExamplesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_evaluated_examples Override in a subclass to manipulate the request or metadata @@ -414,8 +436,10 @@ def post_export_evaluated_examples( return response def pre_export_model( - self, request: service.ExportModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExportModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExportModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExportModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_model Override in a subclass to manipulate the request or metadata @@ -437,8 +461,10 @@ def post_export_model( def pre_get_annotation_spec( self, request: service.GetAnnotationSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetAnnotationSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetAnnotationSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_annotation_spec Override in a subclass to manipulate the request or metadata @@ -458,8 +484,10 @@ def post_get_annotation_spec( return response def pre_get_column_spec( - self, request: service.GetColumnSpecRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetColumnSpecRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetColumnSpecRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetColumnSpecRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_column_spec Override in a subclass to manipulate the request or metadata @@ -479,8 +507,10 @@ def post_get_column_spec( return response def pre_get_dataset( - self, request: service.GetDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_dataset Override in a subclass to manipulate the request or metadata @@ -498,8 +528,10 @@ def post_get_dataset(self, response: dataset.Dataset) -> dataset.Dataset: return response def pre_get_model( - self, request: service.GetModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -519,8 +551,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_get_model_evaluation( self, request: service.GetModelEvaluationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetModelEvaluationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetModelEvaluationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_model_evaluation Override in a subclass to manipulate the request or metadata @@ -540,8 +574,10 @@ def post_get_model_evaluation( return response def pre_get_table_spec( - self, request: service.GetTableSpecRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetTableSpecRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetTableSpecRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetTableSpecRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_table_spec Override in a subclass to manipulate the request or metadata @@ -561,8 +597,10 @@ def post_get_table_spec( return response def pre_import_data( - self, request: service.ImportDataRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ImportDataRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ImportDataRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ImportDataRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_data Override in a subclass to manipulate the request or metadata @@ -584,8 +622,8 @@ def post_import_data( def pre_list_column_specs( self, request: service.ListColumnSpecsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListColumnSpecsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListColumnSpecsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_column_specs Override in a subclass to manipulate the request or metadata @@ -605,8 +643,10 @@ def post_list_column_specs( return response def pre_list_datasets( - self, request: service.ListDatasetsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListDatasetsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListDatasetsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListDatasetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_datasets Override in a subclass to manipulate the request or metadata @@ -628,8 +668,10 @@ def post_list_datasets( def pre_list_model_evaluations( self, request: service.ListModelEvaluationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListModelEvaluationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListModelEvaluationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_model_evaluations Override in a subclass to manipulate the request or metadata @@ -649,8 +691,10 @@ def post_list_model_evaluations( return response def pre_list_models( - self, request: service.ListModelsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListModelsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListModelsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -672,8 +716,8 @@ def post_list_models( def pre_list_table_specs( self, request: service.ListTableSpecsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListTableSpecsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListTableSpecsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_table_specs Override in a subclass to manipulate the request or metadata @@ -693,8 +737,10 @@ def post_list_table_specs( return response def pre_undeploy_model( - self, request: service.UndeployModelRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UndeployModelRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UndeployModelRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UndeployModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undeploy_model Override in a subclass to manipulate the request or metadata @@ -716,8 +762,10 @@ def post_undeploy_model( def pre_update_column_spec( self, request: service.UpdateColumnSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateColumnSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.UpdateColumnSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_column_spec Override in a subclass to manipulate the request or metadata @@ -737,8 +785,10 @@ def post_update_column_spec( return response def pre_update_dataset( - self, request: service.UpdateDatasetRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateDatasetRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateDatasetRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateDatasetRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_dataset Override in a subclass to manipulate the request or metadata @@ -758,8 +808,8 @@ def post_update_dataset(self, response: gca_dataset.Dataset) -> gca_dataset.Data def pre_update_table_spec( self, request: service.UpdateTableSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateTableSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateTableSpecRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_table_spec Override in a subclass to manipulate the request or metadata @@ -973,7 +1023,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]]] = (), ) -> gca_dataset.Dataset: r"""Call the create dataset method over HTTP. @@ -984,8 +1034,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: ~.gca_dataset.Dataset: @@ -999,6 +1051,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseCreateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_create_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseCreateDataset._get_transcoded_request( @@ -1017,6 +1070,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.automl_v1beta1.AutoMlClient.CreateDataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "CreateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._CreateDataset._get_response( self._host, @@ -1038,7 +1118,29 @@ def __call__( pb_resp = gca_dataset.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_dataset.Dataset.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.automl_v1beta1.AutoMlClient.create_dataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "CreateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateModel(_BaseAutoMlRestTransport._BaseCreateModel, AutoMlRestStub): @@ -1074,7 +1176,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create model method over HTTP. @@ -1085,8 +1187,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: ~.operations_pb2.Operation: @@ -1097,6 +1201,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseCreateModel._get_http_options() + request, metadata = self._interceptor.pre_create_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseCreateModel._get_transcoded_request( @@ -1115,6 +1220,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.automl_v1beta1.AutoMlClient.CreateModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "CreateModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._CreateModel._get_response( self._host, @@ -1134,7 +1266,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_model(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.automl_v1beta1.AutoMlClient.create_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "CreateModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDataset(_BaseAutoMlRestTransport._BaseDeleteDataset, AutoMlRestStub): @@ -1169,7 +1323,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete dataset method over HTTP. @@ -1180,8 +1334,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: ~.operations_pb2.Operation: @@ -1194,6 +1350,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseDeleteDataset._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeleteDataset._get_transcoded_request( @@ -1208,6 +1365,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.automl_v1beta1.AutoMlClient.DeleteDataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeleteDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeleteDataset._get_response( self._host, @@ -1226,7 +1410,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_dataset(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.automl_v1beta1.AutoMlClient.delete_dataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeleteDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteModel(_BaseAutoMlRestTransport._BaseDeleteModel, AutoMlRestStub): @@ -1261,7 +1467,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete model method over HTTP. @@ -1272,8 +1478,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: ~.operations_pb2.Operation: @@ -1284,6 +1492,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseDeleteModel._get_http_options() + request, metadata = self._interceptor.pre_delete_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeleteModel._get_transcoded_request( @@ -1298,6 +1507,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.automl_v1beta1.AutoMlClient.DeleteModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeleteModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeleteModel._get_response( self._host, @@ -1316,7 +1552,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_model(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.automl_v1beta1.AutoMlClient.delete_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeleteModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeployModel(_BaseAutoMlRestTransport._BaseDeployModel, AutoMlRestStub): @@ -1352,7 +1610,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]]] = (), ) -> operations_pb2.Operation: r"""Call the deploy model method over HTTP. @@ -1363,8 +1621,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: ~.operations_pb2.Operation: @@ -1375,6 +1635,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseDeployModel._get_http_options() + request, metadata = self._interceptor.pre_deploy_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseDeployModel._get_transcoded_request( @@ -1393,6 +1654,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.automl_v1beta1.AutoMlClient.DeployModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeployModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._DeployModel._get_response( self._host, @@ -1412,7 +1700,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_model(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.automl_v1beta1.AutoMlClient.deploy_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "DeployModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportData(_BaseAutoMlRestTransport._BaseExportData, AutoMlRestStub): @@ -1448,7 +1758,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export data method over HTTP. @@ -1459,8 +1769,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: ~.operations_pb2.Operation: @@ -1471,6 +1783,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseExportData._get_http_options() + request, metadata = self._interceptor.pre_export_data(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseExportData._get_transcoded_request( @@ -1489,6 +1802,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.automl_v1beta1.AutoMlClient.ExportData", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ExportData._get_response( self._host, @@ -1508,7 +1848,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_data(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.automl_v1beta1.AutoMlClient.export_data", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportEvaluatedExamples( @@ -1546,7 +1908,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export evaluated examples method over HTTP. @@ -1557,8 +1919,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: ~.operations_pb2.Operation: @@ -1571,6 +1935,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseExportEvaluatedExamples._get_http_options() ) + request, metadata = self._interceptor.pre_export_evaluated_examples( request, metadata ) @@ -1587,6 +1952,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.automl_v1beta1.AutoMlClient.ExportEvaluatedExamples", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportEvaluatedExamples", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ExportEvaluatedExamples._get_response( self._host, @@ -1606,7 +1998,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_evaluated_examples(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.automl_v1beta1.AutoMlClient.export_evaluated_examples", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportEvaluatedExamples", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ExportModel(_BaseAutoMlRestTransport._BaseExportModel, AutoMlRestStub): @@ -1642,7 +2056,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]]] = (), ) -> operations_pb2.Operation: r"""Call the export model method over HTTP. @@ -1655,8 +2069,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: ~.operations_pb2.Operation: @@ -1667,6 +2083,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseExportModel._get_http_options() + request, metadata = self._interceptor.pre_export_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseExportModel._get_transcoded_request( @@ -1685,6 +2102,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.automl_v1beta1.AutoMlClient.ExportModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ExportModel._get_response( self._host, @@ -1704,7 +2148,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_model(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.automl_v1beta1.AutoMlClient.export_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ExportModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAnnotationSpec( @@ -1741,7 +2207,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]]] = (), ) -> annotation_spec.AnnotationSpec: r"""Call the get annotation spec method over HTTP. @@ -1752,8 +2218,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: ~.annotation_spec.AnnotationSpec: @@ -1763,6 +2231,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetAnnotationSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_annotation_spec( request, metadata ) @@ -1779,6 +2248,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.automl_v1beta1.AutoMlClient.GetAnnotationSpec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetAnnotationSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetAnnotationSpec._get_response( self._host, @@ -1799,7 +2295,29 @@ def __call__( pb_resp = annotation_spec.AnnotationSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_annotation_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = annotation_spec.AnnotationSpec.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.automl_v1beta1.AutoMlClient.get_annotation_spec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetAnnotationSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetColumnSpec(_BaseAutoMlRestTransport._BaseGetColumnSpec, AutoMlRestStub): @@ -1834,7 +2352,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]]] = (), ) -> column_spec.ColumnSpec: r"""Call the get column spec method over HTTP. @@ -1845,8 +2363,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: ~.column_spec.ColumnSpec: @@ -1861,6 +2381,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetColumnSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_column_spec(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetColumnSpec._get_transcoded_request( @@ -1875,6 +2396,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.automl_v1beta1.AutoMlClient.GetColumnSpec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetColumnSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetColumnSpec._get_response( self._host, @@ -1895,7 +2443,29 @@ def __call__( pb_resp = column_spec.ColumnSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_column_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = column_spec.ColumnSpec.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.automl_v1beta1.AutoMlClient.get_column_spec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetColumnSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataset(_BaseAutoMlRestTransport._BaseGetDataset, AutoMlRestStub): @@ -1930,7 +2500,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]]] = (), ) -> dataset.Dataset: r"""Call the get dataset method over HTTP. @@ -1941,8 +2511,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: ~.dataset.Dataset: @@ -1954,6 +2526,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseGetDataset._get_http_options() + request, metadata = self._interceptor.pre_get_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetDataset._get_transcoded_request( @@ -1968,6 +2541,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.automl_v1beta1.AutoMlClient.GetDataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetDataset._get_response( self._host, @@ -1988,7 +2588,29 @@ def __call__( pb_resp = dataset.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = dataset.Dataset.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.automl_v1beta1.AutoMlClient.get_dataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModel(_BaseAutoMlRestTransport._BaseGetModel, AutoMlRestStub): @@ -2023,7 +2645,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]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -2034,8 +2656,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: ~.model.Model: @@ -2045,6 +2669,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseGetModel._get_http_options() + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetModel._get_transcoded_request( @@ -2059,6 +2684,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.automl_v1beta1.AutoMlClient.GetModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetModel._get_response( self._host, @@ -2079,7 +2731,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.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.automl_v1beta1.AutoMlClient.get_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetModelEvaluation( @@ -2116,7 +2790,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]]] = (), ) -> model_evaluation.ModelEvaluation: r"""Call the get model evaluation method over HTTP. @@ -2127,8 +2801,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: ~.model_evaluation.ModelEvaluation: @@ -2138,6 +2814,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetModelEvaluation._get_http_options() ) + request, metadata = self._interceptor.pre_get_model_evaluation( request, metadata ) @@ -2152,6 +2829,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.automl_v1beta1.AutoMlClient.GetModelEvaluation", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetModelEvaluation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetModelEvaluation._get_response( self._host, @@ -2172,7 +2876,31 @@ def __call__( pb_resp = model_evaluation.ModelEvaluation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model_evaluation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_evaluation.ModelEvaluation.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.automl_v1beta1.AutoMlClient.get_model_evaluation", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetModelEvaluation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTableSpec(_BaseAutoMlRestTransport._BaseGetTableSpec, AutoMlRestStub): @@ -2207,7 +2935,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]]] = (), ) -> table_spec.TableSpec: r"""Call the get table spec method over HTTP. @@ -2218,8 +2946,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: ~.table_spec.TableSpec: @@ -2240,6 +2970,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseGetTableSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_table_spec(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseGetTableSpec._get_transcoded_request( @@ -2254,6 +2985,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.automl_v1beta1.AutoMlClient.GetTableSpec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetTableSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._GetTableSpec._get_response( self._host, @@ -2274,7 +3032,29 @@ def __call__( pb_resp = table_spec.TableSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_table_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = table_spec.TableSpec.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.automl_v1beta1.AutoMlClient.get_table_spec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "GetTableSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportData(_BaseAutoMlRestTransport._BaseImportData, AutoMlRestStub): @@ -2310,7 +3090,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import data method over HTTP. @@ -2321,8 +3101,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: ~.operations_pb2.Operation: @@ -2333,6 +3115,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseImportData._get_http_options() + request, metadata = self._interceptor.pre_import_data(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseImportData._get_transcoded_request( @@ -2351,6 +3134,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.automl_v1beta1.AutoMlClient.ImportData", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ImportData", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ImportData._get_response( self._host, @@ -2370,7 +3180,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_data(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.automl_v1beta1.AutoMlClient.import_data", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ImportData", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListColumnSpecs( @@ -2407,7 +3239,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]]] = (), ) -> service.ListColumnSpecsResponse: r"""Call the list column specs method over HTTP. @@ -2418,8 +3250,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: ~.service.ListColumnSpecsResponse: @@ -2431,6 +3265,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListColumnSpecs._get_http_options() ) + request, metadata = self._interceptor.pre_list_column_specs( request, metadata ) @@ -2447,6 +3282,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.automl_v1beta1.AutoMlClient.ListColumnSpecs", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListColumnSpecs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListColumnSpecs._get_response( self._host, @@ -2467,7 +3329,29 @@ def __call__( pb_resp = service.ListColumnSpecsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_column_specs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListColumnSpecsResponse.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.automl_v1beta1.AutoMlClient.list_column_specs", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListColumnSpecs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatasets(_BaseAutoMlRestTransport._BaseListDatasets, AutoMlRestStub): @@ -2502,7 +3386,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]]] = (), ) -> service.ListDatasetsResponse: r"""Call the list datasets method over HTTP. @@ -2513,8 +3397,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: ~.service.ListDatasetsResponse: @@ -2526,6 +3412,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListDatasets._get_http_options() ) + request, metadata = self._interceptor.pre_list_datasets(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseListDatasets._get_transcoded_request( @@ -2540,6 +3427,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.automl_v1beta1.AutoMlClient.ListDatasets", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListDatasets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListDatasets._get_response( self._host, @@ -2560,7 +3474,29 @@ def __call__( pb_resp = service.ListDatasetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_datasets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListDatasetsResponse.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.automl_v1beta1.AutoMlClient.list_datasets", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListDatasets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModelEvaluations( @@ -2597,7 +3533,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]]] = (), ) -> service.ListModelEvaluationsResponse: r"""Call the list model evaluations method over HTTP. @@ -2608,8 +3544,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: ~.service.ListModelEvaluationsResponse: @@ -2621,6 +3559,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListModelEvaluations._get_http_options() ) + request, metadata = self._interceptor.pre_list_model_evaluations( request, metadata ) @@ -2633,6 +3572,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 = 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.automl_v1beta1.AutoMlClient.ListModelEvaluations", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListModelEvaluations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListModelEvaluations._get_response( self._host, @@ -2653,7 +3619,31 @@ def __call__( pb_resp = service.ListModelEvaluationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_model_evaluations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListModelEvaluationsResponse.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.automl_v1beta1.AutoMlClient.list_model_evaluations", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListModelEvaluations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels(_BaseAutoMlRestTransport._BaseListModels, AutoMlRestStub): @@ -2688,7 +3678,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]]] = (), ) -> service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -2699,8 +3689,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: ~.service.ListModelsResponse: @@ -2710,6 +3702,7 @@ def __call__( """ http_options = _BaseAutoMlRestTransport._BaseListModels._get_http_options() + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseListModels._get_transcoded_request( @@ -2724,6 +3717,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.automl_v1beta1.AutoMlClient.ListModels", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListModels._get_response( self._host, @@ -2744,7 +3764,29 @@ def __call__( pb_resp = service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListModelsResponse.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.automl_v1beta1.AutoMlClient.list_models", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTableSpecs(_BaseAutoMlRestTransport._BaseListTableSpecs, AutoMlRestStub): @@ -2779,7 +3821,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]]] = (), ) -> service.ListTableSpecsResponse: r"""Call the list table specs method over HTTP. @@ -2790,8 +3832,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: ~.service.ListTableSpecsResponse: @@ -2803,6 +3847,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseListTableSpecs._get_http_options() ) + request, metadata = self._interceptor.pre_list_table_specs( request, metadata ) @@ -2819,6 +3864,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.automl_v1beta1.AutoMlClient.ListTableSpecs", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListTableSpecs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._ListTableSpecs._get_response( self._host, @@ -2839,7 +3911,29 @@ def __call__( pb_resp = service.ListTableSpecsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_table_specs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListTableSpecsResponse.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.automl_v1beta1.AutoMlClient.list_table_specs", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "ListTableSpecs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeployModel(_BaseAutoMlRestTransport._BaseUndeployModel, AutoMlRestStub): @@ -2875,7 +3969,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]]] = (), ) -> operations_pb2.Operation: r"""Call the undeploy model method over HTTP. @@ -2886,8 +3980,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: ~.operations_pb2.Operation: @@ -2900,6 +3996,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUndeployModel._get_http_options() ) + request, metadata = self._interceptor.pre_undeploy_model(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseUndeployModel._get_transcoded_request( @@ -2918,6 +4015,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.automl_v1beta1.AutoMlClient.UndeployModel", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UndeployModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UndeployModel._get_response( self._host, @@ -2937,7 +4061,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_model(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.automl_v1beta1.AutoMlClient.undeploy_model", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UndeployModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateColumnSpec( @@ -2975,7 +4121,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]]] = (), ) -> gca_column_spec.ColumnSpec: r"""Call the update column spec method over HTTP. @@ -2986,8 +4132,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: ~.gca_column_spec.ColumnSpec: @@ -3002,6 +4150,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUpdateColumnSpec._get_http_options() ) + request, metadata = self._interceptor.pre_update_column_spec( request, metadata ) @@ -3024,6 +4173,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.automl_v1beta1.AutoMlClient.UpdateColumnSpec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateColumnSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UpdateColumnSpec._get_response( self._host, @@ -3045,7 +4221,29 @@ def __call__( pb_resp = gca_column_spec.ColumnSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_column_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_column_spec.ColumnSpec.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.automl_v1beta1.AutoMlClient.update_column_spec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateColumnSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataset(_BaseAutoMlRestTransport._BaseUpdateDataset, AutoMlRestStub): @@ -3081,7 +4279,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]]] = (), ) -> gca_dataset.Dataset: r"""Call the update dataset method over HTTP. @@ -3092,8 +4290,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: ~.gca_dataset.Dataset: @@ -3107,6 +4307,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUpdateDataset._get_http_options() ) + request, metadata = self._interceptor.pre_update_dataset(request, metadata) transcoded_request = ( _BaseAutoMlRestTransport._BaseUpdateDataset._get_transcoded_request( @@ -3125,6 +4326,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.automl_v1beta1.AutoMlClient.UpdateDataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateDataset", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UpdateDataset._get_response( self._host, @@ -3146,7 +4374,29 @@ def __call__( pb_resp = gca_dataset.Dataset.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dataset(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_dataset.Dataset.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.automl_v1beta1.AutoMlClient.update_dataset", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateDataset", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTableSpec( @@ -3184,7 +4434,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]]] = (), ) -> gca_table_spec.TableSpec: r"""Call the update table spec method over HTTP. @@ -3195,8 +4445,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: ~.gca_table_spec.TableSpec: @@ -3217,6 +4469,7 @@ def __call__( http_options = ( _BaseAutoMlRestTransport._BaseUpdateTableSpec._get_http_options() ) + request, metadata = self._interceptor.pre_update_table_spec( request, metadata ) @@ -3237,6 +4490,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.automl_v1beta1.AutoMlClient.UpdateTableSpec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateTableSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AutoMlRestTransport._UpdateTableSpec._get_response( self._host, @@ -3258,7 +4538,29 @@ def __call__( pb_resp = gca_table_spec.TableSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_table_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gca_table_spec.TableSpec.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.automl_v1beta1.AutoMlClient.update_table_spec", + extra={ + "serviceName": "google.cloud.automl.v1beta1.AutoMl", + "rpcName": "UpdateTableSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/async_client.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/async_client.py index b8ad20c31516..a6fb80b73b8d 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/async_client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/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, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +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 PredictionServiceAsyncClient: """AutoML Prediction API. @@ -270,6 +280,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.automl_v1beta1.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "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.automl.v1beta1.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -279,7 +311,7 @@ async def predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> prediction_service.PredictResponse: r"""Perform an online prediction. The prediction result will be directly returned in the response. Available for following ML @@ -383,8 +415,10 @@ async def sample_predict(): 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.automl_v1beta1.types.PredictResponse: @@ -451,7 +485,7 @@ async def batch_predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1beta1.PredictionService.Predict], @@ -618,8 +652,10 @@ async def sample_batch_predict(): 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.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/client.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/client.py index 23ab0d0fe0ee..ae7e7884258f 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -594,6 +604,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( @@ -660,6 +674,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.automl_v1beta1.PredictionServiceClient`.", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "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.automl.v1beta1.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -669,7 +706,7 @@ def predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> prediction_service.PredictResponse: r"""Perform an online prediction. The prediction result will be directly returned in the response. Available for following ML @@ -773,8 +810,10 @@ def sample_predict(): 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.automl_v1beta1.types.PredictResponse: @@ -839,7 +878,7 @@ def batch_predict( params: Optional[MutableMapping[str, 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]]] = (), ) -> operation.Operation: r"""Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1beta1.PredictionService.Predict], @@ -1006,8 +1045,10 @@ def sample_batch_predict(): 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.api_core.operation.Operation: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py index 27233b6d79dd..cf284c2781c6 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1beta1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +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.automl.v1beta1.PredictionService", + "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.automl.v1beta1.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -184,7 +265,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 @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -294,7 +382,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -336,7 +424,7 @@ def batch_predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_predict" not in self._stubs: - self._stubs["batch_predict"] = self.grpc_channel.unary_unary( + self._stubs["batch_predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.PredictionService/BatchPredict", request_serializer=prediction_service.BatchPredictRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -344,7 +432,7 @@ def batch_predict( return self._stubs["batch_predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py index 7837e7ca5c9c..af48008c8c81 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.automl_v1beta1.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +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.automl.v1beta1.PredictionService", + "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.automl.v1beta1.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -231,10 +313,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 @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -305,7 +390,7 @@ def predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -349,7 +434,7 @@ def batch_predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_predict" not in self._stubs: - self._stubs["batch_predict"] = self.grpc_channel.unary_unary( + self._stubs["batch_predict"] = self._logged_channel.unary_unary( "/google.cloud.automl.v1beta1.PredictionService/BatchPredict", request_serializer=prediction_service.BatchPredictRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +462,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: diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/rest.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/rest.py index 52e2705b419b..342dd9cbcfa6 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/transports/rest.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/prediction_service/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 @@ -38,6 +38,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, @@ -86,8 +94,10 @@ def post_predict(self, response): def pre_batch_predict( self, request: prediction_service.BatchPredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.BatchPredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.BatchPredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_predict Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_batch_predict( def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -315,7 +327,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]]] = (), ) -> operations_pb2.Operation: r"""Call the batch predict method over HTTP. @@ -326,8 +338,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: ~.operations_pb2.Operation: @@ -340,6 +354,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseBatchPredict._get_http_options() ) + request, metadata = self._interceptor.pre_batch_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseBatchPredict._get_transcoded_request( http_options, request @@ -354,6 +369,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.automl_v1beta1.PredictionServiceClient.BatchPredict", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "rpcName": "BatchPredict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._BatchPredict._get_response( self._host, @@ -373,7 +415,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_predict(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.automl_v1beta1.PredictionServiceClient.batch_predict", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "rpcName": "BatchPredict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _Predict( @@ -411,7 +475,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]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -422,8 +486,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: ~.prediction_service.PredictResponse: @@ -435,6 +501,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -453,6 +520,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.automl_v1beta1.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -474,7 +568,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.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.automl_v1beta1.PredictionServiceClient.predict", + extra={ + "serviceName": "google.cloud.automl.v1beta1.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json index 49126fa3a89d..0d8816baffc0 100644 --- a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json +++ b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-automl", - "version": "2.14.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.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1041,7 +1041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.AnnotationSpec", @@ -1286,7 +1286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.AnnotationSpec", @@ -1367,7 +1367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Dataset", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Dataset", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.ModelEvaluation", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.ModelEvaluation", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Model", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Model", @@ -1854,7 +1854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListDatasetsAsyncPager", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListDatasetsPager", @@ -2184,7 +2184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListModelEvaluationsAsyncPager", @@ -2268,7 +2268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListModelEvaluationsPager", @@ -2349,7 +2349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListModelsAsyncPager", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.services.auto_ml.pagers.ListModelsPager", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2675,7 +2675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Dataset", @@ -2759,7 +2759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Dataset", @@ -2844,7 +2844,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Model", @@ -2928,7 +2928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.Model", @@ -3021,7 +3021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3113,7 +3113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3202,7 +3202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.PredictResponse", @@ -3290,7 +3290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1.types.PredictResponse", diff --git a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json index a123a7bf2218..3957ec9b1b9f 100644 --- a/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json +++ b/packages/google-cloud-automl/samples/generated_samples/snippet_metadata_google.cloud.automl.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-automl", - "version": "2.14.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.automl_v1beta1.types.Dataset", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Dataset", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1041,7 +1041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1210,7 +1210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1294,7 +1294,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1375,7 +1375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.AnnotationSpec", @@ -1455,7 +1455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.AnnotationSpec", @@ -1536,7 +1536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ColumnSpec", @@ -1616,7 +1616,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ColumnSpec", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Dataset", @@ -1777,7 +1777,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Dataset", @@ -1858,7 +1858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ModelEvaluation", @@ -1938,7 +1938,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ModelEvaluation", @@ -2019,7 +2019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Model", @@ -2099,7 +2099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Model", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.TableSpec", @@ -2260,7 +2260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.TableSpec", @@ -2345,7 +2345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2429,7 +2429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2510,7 +2510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListColumnSpecsAsyncPager", @@ -2590,7 +2590,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListColumnSpecsPager", @@ -2671,7 +2671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListDatasetsAsyncPager", @@ -2751,7 +2751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListDatasetsPager", @@ -2832,7 +2832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListModelEvaluationsAsyncPager", @@ -2912,7 +2912,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListModelEvaluationsPager", @@ -2993,7 +2993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListModelsAsyncPager", @@ -3073,7 +3073,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListModelsPager", @@ -3154,7 +3154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListTableSpecsAsyncPager", @@ -3234,7 +3234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.services.auto_ml.pagers.ListTableSpecsPager", @@ -3315,7 +3315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3395,7 +3395,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3476,7 +3476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ColumnSpec", @@ -3556,7 +3556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.ColumnSpec", @@ -3637,7 +3637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Dataset", @@ -3717,7 +3717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.Dataset", @@ -3798,7 +3798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.TableSpec", @@ -3878,7 +3878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.TableSpec", @@ -3971,7 +3971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4063,7 +4063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4152,7 +4152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.PredictResponse", @@ -4240,7 +4240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.automl_v1beta1.types.PredictResponse", diff --git a/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_auto_ml.py b/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_auto_ml.py index b93fc9fb0fbc..bed20847bf91 100644 --- a/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_auto_ml.py +++ b/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_auto_ml.py @@ -7922,6 +7922,7 @@ def test_create_dataset_rest_required_fields(request_type=service.CreateDatasetR 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_dataset(request) @@ -7978,6 +7979,7 @@ def test_create_dataset_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_dataset(**mock_args) @@ -8111,6 +8113,7 @@ def test_get_dataset_rest_required_fields(request_type=service.GetDatasetRequest 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_dataset(request) @@ -8156,6 +8159,7 @@ def test_get_dataset_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_dataset(**mock_args) @@ -8292,6 +8296,7 @@ def test_list_datasets_rest_required_fields(request_type=service.ListDatasetsReq 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_datasets(request) @@ -8346,6 +8351,7 @@ def test_list_datasets_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_datasets(**mock_args) @@ -8533,6 +8539,7 @@ def test_update_dataset_rest_required_fields(request_type=service.UpdateDatasetR 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_dataset(request) @@ -8593,6 +8600,7 @@ def test_update_dataset_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_dataset(**mock_args) @@ -8728,6 +8736,7 @@ def test_delete_dataset_rest_required_fields(request_type=service.DeleteDatasetR 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_dataset(request) @@ -8771,6 +8780,7 @@ def test_delete_dataset_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.delete_dataset(**mock_args) @@ -8901,6 +8911,7 @@ def test_import_data_rest_required_fields(request_type=service.ImportDataRequest 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.import_data(request) @@ -8955,6 +8966,7 @@ def test_import_data_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.import_data(**mock_args) @@ -9089,6 +9101,7 @@ def test_export_data_rest_required_fields(request_type=service.ExportDataRequest 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.export_data(request) @@ -9145,6 +9158,7 @@ def test_export_data_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.export_data(**mock_args) @@ -9285,6 +9299,7 @@ def test_get_annotation_spec_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_annotation_spec(request) @@ -9332,6 +9347,7 @@ def test_get_annotation_spec_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_annotation_spec(**mock_args) @@ -9463,6 +9479,7 @@ def test_create_model_rest_required_fields(request_type=service.CreateModelReque 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_model(request) @@ -9519,6 +9536,7 @@ def test_create_model_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_model(**mock_args) @@ -9652,6 +9670,7 @@ def test_get_model_rest_required_fields(request_type=service.GetModelRequest): 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_model(request) @@ -9697,6 +9716,7 @@ def test_get_model_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_model(**mock_args) @@ -9833,6 +9853,7 @@ def test_list_models_rest_required_fields(request_type=service.ListModelsRequest 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_models(request) @@ -9887,6 +9908,7 @@ def test_list_models_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_models(**mock_args) @@ -10077,6 +10099,7 @@ def test_delete_model_rest_required_fields(request_type=service.DeleteModelReque 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_model(request) @@ -10120,6 +10143,7 @@ def test_delete_model_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.delete_model(**mock_args) @@ -10246,6 +10270,7 @@ def test_update_model_rest_required_fields(request_type=service.UpdateModelReque 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_model(request) @@ -10306,6 +10331,7 @@ def test_update_model_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_model(**mock_args) @@ -10442,6 +10468,7 @@ def test_deploy_model_rest_required_fields(request_type=service.DeployModelReque 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.deploy_model(request) @@ -10485,6 +10512,7 @@ def test_deploy_model_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.deploy_model(**mock_args) @@ -10616,6 +10644,7 @@ def test_undeploy_model_rest_required_fields(request_type=service.UndeployModelR 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.undeploy_model(request) @@ -10659,6 +10688,7 @@ def test_undeploy_model_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.undeploy_model(**mock_args) @@ -10790,6 +10820,7 @@ def test_export_model_rest_required_fields(request_type=service.ExportModelReque 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.export_model(request) @@ -10846,6 +10877,7 @@ def test_export_model_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.export_model(**mock_args) @@ -10986,6 +11018,7 @@ def test_get_model_evaluation_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_model_evaluation(request) @@ -11033,6 +11066,7 @@ def test_get_model_evaluation_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_model_evaluation(**mock_args) @@ -11184,6 +11218,7 @@ def test_list_model_evaluations_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.list_model_evaluations(request) @@ -11250,6 +11285,7 @@ def test_list_model_evaluations_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_model_evaluations(**mock_args) @@ -12368,6 +12404,7 @@ def test_create_dataset_rest_bad_request(request_type=service.CreateDatasetReque 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_dataset(request) @@ -12483,6 +12520,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_dataset(request) # Establish that the response is the type that we expect. @@ -12520,6 +12558,7 @@ def test_create_dataset_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -12562,6 +12601,7 @@ def test_get_dataset_rest_bad_request(request_type=service.GetDatasetRequest): 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_dataset(request) @@ -12601,6 +12641,7 @@ def test_get_dataset_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_dataset(request) # Establish that the response is the type that we expect. @@ -12641,6 +12682,7 @@ def test_get_dataset_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 = dataset.Dataset.to_json(dataset.Dataset()) req.return_value.content = return_value @@ -12683,6 +12725,7 @@ def test_list_datasets_rest_bad_request(request_type=service.ListDatasetsRequest 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_datasets(request) @@ -12718,6 +12761,7 @@ def test_list_datasets_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_datasets(request) # Establish that the response is the type that we expect. @@ -12754,6 +12798,7 @@ def test_list_datasets_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 = service.ListDatasetsResponse.to_json( service.ListDatasetsResponse() ) @@ -12800,6 +12845,7 @@ def test_update_dataset_rest_bad_request(request_type=service.UpdateDatasetReque 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_dataset(request) @@ -12926,6 +12972,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_dataset(request) # Establish that the response is the type that we expect. @@ -12966,6 +13013,7 @@ def test_update_dataset_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 = gca_dataset.Dataset.to_json(gca_dataset.Dataset()) req.return_value.content = return_value @@ -13008,6 +13056,7 @@ def test_delete_dataset_rest_bad_request(request_type=service.DeleteDatasetReque 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_dataset(request) @@ -13038,6 +13087,7 @@ def test_delete_dataset_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.delete_dataset(request) # Establish that the response is the type that we expect. @@ -13075,6 +13125,7 @@ def test_delete_dataset_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -13117,6 +13168,7 @@ def test_import_data_rest_bad_request(request_type=service.ImportDataRequest): 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.import_data(request) @@ -13147,6 +13199,7 @@ def test_import_data_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.import_data(request) # Establish that the response is the type that we expect. @@ -13184,6 +13237,7 @@ def test_import_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -13226,6 +13280,7 @@ def test_export_data_rest_bad_request(request_type=service.ExportDataRequest): 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.export_data(request) @@ -13256,6 +13311,7 @@ def test_export_data_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.export_data(request) # Establish that the response is the type that we expect. @@ -13293,6 +13349,7 @@ def test_export_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -13339,6 +13396,7 @@ def test_get_annotation_spec_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_annotation_spec(request) @@ -13378,6 +13436,7 @@ def test_get_annotation_spec_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_annotation_spec(request) # Establish that the response is the type that we expect. @@ -13418,6 +13477,7 @@ def test_get_annotation_spec_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 = annotation_spec.AnnotationSpec.to_json( annotation_spec.AnnotationSpec() ) @@ -13462,6 +13522,7 @@ def test_create_model_rest_bad_request(request_type=service.CreateModelRequest): 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_model(request) @@ -13594,6 +13655,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_model(request) # Establish that the response is the type that we expect. @@ -13631,6 +13693,7 @@ def test_create_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -13673,6 +13736,7 @@ def test_get_model_rest_bad_request(request_type=service.GetModelRequest): 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_model(request) @@ -13712,6 +13776,7 @@ def test_get_model_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_model(request) # Establish that the response is the type that we expect. @@ -13752,6 +13817,7 @@ def test_get_model_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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -13794,6 +13860,7 @@ def test_list_models_rest_bad_request(request_type=service.ListModelsRequest): 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_models(request) @@ -13829,6 +13896,7 @@ def test_list_models_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_models(request) # Establish that the response is the type that we expect. @@ -13865,6 +13933,7 @@ def test_list_models_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 = service.ListModelsResponse.to_json(service.ListModelsResponse()) req.return_value.content = return_value @@ -13907,6 +13976,7 @@ def test_delete_model_rest_bad_request(request_type=service.DeleteModelRequest): 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_model(request) @@ -13937,6 +14007,7 @@ def test_delete_model_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.delete_model(request) # Establish that the response is the type that we expect. @@ -13974,6 +14045,7 @@ def test_delete_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14018,6 +14090,7 @@ def test_update_model_rest_bad_request(request_type=service.UpdateModelRequest): 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_model(request) @@ -14161,6 +14234,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_model(request) # Establish that the response is the type that we expect. @@ -14201,6 +14275,7 @@ def test_update_model_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 = gca_model.Model.to_json(gca_model.Model()) req.return_value.content = return_value @@ -14243,6 +14318,7 @@ def test_deploy_model_rest_bad_request(request_type=service.DeployModelRequest): 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.deploy_model(request) @@ -14273,6 +14349,7 @@ def test_deploy_model_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.deploy_model(request) # Establish that the response is the type that we expect. @@ -14310,6 +14387,7 @@ def test_deploy_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14352,6 +14430,7 @@ def test_undeploy_model_rest_bad_request(request_type=service.UndeployModelReque 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.undeploy_model(request) @@ -14382,6 +14461,7 @@ def test_undeploy_model_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.undeploy_model(request) # Establish that the response is the type that we expect. @@ -14419,6 +14499,7 @@ def test_undeploy_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14461,6 +14542,7 @@ def test_export_model_rest_bad_request(request_type=service.ExportModelRequest): 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.export_model(request) @@ -14491,6 +14573,7 @@ def test_export_model_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.export_model(request) # Establish that the response is the type that we expect. @@ -14528,6 +14611,7 @@ def test_export_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14574,6 +14658,7 @@ def test_get_model_evaluation_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_model_evaluation(request) @@ -14614,6 +14699,7 @@ def test_get_model_evaluation_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_model_evaluation(request) # Establish that the response is the type that we expect. @@ -14655,6 +14741,7 @@ def test_get_model_evaluation_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 = model_evaluation.ModelEvaluation.to_json( model_evaluation.ModelEvaluation() ) @@ -14701,6 +14788,7 @@ def test_list_model_evaluations_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.list_model_evaluations(request) @@ -14736,6 +14824,7 @@ def test_list_model_evaluations_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_model_evaluations(request) # Establish that the response is the type that we expect. @@ -14774,6 +14863,7 @@ def test_list_model_evaluations_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 = service.ListModelEvaluationsResponse.to_json( service.ListModelEvaluationsResponse() ) diff --git a/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_prediction_service.py b/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_prediction_service.py index 619c77d51854..25ca1ff6bc95 100644 --- a/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_prediction_service.py +++ b/packages/google-cloud-automl/tests/unit/gapic/automl_v1/test_prediction_service.py @@ -1956,6 +1956,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq 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.predict(request) @@ -2013,6 +2014,7 @@ def test_predict_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.predict(**mock_args) @@ -2150,6 +2152,7 @@ def test_batch_predict_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.batch_predict(request) @@ -2211,6 +2214,7 @@ def test_batch_predict_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.batch_predict(**mock_args) @@ -2487,6 +2491,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -2520,6 +2525,7 @@ def test_predict_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.predict(request) # Establish that the response is the type that we expect. @@ -2559,6 +2565,7 @@ def test_predict_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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -2605,6 +2612,7 @@ def test_batch_predict_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.batch_predict(request) @@ -2635,6 +2643,7 @@ def test_batch_predict_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.batch_predict(request) # Establish that the response is the type that we expect. @@ -2676,6 +2685,7 @@ def test_batch_predict_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(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_auto_ml.py b/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_auto_ml.py index bf1e2924313b..0b3cbcce8160 100644 --- a/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_auto_ml.py +++ b/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_auto_ml.py @@ -10368,6 +10368,7 @@ def test_create_dataset_rest_required_fields(request_type=service.CreateDatasetR 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_dataset(request) @@ -10426,6 +10427,7 @@ def test_create_dataset_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_dataset(**mock_args) @@ -10560,6 +10562,7 @@ def test_get_dataset_rest_required_fields(request_type=service.GetDatasetRequest 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_dataset(request) @@ -10605,6 +10608,7 @@ def test_get_dataset_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_dataset(**mock_args) @@ -10742,6 +10746,7 @@ def test_list_datasets_rest_required_fields(request_type=service.ListDatasetsReq 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_datasets(request) @@ -10796,6 +10801,7 @@ def test_list_datasets_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_datasets(**mock_args) @@ -10984,6 +10990,7 @@ def test_update_dataset_rest_required_fields(request_type=service.UpdateDatasetR 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_dataset(request) @@ -11035,6 +11042,7 @@ def test_update_dataset_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_dataset(**mock_args) @@ -11169,6 +11177,7 @@ def test_delete_dataset_rest_required_fields(request_type=service.DeleteDatasetR 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_dataset(request) @@ -11212,6 +11221,7 @@ def test_delete_dataset_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.delete_dataset(**mock_args) @@ -11343,6 +11353,7 @@ def test_import_data_rest_required_fields(request_type=service.ImportDataRequest 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.import_data(request) @@ -11397,6 +11408,7 @@ def test_import_data_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.import_data(**mock_args) @@ -11531,6 +11543,7 @@ def test_export_data_rest_required_fields(request_type=service.ExportDataRequest 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.export_data(request) @@ -11587,6 +11600,7 @@ def test_export_data_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.export_data(**mock_args) @@ -11727,6 +11741,7 @@ def test_get_annotation_spec_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_annotation_spec(request) @@ -11774,6 +11789,7 @@ def test_get_annotation_spec_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_annotation_spec(**mock_args) @@ -11905,6 +11921,7 @@ def test_get_table_spec_rest_required_fields(request_type=service.GetTableSpecRe 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_table_spec(request) @@ -11952,6 +11969,7 @@ def test_get_table_spec_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_table_spec(**mock_args) @@ -12094,6 +12112,7 @@ def test_list_table_specs_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.list_table_specs(request) @@ -12151,6 +12170,7 @@ def test_list_table_specs_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_table_specs(**mock_args) @@ -12345,6 +12365,7 @@ def test_update_table_spec_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.update_table_spec(request) @@ -12394,6 +12415,7 @@ def test_update_table_spec_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_table_spec(**mock_args) @@ -12527,6 +12549,7 @@ def test_get_column_spec_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_column_spec(request) @@ -12574,6 +12597,7 @@ def test_get_column_spec_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_column_spec(**mock_args) @@ -12716,6 +12740,7 @@ def test_list_column_specs_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.list_column_specs(request) @@ -12773,6 +12798,7 @@ def test_list_column_specs_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_column_specs(**mock_args) @@ -12969,6 +12995,7 @@ def test_update_column_spec_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.update_column_spec(request) @@ -13018,6 +13045,7 @@ def test_update_column_spec_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_column_spec(**mock_args) @@ -13149,6 +13177,7 @@ def test_create_model_rest_required_fields(request_type=service.CreateModelReque 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_model(request) @@ -13205,6 +13234,7 @@ def test_create_model_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_model(**mock_args) @@ -13339,6 +13369,7 @@ def test_get_model_rest_required_fields(request_type=service.GetModelRequest): 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_model(request) @@ -13384,6 +13415,7 @@ def test_get_model_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_model(**mock_args) @@ -13521,6 +13553,7 @@ def test_list_models_rest_required_fields(request_type=service.ListModelsRequest 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_models(request) @@ -13575,6 +13608,7 @@ def test_list_models_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_models(**mock_args) @@ -13766,6 +13800,7 @@ def test_delete_model_rest_required_fields(request_type=service.DeleteModelReque 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_model(request) @@ -13809,6 +13844,7 @@ def test_delete_model_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.delete_model(**mock_args) @@ -13940,6 +13976,7 @@ def test_deploy_model_rest_required_fields(request_type=service.DeployModelReque 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.deploy_model(request) @@ -13983,6 +14020,7 @@ def test_deploy_model_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.deploy_model(**mock_args) @@ -14114,6 +14152,7 @@ def test_undeploy_model_rest_required_fields(request_type=service.UndeployModelR 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.undeploy_model(request) @@ -14157,6 +14196,7 @@ def test_undeploy_model_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.undeploy_model(**mock_args) @@ -14288,6 +14328,7 @@ def test_export_model_rest_required_fields(request_type=service.ExportModelReque 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.export_model(request) @@ -14344,6 +14385,7 @@ def test_export_model_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.export_model(**mock_args) @@ -14487,6 +14529,7 @@ def test_export_evaluated_examples_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.export_evaluated_examples(request) @@ -14543,6 +14586,7 @@ def test_export_evaluated_examples_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.export_evaluated_examples(**mock_args) @@ -14683,6 +14727,7 @@ def test_get_model_evaluation_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_model_evaluation(request) @@ -14730,6 +14775,7 @@ def test_get_model_evaluation_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_model_evaluation(**mock_args) @@ -14874,6 +14920,7 @@ def test_list_model_evaluations_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.list_model_evaluations(request) @@ -14928,6 +14975,7 @@ def test_list_model_evaluations_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_model_evaluations(**mock_args) @@ -16362,6 +16410,7 @@ def test_create_dataset_rest_bad_request(request_type=service.CreateDatasetReque 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_dataset(request) @@ -16495,6 +16544,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_dataset(request) # Establish that the response is the type that we expect. @@ -16535,6 +16585,7 @@ def test_create_dataset_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 = gca_dataset.Dataset.to_json(gca_dataset.Dataset()) req.return_value.content = return_value @@ -16577,6 +16628,7 @@ def test_get_dataset_rest_bad_request(request_type=service.GetDatasetRequest): 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_dataset(request) @@ -16616,6 +16668,7 @@ def test_get_dataset_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_dataset(request) # Establish that the response is the type that we expect. @@ -16656,6 +16709,7 @@ def test_get_dataset_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 = dataset.Dataset.to_json(dataset.Dataset()) req.return_value.content = return_value @@ -16698,6 +16752,7 @@ def test_list_datasets_rest_bad_request(request_type=service.ListDatasetsRequest 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_datasets(request) @@ -16733,6 +16788,7 @@ def test_list_datasets_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_datasets(request) # Establish that the response is the type that we expect. @@ -16769,6 +16825,7 @@ def test_list_datasets_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 = service.ListDatasetsResponse.to_json( service.ListDatasetsResponse() ) @@ -16815,6 +16872,7 @@ def test_update_dataset_rest_bad_request(request_type=service.UpdateDatasetReque 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_dataset(request) @@ -16950,6 +17008,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_dataset(request) # Establish that the response is the type that we expect. @@ -16990,6 +17049,7 @@ def test_update_dataset_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 = gca_dataset.Dataset.to_json(gca_dataset.Dataset()) req.return_value.content = return_value @@ -17032,6 +17092,7 @@ def test_delete_dataset_rest_bad_request(request_type=service.DeleteDatasetReque 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_dataset(request) @@ -17062,6 +17123,7 @@ def test_delete_dataset_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.delete_dataset(request) # Establish that the response is the type that we expect. @@ -17099,6 +17161,7 @@ def test_delete_dataset_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17141,6 +17204,7 @@ def test_import_data_rest_bad_request(request_type=service.ImportDataRequest): 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.import_data(request) @@ -17171,6 +17235,7 @@ def test_import_data_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.import_data(request) # Establish that the response is the type that we expect. @@ -17208,6 +17273,7 @@ def test_import_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17250,6 +17316,7 @@ def test_export_data_rest_bad_request(request_type=service.ExportDataRequest): 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.export_data(request) @@ -17280,6 +17347,7 @@ def test_export_data_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.export_data(request) # Establish that the response is the type that we expect. @@ -17317,6 +17385,7 @@ def test_export_data_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17363,6 +17432,7 @@ def test_get_annotation_spec_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_annotation_spec(request) @@ -17402,6 +17472,7 @@ def test_get_annotation_spec_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_annotation_spec(request) # Establish that the response is the type that we expect. @@ -17442,6 +17513,7 @@ def test_get_annotation_spec_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 = annotation_spec.AnnotationSpec.to_json( annotation_spec.AnnotationSpec() ) @@ -17488,6 +17560,7 @@ def test_get_table_spec_rest_bad_request(request_type=service.GetTableSpecReques 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_table_spec(request) @@ -17530,6 +17603,7 @@ def test_get_table_spec_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_table_spec(request) # Establish that the response is the type that we expect. @@ -17571,6 +17645,7 @@ def test_get_table_spec_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 = table_spec.TableSpec.to_json(table_spec.TableSpec()) req.return_value.content = return_value @@ -17613,6 +17688,7 @@ def test_list_table_specs_rest_bad_request(request_type=service.ListTableSpecsRe 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_table_specs(request) @@ -17648,6 +17724,7 @@ def test_list_table_specs_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_table_specs(request) # Establish that the response is the type that we expect. @@ -17684,6 +17761,7 @@ def test_list_table_specs_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 = service.ListTableSpecsResponse.to_json( service.ListTableSpecsResponse() ) @@ -17734,6 +17812,7 @@ def test_update_table_spec_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.update_table_spec(request) @@ -17862,6 +17941,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_table_spec(request) # Establish that the response is the type that we expect. @@ -17903,6 +17983,7 @@ def test_update_table_spec_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 = gca_table_spec.TableSpec.to_json(gca_table_spec.TableSpec()) req.return_value.content = return_value @@ -17947,6 +18028,7 @@ def test_get_column_spec_rest_bad_request(request_type=service.GetColumnSpecRequ 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_column_spec(request) @@ -17986,6 +18068,7 @@ def test_get_column_spec_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_column_spec(request) # Establish that the response is the type that we expect. @@ -18024,6 +18107,7 @@ def test_get_column_spec_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 = column_spec.ColumnSpec.to_json(column_spec.ColumnSpec()) req.return_value.content = return_value @@ -18070,6 +18154,7 @@ def test_list_column_specs_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.list_column_specs(request) @@ -18107,6 +18192,7 @@ def test_list_column_specs_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_column_specs(request) # Establish that the response is the type that we expect. @@ -18143,6 +18229,7 @@ def test_list_column_specs_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 = service.ListColumnSpecsResponse.to_json( service.ListColumnSpecsResponse() ) @@ -18193,6 +18280,7 @@ def test_update_column_spec_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.update_column_spec(request) @@ -18339,6 +18427,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_column_spec(request) # Establish that the response is the type that we expect. @@ -18379,6 +18468,7 @@ def test_update_column_spec_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 = gca_column_spec.ColumnSpec.to_json(gca_column_spec.ColumnSpec()) req.return_value.content = return_value @@ -18421,6 +18511,7 @@ def test_create_model_rest_bad_request(request_type=service.CreateModelRequest): 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_model(request) @@ -18609,6 +18700,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_model(request) # Establish that the response is the type that we expect. @@ -18646,6 +18738,7 @@ def test_create_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -18688,6 +18781,7 @@ def test_get_model_rest_bad_request(request_type=service.GetModelRequest): 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_model(request) @@ -18726,6 +18820,7 @@ def test_get_model_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_model(request) # Establish that the response is the type that we expect. @@ -18765,6 +18860,7 @@ def test_get_model_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 = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -18807,6 +18903,7 @@ def test_list_models_rest_bad_request(request_type=service.ListModelsRequest): 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_models(request) @@ -18842,6 +18939,7 @@ def test_list_models_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_models(request) # Establish that the response is the type that we expect. @@ -18878,6 +18976,7 @@ def test_list_models_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 = service.ListModelsResponse.to_json(service.ListModelsResponse()) req.return_value.content = return_value @@ -18920,6 +19019,7 @@ def test_delete_model_rest_bad_request(request_type=service.DeleteModelRequest): 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_model(request) @@ -18950,6 +19050,7 @@ def test_delete_model_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.delete_model(request) # Establish that the response is the type that we expect. @@ -18987,6 +19088,7 @@ def test_delete_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -19029,6 +19131,7 @@ def test_deploy_model_rest_bad_request(request_type=service.DeployModelRequest): 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.deploy_model(request) @@ -19059,6 +19162,7 @@ def test_deploy_model_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.deploy_model(request) # Establish that the response is the type that we expect. @@ -19096,6 +19200,7 @@ def test_deploy_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -19138,6 +19243,7 @@ def test_undeploy_model_rest_bad_request(request_type=service.UndeployModelReque 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.undeploy_model(request) @@ -19168,6 +19274,7 @@ def test_undeploy_model_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.undeploy_model(request) # Establish that the response is the type that we expect. @@ -19205,6 +19312,7 @@ def test_undeploy_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -19247,6 +19355,7 @@ def test_export_model_rest_bad_request(request_type=service.ExportModelRequest): 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.export_model(request) @@ -19277,6 +19386,7 @@ def test_export_model_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.export_model(request) # Establish that the response is the type that we expect. @@ -19314,6 +19424,7 @@ def test_export_model_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -19358,6 +19469,7 @@ def test_export_evaluated_examples_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.export_evaluated_examples(request) @@ -19388,6 +19500,7 @@ def test_export_evaluated_examples_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.export_evaluated_examples(request) # Establish that the response is the type that we expect. @@ -19427,6 +19540,7 @@ def test_export_evaluated_examples_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -19473,6 +19587,7 @@ def test_get_model_evaluation_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_model_evaluation(request) @@ -19513,6 +19628,7 @@ def test_get_model_evaluation_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_model_evaluation(request) # Establish that the response is the type that we expect. @@ -19554,6 +19670,7 @@ def test_get_model_evaluation_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 = model_evaluation.ModelEvaluation.to_json( model_evaluation.ModelEvaluation() ) @@ -19600,6 +19717,7 @@ def test_list_model_evaluations_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.list_model_evaluations(request) @@ -19635,6 +19753,7 @@ def test_list_model_evaluations_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_model_evaluations(request) # Establish that the response is the type that we expect. @@ -19673,6 +19792,7 @@ def test_list_model_evaluations_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 = service.ListModelEvaluationsResponse.to_json( service.ListModelEvaluationsResponse() ) diff --git a/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_prediction_service.py b/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_prediction_service.py index 16fc61240b14..7b578a53cecd 100644 --- a/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_prediction_service.py +++ b/packages/google-cloud-automl/tests/unit/gapic/automl_v1beta1/test_prediction_service.py @@ -1957,6 +1957,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq 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.predict(request) @@ -2014,6 +2015,7 @@ def test_predict_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.predict(**mock_args) @@ -2151,6 +2153,7 @@ def test_batch_predict_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.batch_predict(request) @@ -2213,6 +2216,7 @@ def test_batch_predict_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.batch_predict(**mock_args) @@ -2489,6 +2493,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest 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.predict(request) @@ -2522,6 +2527,7 @@ def test_predict_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.predict(request) # Establish that the response is the type that we expect. @@ -2561,6 +2567,7 @@ def test_predict_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 = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -2607,6 +2614,7 @@ def test_batch_predict_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.batch_predict(request) @@ -2637,6 +2645,7 @@ def test_batch_predict_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.batch_predict(request) # Establish that the response is the type that we expect. @@ -2678,6 +2687,7 @@ def test_batch_predict_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(operations_pb2.Operation()) req.return_value.content = return_value From f05eae5180b45ed8d4eab0a7655e8f330f2136af 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 14:13:27 +0000 Subject: [PATCH 16/16] feat: [google-cloud-orchestration-airflow] Add support for opt-in debug logging (#13322) 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 docs: add examples for kubernetes secret chore: explicitly set fields to field_behavior optional docs: A comment for field `data` in message `.google.cloud.orchestration.airflow.service.v1beta1.UserWorkloadsSecret` is changed docs: A comment for field `data` in message `.google.cloud.orchestration.airflow.service.v1beta1.UserWorkloadsConfigMap` is changed docs: A comment for field `software_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `node_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `private_environment_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `image_version` in message `.google.cloud.orchestration.airflow.service.v1beta1.SoftwareConfig` is changed docs: A comment for field `name` in message `.google.cloud.orchestration.airflow.service.v1beta1.Environment` is changed docs: A comment for field `config` in message `.google.cloud.orchestration.airflow.service.v1beta1.Environment` is changed 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yY2hlc3RyYXRpb24tYWlyZmxvdy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 BEGIN_NESTED_COMMIT docs: [google-cloud-orchestration-airflow] add examples for kubernetes secret chore: explicitly set fields to field_behavior optional PiperOrigin-RevId: 703589766 Source-Link: https://github.com/googleapis/googleapis/commit/22dffa8f690606f58578f478e45172fbf7a06976 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3a83c894fc43e34d7dc94ffa94727d4d5365b410 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yY2hlc3RyYXRpb24tYWlyZmxvdy8uT3dsQm90LnlhbWwiLCJoIjoiM2E4M2M4OTRmYzQzZTM0ZDdkYzk0ZmZhOTQ3MjdkNGQ1MzY1YjQxMCJ9 END_NESTED_COMMIT BEGIN_NESTED_COMMIT docs: [google-cloud-orchestration-airflow] A comment for field `data` in message `.google.cloud.orchestration.airflow.service.v1beta1.UserWorkloadsSecret` is changed docs: A comment for field `data` in message `.google.cloud.orchestration.airflow.service.v1beta1.UserWorkloadsConfigMap` is changed docs: A comment for field `software_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `node_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `private_environment_config` in message `.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentConfig` is changed docs: A comment for field `image_version` in message `.google.cloud.orchestration.airflow.service.v1beta1.SoftwareConfig` is changed docs: A comment for field `name` in message `.google.cloud.orchestration.airflow.service.v1beta1.Environment` is changed docs: A comment for field `config` in message `.google.cloud.orchestration.airflow.service.v1beta1.Environment` is changed PiperOrigin-RevId: 702414176 Source-Link: https://github.com/googleapis/googleapis/commit/0b0960363068a40a6b44001fb73e2bf018a200e6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/bdd2f7d11e7ae9d7bfc00aba2dcd240e944ba4a9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9yY2hlc3RyYXRpb24tYWlyZmxvdy8uT3dsQm90LnlhbWwiLCJoIjoiYmRkMmY3ZDExZTdhZTlkN2JmYzAwYWJhMmRjZDI0MGU5NDRiYTRhOSJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../airflow/service/gapic_version.py | 2 +- .../airflow/service_v1/gapic_version.py | 2 +- .../services/environments/async_client.py | 248 ++- .../services/environments/client.py | 253 ++- .../services/environments/pagers.py | 64 +- .../services/environments/transports/grpc.py | 156 +- .../environments/transports/grpc_asyncio.py | 153 +- .../services/environments/transports/rest.py | 1696 ++++++++++++++-- .../services/image_versions/async_client.py | 64 +- .../services/image_versions/client.py | 69 +- .../services/image_versions/pagers.py | 16 +- .../image_versions/transports/grpc.py | 98 +- .../image_versions/transports/grpc_asyncio.py | 97 +- .../image_versions/transports/rest.py | 244 ++- .../airflow/service_v1/types/environments.py | 44 +- .../airflow/service_v1beta1/gapic_version.py | 2 +- .../services/environments/async_client.py | 256 ++- .../services/environments/client.py | 261 ++- .../services/environments/pagers.py | 64 +- .../services/environments/transports/grpc.py | 158 +- .../environments/transports/grpc_asyncio.py | 155 +- .../services/environments/transports/rest.py | 1760 +++++++++++++++-- .../services/image_versions/async_client.py | 64 +- .../services/image_versions/client.py | 69 +- .../services/image_versions/pagers.py | 16 +- .../image_versions/transports/grpc.py | 98 +- .../image_versions/transports/grpc_asyncio.py | 97 +- .../image_versions/transports/rest.py | 244 ++- .../service_v1beta1/types/environments.py | 44 +- ...loud.orchestration.airflow.service.v1.json | 102 +- ...orchestration.airflow.service.v1beta1.json | 106 +- .../gapic/service_v1/test_environments.py | 105 + .../gapic/service_v1/test_image_versions.py | 10 + .../service_v1beta1/test_environments.py | 108 + .../service_v1beta1/test_image_versions.py | 10 + 35 files changed, 5891 insertions(+), 1044 deletions(-) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service/gapic_version.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service/gapic_version.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/gapic_version.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/gapic_version.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py index 2601c1bca362..64a9186c1e62 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport +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 EnvironmentsAsyncClient: """Managed Apache Airflow Environments.""" @@ -271,6 +281,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.orchestration.airflow.service_v1.EnvironmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "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.orchestration.airflow.service.v1.Environments", + "credentialsType": None, + }, + ) + async def create_environment( self, request: Optional[Union[environments.CreateEnvironmentRequest, dict]] = None, @@ -279,7 +311,7 @@ async def create_environment( environment: Optional[environments.Environment] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new environment. @@ -330,8 +362,10 @@ async def sample_create_environment(): 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.api_core.operation_async.AsyncOperation: @@ -405,7 +439,7 @@ async def get_environment( 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]]] = (), ) -> environments.Environment: r"""Get an existing environment. @@ -448,8 +482,10 @@ async def sample_get_environment(): 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.orchestration.airflow.service_v1.types.Environment: @@ -510,7 +546,7 @@ async def list_environments( 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.ListEnvironmentsAsyncPager: r"""List environments. @@ -555,8 +591,10 @@ async def sample_list_environments(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListEnvironmentsAsyncPager: @@ -633,7 +671,7 @@ async def update_environment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Update an environment. @@ -871,8 +909,10 @@ async def sample_update_environment(): 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.api_core.operation_async.AsyncOperation: @@ -948,7 +988,7 @@ async def delete_environment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Delete an environment. @@ -995,8 +1035,10 @@ async def sample_delete_environment(): 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.api_core.operation_async.AsyncOperation: @@ -1076,7 +1118,7 @@ async def execute_airflow_command( *, 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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Executes Airflow CLI command. @@ -1111,8 +1153,10 @@ async def sample_execute_airflow_command(): 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.orchestration.airflow.service_v1.types.ExecuteAirflowCommandResponse: @@ -1160,7 +1204,7 @@ async def stop_airflow_command( *, 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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Stops Airflow CLI command execution. @@ -1195,8 +1239,10 @@ async def sample_stop_airflow_command(): 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.orchestration.airflow.service_v1.types.StopAirflowCommandResponse: @@ -1244,7 +1290,7 @@ async def poll_airflow_command( *, 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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Polls Airflow CLI command execution and fetches logs. @@ -1279,8 +1325,10 @@ async def sample_poll_airflow_command(): 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.orchestration.airflow.service_v1.types.PollAirflowCommandResponse: @@ -1329,7 +1377,7 @@ async def list_workloads( 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.ListWorkloadsAsyncPager: r"""Lists workloads in a Cloud Composer environment. Workload is a unit that runs a single Composer component. @@ -1379,8 +1427,10 @@ async def sample_list_workloads(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListWorkloadsAsyncPager: @@ -1454,7 +1504,7 @@ async def check_upgrade( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Check if an upgrade operation on the environment will succeed. @@ -1498,8 +1548,10 @@ async def sample_check_upgrade(): 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.api_core.operation_async.AsyncOperation: @@ -1561,7 +1613,7 @@ async def create_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Creates a user workloads Secret. @@ -1615,8 +1667,10 @@ async def sample_create_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -1682,7 +1736,7 @@ async def get_user_workloads_secret( 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Gets an existing user workloads Secret. Values of the "data" field in the response are cleared. @@ -1730,8 +1784,10 @@ async def sample_get_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -1795,7 +1851,7 @@ async def list_user_workloads_secrets( 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.ListUserWorkloadsSecretsAsyncPager: r"""Lists user workloads Secrets. @@ -1843,8 +1899,10 @@ async def sample_list_user_workloads_secrets(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsSecretsAsyncPager: @@ -1921,7 +1979,7 @@ async def update_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Updates a user workloads Secret. @@ -1966,8 +2024,10 @@ async def sample_update_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -2033,7 +2093,7 @@ async def delete_user_workloads_secret( 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 user workloads Secret. @@ -2077,8 +2137,10 @@ async def sample_delete_user_workloads_secret(): 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 @@ -2133,7 +2195,7 @@ async def create_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Creates a user workloads ConfigMap. @@ -2188,8 +2250,10 @@ async def sample_create_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -2255,7 +2319,7 @@ async def get_user_workloads_config_map( 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Gets an existing user workloads ConfigMap. @@ -2302,8 +2366,10 @@ async def sample_get_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -2367,7 +2433,7 @@ async def list_user_workloads_config_maps( 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.ListUserWorkloadsConfigMapsAsyncPager: r"""Lists user workloads ConfigMaps. @@ -2416,8 +2482,10 @@ async def sample_list_user_workloads_config_maps(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsConfigMapsAsyncPager: @@ -2494,7 +2562,7 @@ async def update_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Updates a user workloads ConfigMap. @@ -2540,8 +2608,10 @@ async def sample_update_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -2612,7 +2682,7 @@ async def delete_user_workloads_config_map( 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 user workloads ConfigMap. @@ -2657,8 +2727,10 @@ async def sample_delete_user_workloads_config_map(): 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 @@ -2709,7 +2781,7 @@ async def save_snapshot( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a snapshots of a Cloud Composer environment. @@ -2753,8 +2825,10 @@ async def sample_save_snapshot(): 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.api_core.operation_async.AsyncOperation: @@ -2813,7 +2887,7 @@ async def load_snapshot( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Loads a snapshot of a Cloud Composer environment. @@ -2857,8 +2931,10 @@ async def sample_load_snapshot(): 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.api_core.operation_async.AsyncOperation: @@ -2917,7 +2993,7 @@ async def database_failover( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Triggers database failover (only for highly resilient environments). @@ -2959,8 +3035,10 @@ async def sample_database_failover(): 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.api_core.operation_async.AsyncOperation: @@ -3021,7 +3099,7 @@ async def fetch_database_properties( *, 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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Fetches database properties. @@ -3058,8 +3136,10 @@ async def sample_fetch_database_properties(): 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.orchestration.airflow.service_v1.types.FetchDatabasePropertiesResponse: @@ -3107,7 +3187,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3118,8 +3198,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3160,7 +3242,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3171,8 +3253,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3213,7 +3297,7 @@ async def delete_operation( *, 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 long-running operation. @@ -3229,8 +3313,10 @@ async def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/client.py index f3bed8c1ab6a..251a247d5859 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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 ( @@ -50,6 +51,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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -635,6 +645,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( @@ -697,6 +711,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.orchestration.airflow.service_v1.EnvironmentsClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "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.orchestration.airflow.service.v1.Environments", + "credentialsType": None, + }, + ) + def create_environment( self, request: Optional[Union[environments.CreateEnvironmentRequest, dict]] = None, @@ -705,7 +742,7 @@ def create_environment( environment: Optional[environments.Environment] = 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]]] = (), ) -> operation.Operation: r"""Create a new environment. @@ -756,8 +793,10 @@ def sample_create_environment(): 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.api_core.operation.Operation: @@ -828,7 +867,7 @@ def get_environment( 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]]] = (), ) -> environments.Environment: r"""Get an existing environment. @@ -871,8 +910,10 @@ def sample_get_environment(): 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.orchestration.airflow.service_v1.types.Environment: @@ -930,7 +971,7 @@ def list_environments( 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.ListEnvironmentsPager: r"""List environments. @@ -975,8 +1016,10 @@ def sample_list_environments(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListEnvironmentsPager: @@ -1050,7 +1093,7 @@ def update_environment( 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]]] = (), ) -> operation.Operation: r"""Update an environment. @@ -1288,8 +1331,10 @@ def sample_update_environment(): 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.api_core.operation.Operation: @@ -1362,7 +1407,7 @@ def delete_environment( 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]]] = (), ) -> operation.Operation: r"""Delete an environment. @@ -1409,8 +1454,10 @@ def sample_delete_environment(): 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.api_core.operation.Operation: @@ -1487,7 +1534,7 @@ def execute_airflow_command( *, 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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Executes Airflow CLI command. @@ -1522,8 +1569,10 @@ def sample_execute_airflow_command(): 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.orchestration.airflow.service_v1.types.ExecuteAirflowCommandResponse: @@ -1569,7 +1618,7 @@ def stop_airflow_command( *, 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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Stops Airflow CLI command execution. @@ -1604,8 +1653,10 @@ def sample_stop_airflow_command(): 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.orchestration.airflow.service_v1.types.StopAirflowCommandResponse: @@ -1651,7 +1702,7 @@ def poll_airflow_command( *, 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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Polls Airflow CLI command execution and fetches logs. @@ -1686,8 +1737,10 @@ def sample_poll_airflow_command(): 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.orchestration.airflow.service_v1.types.PollAirflowCommandResponse: @@ -1734,7 +1787,7 @@ def list_workloads( 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.ListWorkloadsPager: r"""Lists workloads in a Cloud Composer environment. Workload is a unit that runs a single Composer component. @@ -1784,8 +1837,10 @@ def sample_list_workloads(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListWorkloadsPager: @@ -1856,7 +1911,7 @@ def check_upgrade( *, 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]]] = (), ) -> operation.Operation: r"""Check if an upgrade operation on the environment will succeed. @@ -1900,8 +1955,10 @@ def sample_check_upgrade(): 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.api_core.operation.Operation: @@ -1961,7 +2018,7 @@ def create_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Creates a user workloads Secret. @@ -2015,8 +2072,10 @@ def sample_create_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -2081,7 +2140,7 @@ def get_user_workloads_secret( 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Gets an existing user workloads Secret. Values of the "data" field in the response are cleared. @@ -2129,8 +2188,10 @@ def sample_get_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -2193,7 +2254,7 @@ def list_user_workloads_secrets( 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.ListUserWorkloadsSecretsPager: r"""Lists user workloads Secrets. @@ -2241,8 +2302,10 @@ def sample_list_user_workloads_secrets(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsSecretsPager: @@ -2318,7 +2381,7 @@ def update_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Updates a user workloads Secret. @@ -2363,8 +2426,10 @@ def sample_update_user_workloads_secret(): 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.orchestration.airflow.service_v1.types.UserWorkloadsSecret: @@ -2429,7 +2494,7 @@ def delete_user_workloads_secret( 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 user workloads Secret. @@ -2473,8 +2538,10 @@ def sample_delete_user_workloads_secret(): 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 @@ -2528,7 +2595,7 @@ def create_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Creates a user workloads ConfigMap. @@ -2583,8 +2650,10 @@ def sample_create_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -2649,7 +2718,7 @@ def get_user_workloads_config_map( 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Gets an existing user workloads ConfigMap. @@ -2696,8 +2765,10 @@ def sample_get_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -2760,7 +2831,7 @@ def list_user_workloads_config_maps( 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.ListUserWorkloadsConfigMapsPager: r"""Lists user workloads ConfigMaps. @@ -2809,8 +2880,10 @@ def sample_list_user_workloads_config_maps(): 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.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsConfigMapsPager: @@ -2886,7 +2959,7 @@ def update_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Updates a user workloads ConfigMap. @@ -2932,8 +3005,10 @@ def sample_update_user_workloads_config_map(): 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.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap: @@ -3003,7 +3078,7 @@ def delete_user_workloads_config_map( 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 user workloads ConfigMap. @@ -3048,8 +3123,10 @@ def sample_delete_user_workloads_config_map(): 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 @@ -3099,7 +3176,7 @@ def save_snapshot( *, 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]]] = (), ) -> operation.Operation: r"""Creates a snapshots of a Cloud Composer environment. @@ -3143,8 +3220,10 @@ def sample_save_snapshot(): 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.api_core.operation.Operation: @@ -3201,7 +3280,7 @@ def load_snapshot( *, 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]]] = (), ) -> operation.Operation: r"""Loads a snapshot of a Cloud Composer environment. @@ -3245,8 +3324,10 @@ def sample_load_snapshot(): 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.api_core.operation.Operation: @@ -3303,7 +3384,7 @@ def database_failover( *, 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]]] = (), ) -> operation.Operation: r"""Triggers database failover (only for highly resilient environments). @@ -3345,8 +3426,10 @@ def sample_database_failover(): 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.api_core.operation.Operation: @@ -3405,7 +3488,7 @@ def fetch_database_properties( *, 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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Fetches database properties. @@ -3442,8 +3525,10 @@ def sample_fetch_database_properties(): 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.orchestration.airflow.service_v1.types.FetchDatabasePropertiesResponse: @@ -3504,7 +3589,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3515,8 +3600,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3557,7 +3644,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3568,8 +3655,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3610,7 +3699,7 @@ def delete_operation( *, 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 long-running operation. @@ -3626,8 +3715,10 @@ def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/pagers.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/pagers.py index e183964e141b..170bba0da9fb 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/pagers.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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 = environments.ListEnvironmentsRequest(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 = environments.ListEnvironmentsRequest(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 = environments.ListWorkloadsRequest(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 = environments.ListWorkloadsRequest(request) @@ -373,7 +381,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. @@ -387,8 +395,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 = environments.ListUserWorkloadsSecretsRequest(request) @@ -447,7 +457,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. @@ -461,8 +471,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 = environments.ListUserWorkloadsSecretsRequest(request) @@ -527,7 +539,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. @@ -541,8 +553,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 = environments.ListUserWorkloadsConfigMapsRequest(request) @@ -603,7 +617,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. @@ -617,8 +631,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 = environments.ListUserWorkloadsConfigMapsRequest(request) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py index 1d424d9d8162..1c5c69304de2 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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 @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1.types import environments from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport +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.orchestration.airflow.service.v1.Environments", + "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.orchestration.airflow.service.v1.Environments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcTransport(EnvironmentsTransport): """gRPC backend transport for Environments. @@ -182,7 +263,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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment", request_serializer=environments.CreateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -296,7 +384,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment", request_serializer=environments.GetEnvironmentRequest.serialize, response_deserializer=environments.Environment.deserialize, @@ -324,7 +412,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments", request_serializer=environments.ListEnvironmentsRequest.serialize, response_deserializer=environments.ListEnvironmentsResponse.deserialize, @@ -350,7 +438,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateEnvironment", request_serializer=environments.UpdateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteEnvironment", request_serializer=environments.DeleteEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def execute_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_airflow_command" not in self._stubs: - self._stubs["execute_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["execute_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ExecuteAirflowCommand", request_serializer=environments.ExecuteAirflowCommandRequest.serialize, response_deserializer=environments.ExecuteAirflowCommandResponse.deserialize, @@ -434,7 +522,7 @@ def stop_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_airflow_command" not in self._stubs: - self._stubs["stop_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["stop_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/StopAirflowCommand", request_serializer=environments.StopAirflowCommandRequest.serialize, response_deserializer=environments.StopAirflowCommandResponse.deserialize, @@ -463,7 +551,7 @@ def poll_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "poll_airflow_command" not in self._stubs: - self._stubs["poll_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["poll_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/PollAirflowCommand", request_serializer=environments.PollAirflowCommandRequest.serialize, response_deserializer=environments.PollAirflowCommandResponse.deserialize, @@ -495,7 +583,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListWorkloads", request_serializer=environments.ListWorkloadsRequest.serialize, response_deserializer=environments.ListWorkloadsResponse.deserialize, @@ -524,7 +612,7 @@ def check_upgrade( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_upgrade" not in self._stubs: - self._stubs["check_upgrade"] = self.grpc_channel.unary_unary( + self._stubs["check_upgrade"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CheckUpgrade", request_serializer=environments.CheckUpgradeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -556,7 +644,9 @@ def create_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user_workloads_secret" not in self._stubs: - self._stubs["create_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsSecret", request_serializer=environments.CreateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -588,7 +678,7 @@ def get_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user_workloads_secret" not in self._stubs: - self._stubs["get_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_user_workloads_secret"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsSecret", request_serializer=environments.GetUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -620,7 +710,9 @@ def list_user_workloads_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_workloads_secrets" not in self._stubs: - self._stubs["list_user_workloads_secrets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_user_workloads_secrets" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsSecrets", request_serializer=environments.ListUserWorkloadsSecretsRequest.serialize, response_deserializer=environments.ListUserWorkloadsSecretsResponse.deserialize, @@ -652,7 +744,9 @@ def update_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user_workloads_secret" not in self._stubs: - self._stubs["update_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsSecret", request_serializer=environments.UpdateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -681,7 +775,9 @@ def delete_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user_workloads_secret" not in self._stubs: - self._stubs["delete_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsSecret", request_serializer=environments.DeleteUserWorkloadsSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -716,7 +812,7 @@ def create_user_workloads_config_map( if "create_user_workloads_config_map" not in self._stubs: self._stubs[ "create_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsConfigMap", request_serializer=environments.CreateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -750,7 +846,7 @@ def get_user_workloads_config_map( if "get_user_workloads_config_map" not in self._stubs: self._stubs[ "get_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsConfigMap", request_serializer=environments.GetUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -785,7 +881,7 @@ def list_user_workloads_config_maps( if "list_user_workloads_config_maps" not in self._stubs: self._stubs[ "list_user_workloads_config_maps" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsConfigMaps", request_serializer=environments.ListUserWorkloadsConfigMapsRequest.serialize, response_deserializer=environments.ListUserWorkloadsConfigMapsResponse.deserialize, @@ -820,7 +916,7 @@ def update_user_workloads_config_map( if "update_user_workloads_config_map" not in self._stubs: self._stubs[ "update_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsConfigMap", request_serializer=environments.UpdateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -852,7 +948,7 @@ def delete_user_workloads_config_map( if "delete_user_workloads_config_map" not in self._stubs: self._stubs[ "delete_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsConfigMap", request_serializer=environments.DeleteUserWorkloadsConfigMapRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -882,7 +978,7 @@ def save_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "save_snapshot" not in self._stubs: - self._stubs["save_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["save_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/SaveSnapshot", request_serializer=environments.SaveSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -912,7 +1008,7 @@ def load_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "load_snapshot" not in self._stubs: - self._stubs["load_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["load_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/LoadSnapshot", request_serializer=environments.LoadSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -939,7 +1035,7 @@ def database_failover( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "database_failover" not in self._stubs: - self._stubs["database_failover"] = self.grpc_channel.unary_unary( + self._stubs["database_failover"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DatabaseFailover", request_serializer=environments.DatabaseFailoverRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -968,7 +1064,7 @@ def fetch_database_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_database_properties" not in self._stubs: - self._stubs["fetch_database_properties"] = self.grpc_channel.unary_unary( + self._stubs["fetch_database_properties"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/FetchDatabaseProperties", request_serializer=environments.FetchDatabasePropertiesRequest.serialize, response_deserializer=environments.FetchDatabasePropertiesResponse.deserialize, @@ -976,7 +1072,7 @@ def fetch_database_properties( return self._stubs["fetch_database_properties"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -988,7 +1084,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1005,7 +1101,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -1024,7 +1120,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py index 30621be46b85..ea3e6aecea44 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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 @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1.types import environments from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .grpc import EnvironmentsGrpcTransport +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.orchestration.airflow.service.v1.Environments", + "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.orchestration.airflow.service.v1.Environments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport): """gRPC AsyncIO backend transport for Environments. @@ -229,10 +311,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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment", request_serializer=environments.CreateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -310,7 +395,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment", request_serializer=environments.GetEnvironmentRequest.serialize, response_deserializer=environments.Environment.deserialize, @@ -339,7 +424,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments", request_serializer=environments.ListEnvironmentsRequest.serialize, response_deserializer=environments.ListEnvironmentsResponse.deserialize, @@ -367,7 +452,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateEnvironment", request_serializer=environments.UpdateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteEnvironment", request_serializer=environments.DeleteEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -424,7 +509,7 @@ def execute_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_airflow_command" not in self._stubs: - self._stubs["execute_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["execute_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ExecuteAirflowCommand", request_serializer=environments.ExecuteAirflowCommandRequest.serialize, response_deserializer=environments.ExecuteAirflowCommandResponse.deserialize, @@ -453,7 +538,7 @@ def stop_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_airflow_command" not in self._stubs: - self._stubs["stop_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["stop_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/StopAirflowCommand", request_serializer=environments.StopAirflowCommandRequest.serialize, response_deserializer=environments.StopAirflowCommandResponse.deserialize, @@ -482,7 +567,7 @@ def poll_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "poll_airflow_command" not in self._stubs: - self._stubs["poll_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["poll_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/PollAirflowCommand", request_serializer=environments.PollAirflowCommandRequest.serialize, response_deserializer=environments.PollAirflowCommandResponse.deserialize, @@ -515,7 +600,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListWorkloads", request_serializer=environments.ListWorkloadsRequest.serialize, response_deserializer=environments.ListWorkloadsResponse.deserialize, @@ -546,7 +631,7 @@ def check_upgrade( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_upgrade" not in self._stubs: - self._stubs["check_upgrade"] = self.grpc_channel.unary_unary( + self._stubs["check_upgrade"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CheckUpgrade", request_serializer=environments.CheckUpgradeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -578,7 +663,9 @@ def create_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user_workloads_secret" not in self._stubs: - self._stubs["create_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsSecret", request_serializer=environments.CreateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -611,7 +698,7 @@ def get_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user_workloads_secret" not in self._stubs: - self._stubs["get_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_user_workloads_secret"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsSecret", request_serializer=environments.GetUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -643,7 +730,9 @@ def list_user_workloads_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_workloads_secrets" not in self._stubs: - self._stubs["list_user_workloads_secrets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_user_workloads_secrets" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsSecrets", request_serializer=environments.ListUserWorkloadsSecretsRequest.serialize, response_deserializer=environments.ListUserWorkloadsSecretsResponse.deserialize, @@ -675,7 +764,9 @@ def update_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user_workloads_secret" not in self._stubs: - self._stubs["update_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsSecret", request_serializer=environments.UpdateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -706,7 +797,9 @@ def delete_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user_workloads_secret" not in self._stubs: - self._stubs["delete_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsSecret", request_serializer=environments.DeleteUserWorkloadsSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -741,7 +834,7 @@ def create_user_workloads_config_map( if "create_user_workloads_config_map" not in self._stubs: self._stubs[ "create_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/CreateUserWorkloadsConfigMap", request_serializer=environments.CreateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -775,7 +868,7 @@ def get_user_workloads_config_map( if "get_user_workloads_config_map" not in self._stubs: self._stubs[ "get_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/GetUserWorkloadsConfigMap", request_serializer=environments.GetUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -810,7 +903,7 @@ def list_user_workloads_config_maps( if "list_user_workloads_config_maps" not in self._stubs: self._stubs[ "list_user_workloads_config_maps" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/ListUserWorkloadsConfigMaps", request_serializer=environments.ListUserWorkloadsConfigMapsRequest.serialize, response_deserializer=environments.ListUserWorkloadsConfigMapsResponse.deserialize, @@ -845,7 +938,7 @@ def update_user_workloads_config_map( if "update_user_workloads_config_map" not in self._stubs: self._stubs[ "update_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/UpdateUserWorkloadsConfigMap", request_serializer=environments.UpdateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -879,7 +972,7 @@ def delete_user_workloads_config_map( if "delete_user_workloads_config_map" not in self._stubs: self._stubs[ "delete_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DeleteUserWorkloadsConfigMap", request_serializer=environments.DeleteUserWorkloadsConfigMapRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -911,7 +1004,7 @@ def save_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "save_snapshot" not in self._stubs: - self._stubs["save_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["save_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/SaveSnapshot", request_serializer=environments.SaveSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -943,7 +1036,7 @@ def load_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "load_snapshot" not in self._stubs: - self._stubs["load_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["load_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/LoadSnapshot", request_serializer=environments.LoadSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -972,7 +1065,7 @@ def database_failover( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "database_failover" not in self._stubs: - self._stubs["database_failover"] = self.grpc_channel.unary_unary( + self._stubs["database_failover"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/DatabaseFailover", request_serializer=environments.DatabaseFailoverRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1001,7 +1094,7 @@ def fetch_database_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_database_properties" not in self._stubs: - self._stubs["fetch_database_properties"] = self.grpc_channel.unary_unary( + self._stubs["fetch_database_properties"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.Environments/FetchDatabaseProperties", request_serializer=environments.FetchDatabasePropertiesRequest.serialize, response_deserializer=environments.FetchDatabasePropertiesResponse.deserialize, @@ -1154,7 +1247,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: @@ -1170,7 +1263,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1187,7 +1280,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -1206,7 +1299,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/rest.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/rest.py index 82bb571a9026..7f897657f5d1 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/rest.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/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 @@ -39,6 +39,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, @@ -255,8 +263,10 @@ def post_update_user_workloads_secret(self, response): def pre_check_upgrade( self, request: environments.CheckUpgradeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.CheckUpgradeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.CheckUpgradeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for check_upgrade Override in a subclass to manipulate the request or metadata @@ -278,8 +288,10 @@ def post_check_upgrade( def pre_create_environment( self, request: environments.CreateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.CreateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.CreateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_environment Override in a subclass to manipulate the request or metadata @@ -301,9 +313,10 @@ def post_create_environment( def pre_create_user_workloads_config_map( self, request: environments.CreateUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.CreateUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.CreateUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_user_workloads_config_map @@ -326,9 +339,10 @@ def post_create_user_workloads_config_map( def pre_create_user_workloads_secret( self, request: environments.CreateUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.CreateUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.CreateUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_user_workloads_secret @@ -351,8 +365,10 @@ def post_create_user_workloads_secret( def pre_database_failover( self, request: environments.DatabaseFailoverRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.DatabaseFailoverRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.DatabaseFailoverRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for database_failover Override in a subclass to manipulate the request or metadata @@ -374,8 +390,10 @@ def post_database_failover( def pre_delete_environment( self, request: environments.DeleteEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.DeleteEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.DeleteEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_environment Override in a subclass to manipulate the request or metadata @@ -397,9 +415,10 @@ def post_delete_environment( def pre_delete_user_workloads_config_map( self, request: environments.DeleteUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.DeleteUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.DeleteUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_user_workloads_config_map @@ -411,9 +430,10 @@ def pre_delete_user_workloads_config_map( def pre_delete_user_workloads_secret( self, request: environments.DeleteUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.DeleteUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.DeleteUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_user_workloads_secret @@ -425,8 +445,11 @@ def pre_delete_user_workloads_secret( def pre_execute_airflow_command( self, request: environments.ExecuteAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ExecuteAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ExecuteAirflowCommandRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for execute_airflow_command Override in a subclass to manipulate the request or metadata @@ -448,8 +471,11 @@ def post_execute_airflow_command( def pre_fetch_database_properties( self, request: environments.FetchDatabasePropertiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.FetchDatabasePropertiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.FetchDatabasePropertiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_database_properties Override in a subclass to manipulate the request or metadata @@ -471,8 +497,10 @@ def post_fetch_database_properties( def pre_get_environment( self, request: environments.GetEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.GetEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_environment Override in a subclass to manipulate the request or metadata @@ -494,9 +522,10 @@ def post_get_environment( def pre_get_user_workloads_config_map( self, request: environments.GetUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.GetUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.GetUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_user_workloads_config_map @@ -519,8 +548,11 @@ def post_get_user_workloads_config_map( def pre_get_user_workloads_secret( self, request: environments.GetUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.GetUserWorkloadsSecretRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.GetUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_user_workloads_secret Override in a subclass to manipulate the request or metadata @@ -542,8 +574,10 @@ def post_get_user_workloads_secret( def pre_list_environments( self, request: environments.ListEnvironmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListEnvironmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListEnvironmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_environments Override in a subclass to manipulate the request or metadata @@ -565,9 +599,10 @@ def post_list_environments( def pre_list_user_workloads_config_maps( self, request: environments.ListUserWorkloadsConfigMapsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.ListUserWorkloadsConfigMapsRequest, Sequence[Tuple[str, str]] + environments.ListUserWorkloadsConfigMapsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_user_workloads_config_maps @@ -590,8 +625,11 @@ def post_list_user_workloads_config_maps( def pre_list_user_workloads_secrets( self, request: environments.ListUserWorkloadsSecretsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListUserWorkloadsSecretsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListUserWorkloadsSecretsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_user_workloads_secrets Override in a subclass to manipulate the request or metadata @@ -613,8 +651,10 @@ def post_list_user_workloads_secrets( def pre_list_workloads( self, request: environments.ListWorkloadsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListWorkloadsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListWorkloadsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workloads Override in a subclass to manipulate the request or metadata @@ -636,8 +676,10 @@ def post_list_workloads( def pre_load_snapshot( self, request: environments.LoadSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.LoadSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.LoadSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for load_snapshot Override in a subclass to manipulate the request or metadata @@ -659,8 +701,10 @@ def post_load_snapshot( def pre_poll_airflow_command( self, request: environments.PollAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.PollAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.PollAirflowCommandRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for poll_airflow_command Override in a subclass to manipulate the request or metadata @@ -682,8 +726,10 @@ def post_poll_airflow_command( def pre_save_snapshot( self, request: environments.SaveSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.SaveSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.SaveSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for save_snapshot Override in a subclass to manipulate the request or metadata @@ -705,8 +751,10 @@ def post_save_snapshot( def pre_stop_airflow_command( self, request: environments.StopAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.StopAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.StopAirflowCommandRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_airflow_command Override in a subclass to manipulate the request or metadata @@ -728,8 +776,10 @@ def post_stop_airflow_command( def pre_update_environment( self, request: environments.UpdateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.UpdateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.UpdateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_environment Override in a subclass to manipulate the request or metadata @@ -751,9 +801,10 @@ def post_update_environment( def pre_update_user_workloads_config_map( self, request: environments.UpdateUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.UpdateUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.UpdateUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_user_workloads_config_map @@ -776,9 +827,10 @@ def post_update_user_workloads_config_map( def pre_update_user_workloads_secret( self, request: environments.UpdateUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.UpdateUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.UpdateUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_user_workloads_secret @@ -801,8 +853,10 @@ def post_update_user_workloads_secret( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -822,8 +876,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -845,8 +901,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -1034,7 +1092,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]]] = (), ) -> operations_pb2.Operation: r"""Call the check upgrade method over HTTP. @@ -1045,8 +1103,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: ~.operations_pb2.Operation: @@ -1059,6 +1119,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCheckUpgrade._get_http_options() ) + request, metadata = self._interceptor.pre_check_upgrade(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseCheckUpgrade._get_transcoded_request( http_options, request @@ -1077,6 +1138,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.orchestration.airflow.service_v1.EnvironmentsClient.CheckUpgrade", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CheckUpgrade", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CheckUpgrade._get_response( self._host, @@ -1096,7 +1184,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_upgrade(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.orchestration.airflow.service_v1.EnvironmentsClient.check_upgrade", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CheckUpgrade", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEnvironment( @@ -1134,7 +1244,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create environment method over HTTP. @@ -1144,8 +1254,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: ~.operations_pb2.Operation: @@ -1158,6 +1270,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_create_environment( request, metadata ) @@ -1174,6 +1287,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.orchestration.airflow.service_v1.EnvironmentsClient.CreateEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CreateEnvironment._get_response( self._host, @@ -1193,7 +1333,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_environment(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.orchestration.airflow.service_v1.EnvironmentsClient.create_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUserWorkloadsConfigMap( @@ -1232,7 +1394,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the create user workloads config map method over HTTP. @@ -1244,8 +1406,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: ~.environments.UserWorkloadsConfigMap: @@ -1258,6 +1422,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_create_user_workloads_config_map( request, metadata ) @@ -1274,6 +1439,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.CreateUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._CreateUserWorkloadsConfigMap._get_response( @@ -1297,7 +1489,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1.EnvironmentsClient.create_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUserWorkloadsSecret( @@ -1336,7 +1552,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the create user workloads secret method over HTTP. @@ -1347,8 +1563,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: ~.environments.UserWorkloadsSecret: @@ -1361,6 +1579,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_create_user_workloads_secret( request, metadata ) @@ -1377,6 +1596,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.CreateUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._CreateUserWorkloadsSecret._get_response( @@ -1400,7 +1646,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1.EnvironmentsClient.create_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "CreateUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DatabaseFailover( @@ -1438,7 +1708,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]]] = (), ) -> operations_pb2.Operation: r"""Call the database failover method over HTTP. @@ -1450,8 +1720,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: ~.operations_pb2.Operation: @@ -1464,6 +1736,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseDatabaseFailover._get_http_options() ) + request, metadata = self._interceptor.pre_database_failover( request, metadata ) @@ -1480,6 +1753,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.orchestration.airflow.service_v1.EnvironmentsClient.DatabaseFailover", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DatabaseFailover", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DatabaseFailover._get_response( self._host, @@ -1499,7 +1799,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_database_failover(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.orchestration.airflow.service_v1.EnvironmentsClient.database_failover", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DatabaseFailover", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEnvironment( @@ -1536,7 +1858,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete environment method over HTTP. @@ -1546,8 +1868,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: ~.operations_pb2.Operation: @@ -1560,6 +1884,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseDeleteEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_environment( request, metadata ) @@ -1572,6 +1897,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.orchestration.airflow.service_v1.EnvironmentsClient.DeleteEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DeleteEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteEnvironment._get_response( self._host, @@ -1590,7 +1942,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_environment(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.orchestration.airflow.service_v1.EnvironmentsClient.delete_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DeleteEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUserWorkloadsConfigMap( @@ -1628,7 +2002,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 user workloads config map method over HTTP. @@ -1640,13 +2014,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user_workloads_config_map( request, metadata ) @@ -1659,6 +2036,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.orchestration.airflow.service_v1.EnvironmentsClient.DeleteUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DeleteUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._DeleteUserWorkloadsConfigMap._get_response( @@ -1711,7 +2115,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 user workloads secret method over HTTP. @@ -1722,13 +2126,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user_workloads_secret( request, metadata ) @@ -1741,6 +2148,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.orchestration.airflow.service_v1.EnvironmentsClient.DeleteUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DeleteUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._DeleteUserWorkloadsSecret._get_response( @@ -1793,7 +2227,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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Call the execute airflow command method over HTTP. @@ -1803,8 +2237,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: ~.environments.ExecuteAirflowCommandResponse: @@ -1816,6 +2252,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseExecuteAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_execute_airflow_command( request, metadata ) @@ -1832,6 +2269,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.ExecuteAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ExecuteAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ExecuteAirflowCommand._get_response( self._host, @@ -1853,7 +2317,31 @@ def __call__( pb_resp = environments.ExecuteAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ExecuteAirflowCommandResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.execute_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ExecuteAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchDatabaseProperties( @@ -1891,7 +2379,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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Call the fetch database properties method over HTTP. @@ -1902,8 +2390,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: ~.environments.FetchDatabasePropertiesResponse: @@ -1915,6 +2405,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseFetchDatabaseProperties._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_database_properties( request, metadata ) @@ -1927,6 +2418,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.FetchDatabaseProperties", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "FetchDatabaseProperties", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._FetchDatabaseProperties._get_response( self._host, @@ -1947,7 +2465,31 @@ def __call__( pb_resp = environments.FetchDatabasePropertiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_database_properties(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.FetchDatabasePropertiesResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.fetch_database_properties", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "FetchDatabaseProperties", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnvironment( @@ -1984,7 +2526,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]]] = (), ) -> environments.Environment: r"""Call the get environment method over HTTP. @@ -1994,8 +2536,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: ~.environments.Environment: @@ -2007,6 +2551,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_transcoded_request( http_options, request @@ -2017,6 +2562,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.GetEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironment._get_response( self._host, @@ -2037,7 +2609,29 @@ def __call__( pb_resp = environments.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.Environment.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.orchestration.airflow.service_v1.EnvironmentsClient.get_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUserWorkloadsConfigMap( @@ -2075,7 +2669,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the get user workloads config map method over HTTP. @@ -2086,8 +2680,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: ~.environments.UserWorkloadsConfigMap: @@ -2100,6 +2696,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_get_user_workloads_config_map( request, metadata ) @@ -2112,6 +2709,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.GetUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._GetUserWorkloadsConfigMap._get_response( @@ -2134,7 +2758,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1.EnvironmentsClient.get_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUserWorkloadsSecret( @@ -2171,7 +2819,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the get user workloads secret method over HTTP. @@ -2181,8 +2829,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: ~.environments.UserWorkloadsSecret: @@ -2195,6 +2845,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_user_workloads_secret( request, metadata ) @@ -2207,6 +2858,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.GetUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetUserWorkloadsSecret._get_response( self._host, @@ -2227,7 +2905,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1.EnvironmentsClient.get_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEnvironments( @@ -2264,7 +2966,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]]] = (), ) -> environments.ListEnvironmentsResponse: r"""Call the list environments method over HTTP. @@ -2275,8 +2977,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: ~.environments.ListEnvironmentsResponse: @@ -2288,6 +2992,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListEnvironments._get_http_options() ) + request, metadata = self._interceptor.pre_list_environments( request, metadata ) @@ -2300,6 +3005,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.ListEnvironments", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListEnvironments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListEnvironments._get_response( self._host, @@ -2320,7 +3052,31 @@ def __call__( pb_resp = environments.ListEnvironmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_environments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.ListEnvironmentsResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.list_environments", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListEnvironments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUserWorkloadsConfigMaps( @@ -2358,7 +3114,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]]] = (), ) -> environments.ListUserWorkloadsConfigMapsResponse: r"""Call the list user workloads config maps method over HTTP. @@ -2370,8 +3126,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: ~.environments.ListUserWorkloadsConfigMapsResponse: @@ -2383,6 +3141,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListUserWorkloadsConfigMaps._get_http_options() ) + request, metadata = self._interceptor.pre_list_user_workloads_config_maps( request, metadata ) @@ -2395,6 +3154,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.ListUserWorkloadsConfigMaps", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListUserWorkloadsConfigMaps", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._ListUserWorkloadsConfigMaps._get_response( @@ -2417,7 +3203,33 @@ def __call__( pb_resp = environments.ListUserWorkloadsConfigMapsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_user_workloads_config_maps(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ListUserWorkloadsConfigMapsResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.list_user_workloads_config_maps", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListUserWorkloadsConfigMaps", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUserWorkloadsSecrets( @@ -2455,7 +3267,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]]] = (), ) -> environments.ListUserWorkloadsSecretsResponse: r"""Call the list user workloads secrets method over HTTP. @@ -2466,8 +3278,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: ~.environments.ListUserWorkloadsSecretsResponse: @@ -2479,6 +3293,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListUserWorkloadsSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_user_workloads_secrets( request, metadata ) @@ -2491,6 +3306,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.ListUserWorkloadsSecrets", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListUserWorkloadsSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._ListUserWorkloadsSecrets._get_response( @@ -2513,7 +3355,31 @@ def __call__( pb_resp = environments.ListUserWorkloadsSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_user_workloads_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ListUserWorkloadsSecretsResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.list_user_workloads_secrets", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListUserWorkloadsSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkloads( @@ -2550,7 +3416,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]]] = (), ) -> environments.ListWorkloadsResponse: r"""Call the list workloads method over HTTP. @@ -2561,8 +3427,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: ~.environments.ListWorkloadsResponse: @@ -2572,6 +3440,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListWorkloads._get_http_options() ) + request, metadata = self._interceptor.pre_list_workloads(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListWorkloads._get_transcoded_request( http_options, request @@ -2582,6 +3451,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.ListWorkloads", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListWorkloads", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListWorkloads._get_response( self._host, @@ -2602,7 +3498,31 @@ def __call__( pb_resp = environments.ListWorkloadsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workloads(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.ListWorkloadsResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.list_workloads", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListWorkloads", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LoadSnapshot( @@ -2640,7 +3560,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]]] = (), ) -> operations_pb2.Operation: r"""Call the load snapshot method over HTTP. @@ -2651,8 +3571,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: ~.operations_pb2.Operation: @@ -2665,6 +3587,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseLoadSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_load_snapshot(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseLoadSnapshot._get_transcoded_request( http_options, request @@ -2683,6 +3606,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.orchestration.airflow.service_v1.EnvironmentsClient.LoadSnapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "LoadSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._LoadSnapshot._get_response( self._host, @@ -2702,7 +3652,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_load_snapshot(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.orchestration.airflow.service_v1.EnvironmentsClient.load_snapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "LoadSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PollAirflowCommand( @@ -2740,7 +3712,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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Call the poll airflow command method over HTTP. @@ -2750,8 +3722,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: ~.environments.PollAirflowCommandResponse: @@ -2763,6 +3737,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BasePollAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_poll_airflow_command( request, metadata ) @@ -2779,6 +3754,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.PollAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "PollAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._PollAirflowCommand._get_response( self._host, @@ -2800,7 +3802,31 @@ def __call__( pb_resp = environments.PollAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_poll_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.PollAirflowCommandResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.poll_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "PollAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SaveSnapshot( @@ -2838,7 +3864,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]]] = (), ) -> operations_pb2.Operation: r"""Call the save snapshot method over HTTP. @@ -2849,8 +3875,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: ~.operations_pb2.Operation: @@ -2863,6 +3891,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseSaveSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_save_snapshot(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseSaveSnapshot._get_transcoded_request( http_options, request @@ -2881,6 +3910,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.orchestration.airflow.service_v1.EnvironmentsClient.SaveSnapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "SaveSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._SaveSnapshot._get_response( self._host, @@ -2900,7 +3956,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_save_snapshot(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.orchestration.airflow.service_v1.EnvironmentsClient.save_snapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "SaveSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopAirflowCommand( @@ -2938,7 +4016,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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Call the stop airflow command method over HTTP. @@ -2948,8 +4026,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: ~.environments.StopAirflowCommandResponse: @@ -2961,6 +4041,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseStopAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_stop_airflow_command( request, metadata ) @@ -2977,6 +4058,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.StopAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "StopAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._StopAirflowCommand._get_response( self._host, @@ -2998,7 +4106,31 @@ def __call__( pb_resp = environments.StopAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.StopAirflowCommandResponse.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.orchestration.airflow.service_v1.EnvironmentsClient.stop_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "StopAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEnvironment( @@ -3036,7 +4168,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update environment method over HTTP. @@ -3046,8 +4178,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: ~.operations_pb2.Operation: @@ -3060,6 +4194,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_update_environment( request, metadata ) @@ -3076,6 +4211,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.orchestration.airflow.service_v1.EnvironmentsClient.UpdateEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._UpdateEnvironment._get_response( self._host, @@ -3095,7 +4257,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_environment(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.orchestration.airflow.service_v1.EnvironmentsClient.update_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUserWorkloadsConfigMap( @@ -3134,7 +4318,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the update user workloads config map method over HTTP. @@ -3146,8 +4330,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: ~.environments.UserWorkloadsConfigMap: @@ -3160,6 +4346,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_update_user_workloads_config_map( request, metadata ) @@ -3176,6 +4363,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.UpdateUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._UpdateUserWorkloadsConfigMap._get_response( @@ -3199,7 +4413,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1.EnvironmentsClient.update_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUserWorkloadsSecret( @@ -3238,7 +4476,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the update user workloads secret method over HTTP. @@ -3249,8 +4487,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: ~.environments.UserWorkloadsSecret: @@ -3263,6 +4503,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_update_user_workloads_secret( request, metadata ) @@ -3279,6 +4520,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 = 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.orchestration.airflow.service_v1.EnvironmentsClient.UpdateUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._UpdateUserWorkloadsSecret._get_response( @@ -3302,7 +4570,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1.EnvironmentsClient.update_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "UpdateUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3574,7 +4866,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3584,13 +4876,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3603,6 +4898,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.orchestration.airflow.service_v1.EnvironmentsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteOperation._get_response( self._host, @@ -3658,7 +4980,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3668,8 +4990,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: operations_pb2.Operation: Response from GetOperation method. @@ -3678,6 +5002,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3690,6 +5015,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.orchestration.airflow.service_v1.EnvironmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetOperation._get_response( self._host, @@ -3709,6 +5061,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.orchestration.airflow.service_v1.EnvironmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3749,7 +5122,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3759,8 +5132,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3769,6 +5144,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3779,6 +5155,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.orchestration.airflow.service_v1.EnvironmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListOperations._get_response( self._host, @@ -3798,6 +5201,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.orchestration.airflow.service_v1.EnvironmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.Environments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/async_client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/async_client.py index 68682cb0ddbd..433e67bec8b2 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/async_client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageVersionsTransport from .transports.grpc_asyncio import ImageVersionsGrpcAsyncIOTransport +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 ImageVersionsAsyncClient: """Readonly service to query available ImageVersions.""" @@ -256,6 +266,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.orchestration.airflow.service_v1.ImageVersionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "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.orchestration.airflow.service.v1.ImageVersions", + "credentialsType": None, + }, + ) + async def list_image_versions( self, request: Optional[Union[image_versions.ListImageVersionsRequest, dict]] = None, @@ -263,7 +295,7 @@ async def list_image_versions( 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.ListImageVersionsAsyncPager: r"""List ImageVersions for provided location. @@ -308,8 +340,10 @@ async def sample_list_image_versions(): 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.orchestration.airflow.service_v1.services.image_versions.pagers.ListImageVersionsAsyncPager: @@ -383,7 +417,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -394,8 +428,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -436,7 +472,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -447,8 +483,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -489,7 +527,7 @@ async def delete_operation( *, 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 long-running operation. @@ -505,8 +543,10 @@ async def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py index 41117d5d931f..ef55915c32ca 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.cloud.orchestration.airflow.service_v1.services.image_versions import pagers @@ -558,6 +568,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( @@ -623,6 +637,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.orchestration.airflow.service_v1.ImageVersionsClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "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.orchestration.airflow.service.v1.ImageVersions", + "credentialsType": None, + }, + ) + def list_image_versions( self, request: Optional[Union[image_versions.ListImageVersionsRequest, dict]] = None, @@ -630,7 +667,7 @@ def list_image_versions( 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.ListImageVersionsPager: r"""List ImageVersions for provided location. @@ -675,8 +712,10 @@ def sample_list_image_versions(): 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.orchestration.airflow.service_v1.services.image_versions.pagers.ListImageVersionsPager: @@ -760,7 +799,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -771,8 +810,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -813,7 +854,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -824,8 +865,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -866,7 +909,7 @@ def delete_operation( *, 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 long-running operation. @@ -882,8 +925,10 @@ def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/pagers.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/pagers.py index 4469614b1e77..70f81c9ab5f0 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/pagers.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 = image_versions.ListImageVersionsRequest(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 = image_versions.ListImageVersionsRequest(request) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py index f9256deebd89..a9a500e76075 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1.types import image_versions from .base import DEFAULT_CLIENT_INFO, ImageVersionsTransport +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.orchestration.airflow.service.v1.ImageVersions", + "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.orchestration.airflow.service.v1.ImageVersions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageVersionsGrpcTransport(ImageVersionsTransport): """gRPC backend transport for ImageVersions. @@ -180,7 +261,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 @@ -257,7 +343,7 @@ def list_image_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_image_versions" not in self._stubs: - self._stubs["list_image_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_image_versions"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions", request_serializer=image_versions.ListImageVersionsRequest.serialize, response_deserializer=image_versions.ListImageVersionsResponse.deserialize, @@ -265,7 +351,7 @@ def list_image_versions( return self._stubs["list_image_versions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -277,7 +363,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -294,7 +380,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -313,7 +399,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py index 345418453c51..998e93cfe47b 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1.types import image_versions from .base import DEFAULT_CLIENT_INFO, ImageVersionsTransport from .grpc import ImageVersionsGrpcTransport +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.orchestration.airflow.service.v1.ImageVersions", + "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.orchestration.airflow.service.v1.ImageVersions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageVersionsGrpcAsyncIOTransport(ImageVersionsTransport): """gRPC AsyncIO backend transport for ImageVersions. @@ -227,10 +309,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 @@ -265,7 +350,7 @@ def list_image_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_image_versions" not in self._stubs: - self._stubs["list_image_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_image_versions"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions", request_serializer=image_versions.ListImageVersionsRequest.serialize, response_deserializer=image_versions.ListImageVersionsResponse.deserialize, @@ -303,7 +388,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: @@ -319,7 +404,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -336,7 +421,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +440,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/rest.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/rest.py index 78d71205d29e..ce3180d59c9d 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/rest.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 @@ -38,6 +38,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, @@ -78,8 +86,10 @@ def post_list_image_versions(self, response): def pre_list_image_versions( self, request: image_versions.ListImageVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_versions.ListImageVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_versions.ListImageVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_image_versions Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_list_image_versions( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -122,8 +134,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -145,8 +159,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -286,7 +302,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]]] = (), ) -> image_versions.ListImageVersionsResponse: r"""Call the list image versions method over HTTP. @@ -297,8 +313,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: ~.image_versions.ListImageVersionsResponse: @@ -310,6 +328,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseListImageVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_image_versions( request, metadata ) @@ -322,6 +341,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 = 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.orchestration.airflow.service_v1.ImageVersionsClient.ListImageVersions", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "ListImageVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._ListImageVersions._get_response( self._host, @@ -342,7 +388,31 @@ def __call__( pb_resp = image_versions.ListImageVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_image_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = image_versions.ListImageVersionsResponse.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.orchestration.airflow.service_v1.ImageVersionsClient.list_image_versions", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "ListImageVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -394,7 +464,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -404,13 +474,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 = ( _BaseImageVersionsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -423,6 +496,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.orchestration.airflow.service_v1.ImageVersionsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._DeleteOperation._get_response( self._host, @@ -478,7 +578,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -488,8 +588,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: operations_pb2.Operation: Response from GetOperation method. @@ -498,6 +600,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseImageVersionsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -508,6 +611,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.orchestration.airflow.service_v1.ImageVersionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._GetOperation._get_response( self._host, @@ -527,6 +657,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.orchestration.airflow.service_v1.ImageVersionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -567,7 +718,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -577,8 +728,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -587,6 +740,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseImageVersionsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -597,6 +751,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.orchestration.airflow.service_v1.ImageVersionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._ListOperations._get_response( self._host, @@ -616,6 +797,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.orchestration.airflow.service_v1.ImageVersionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1.ImageVersions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/types/environments.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/types/environments.py index 05f5049857da..911b3695da9f 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/types/environments.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/types/environments.py @@ -863,6 +863,13 @@ class UserWorkloadsSecret(proto.Message): token, or a key. The values for all keys have to be base64-encoded strings. For details see: https://kubernetes.io/docs/concepts/configuration/secret/ + + Example: + + { + "example": "ZXhhbXBsZV92YWx1ZQ==", + "another-example": + "YW5vdGhlcl9leGFtcGxlX3ZhbHVl" } """ name: str = proto.Field( @@ -915,11 +922,14 @@ class UserWorkloadsConfigMap(proto.Message): ConfigMap, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsConfigMaps/{userWorkloadsConfigMapId}". data (MutableMapping[str, str]): - Optional. The "data" field of Kubernetes - ConfigMap, organized in key-value pairs. For - details see: - + Optional. The "data" field of Kubernetes ConfigMap, + organized in key-value pairs. For details see: https://kubernetes.io/docs/concepts/configuration/configmap/ + + Example: + + { "example_key": "example_value", "another_key": + "another_value" } """ name: str = proto.Field( @@ -1352,14 +1362,14 @@ class EnvironmentConfig(proto.Message): This field is supported for Cloud Composer environments in versions composer-1.\ *.*-airflow-*.*.*. software_config (google.cloud.orchestration.airflow.service_v1.types.SoftwareConfig): - The configuration settings for software - inside the environment. + Optional. The configuration settings for + software inside the environment. node_config (google.cloud.orchestration.airflow.service_v1.types.NodeConfig): - The configuration used for the Kubernetes - Engine cluster. + Optional. The configuration used for the + Kubernetes Engine cluster. private_environment_config (google.cloud.orchestration.airflow.service_v1.types.PrivateEnvironmentConfig): - The configuration used for the Private IP - Cloud Composer environment. + Optional. The configuration used for the + Private IP Cloud Composer environment. web_server_network_access_control (google.cloud.orchestration.airflow.service_v1.types.WebServerNetworkAccessControl): Optional. The network-level access control policy for the Airflow web server. If @@ -1741,10 +1751,10 @@ class SoftwareConfig(proto.Message): Attributes: image_version (str): - The version of the software running in the environment. This - encapsulates both the version of Cloud Composer - functionality and the version of Apache Airflow. It must - match the regular expression + Optional. The version of the software running in the + environment. This encapsulates both the version of Cloud + Composer functionality and the version of Apache Airflow. It + must match the regular expression ``composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)``. When used as input, the server also checks if the provided version is supported and denies the request for an @@ -2748,15 +2758,15 @@ class Environment(proto.Message): Attributes: name (str): - The resource name of the environment, in the - form: + Identifier. The resource name of the + environment, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}" EnvironmentId must start with a lowercase letter followed by up to 63 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. config (google.cloud.orchestration.airflow.service_v1.types.EnvironmentConfig): - Configuration parameters for this + Optional. Configuration parameters for this environment. uuid (str): Output only. The UUID (Universally Unique diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/gapic_version.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/gapic_version.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py index 83f8123afa03..e05b2c33c7f9 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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, @@ -63,6 +64,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport +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 EnvironmentsAsyncClient: """Managed Apache Airflow Environments.""" @@ -276,6 +286,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.orchestration.airflow.service_v1beta1.EnvironmentsAsyncClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "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.orchestration.airflow.service.v1beta1.Environments", + "credentialsType": None, + }, + ) + async def create_environment( self, request: Optional[Union[environments.CreateEnvironmentRequest, dict]] = None, @@ -284,7 +316,7 @@ async def create_environment( environment: Optional[environments.Environment] = 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]]] = (), ) -> operation_async.AsyncOperation: r"""Create a new environment. @@ -335,8 +367,10 @@ async def sample_create_environment(): 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.api_core.operation_async.AsyncOperation: @@ -410,7 +444,7 @@ async def get_environment( 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]]] = (), ) -> environments.Environment: r"""Get an existing environment. @@ -453,8 +487,10 @@ async def sample_get_environment(): 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.orchestration.airflow.service_v1beta1.types.Environment: @@ -515,7 +551,7 @@ async def list_environments( 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.ListEnvironmentsAsyncPager: r"""List environments. @@ -560,8 +596,10 @@ async def sample_list_environments(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListEnvironmentsAsyncPager: @@ -638,7 +676,7 @@ async def update_environment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Update an environment. @@ -913,8 +951,10 @@ async def sample_update_environment(): 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.api_core.operation_async.AsyncOperation: @@ -990,7 +1030,7 @@ async def delete_environment( 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]]] = (), ) -> operation_async.AsyncOperation: r"""Delete an environment. @@ -1037,8 +1077,10 @@ async def sample_delete_environment(): 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.api_core.operation_async.AsyncOperation: @@ -1116,7 +1158,7 @@ async def restart_web_server( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Restart Airflow web server. @@ -1155,8 +1197,10 @@ async def sample_restart_web_server(): 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.api_core.operation_async.AsyncOperation: @@ -1213,7 +1257,7 @@ async def check_upgrade( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Check if an upgrade operation on the environment will succeed. @@ -1256,8 +1300,10 @@ async def sample_check_upgrade(): 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.api_core.operation_async.AsyncOperation: @@ -1317,7 +1363,7 @@ async def execute_airflow_command( *, 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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Executes Airflow CLI command. @@ -1352,8 +1398,10 @@ async def sample_execute_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.ExecuteAirflowCommandResponse: @@ -1401,7 +1449,7 @@ async def stop_airflow_command( *, 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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Stops Airflow CLI command execution. @@ -1436,8 +1484,10 @@ async def sample_stop_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.StopAirflowCommandResponse: @@ -1485,7 +1535,7 @@ async def poll_airflow_command( *, 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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Polls Airflow CLI command execution and fetches logs. @@ -1520,8 +1570,10 @@ async def sample_poll_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.PollAirflowCommandResponse: @@ -1570,7 +1622,7 @@ async def list_workloads( 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.ListWorkloadsAsyncPager: r"""Lists workloads in a Cloud Composer environment. Workload is a unit that runs a single Composer component. @@ -1620,8 +1672,10 @@ async def sample_list_workloads(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListWorkloadsAsyncPager: @@ -1699,7 +1753,7 @@ async def create_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Creates a user workloads Secret. @@ -1753,8 +1807,10 @@ async def sample_create_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -1820,7 +1876,7 @@ async def get_user_workloads_secret( 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Gets an existing user workloads Secret. Values of the "data" field in the response are cleared. @@ -1868,8 +1924,10 @@ async def sample_get_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -1933,7 +1991,7 @@ async def list_user_workloads_secrets( 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.ListUserWorkloadsSecretsAsyncPager: r"""Lists user workloads Secrets. @@ -1981,8 +2039,10 @@ async def sample_list_user_workloads_secrets(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsSecretsAsyncPager: @@ -2059,7 +2119,7 @@ async def update_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Updates a user workloads Secret. @@ -2104,8 +2164,10 @@ async def sample_update_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -2171,7 +2233,7 @@ async def delete_user_workloads_secret( 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 user workloads Secret. @@ -2215,8 +2277,10 @@ async def sample_delete_user_workloads_secret(): 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 @@ -2271,7 +2335,7 @@ async def create_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Creates a user workloads ConfigMap. @@ -2326,8 +2390,10 @@ async def sample_create_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -2393,7 +2459,7 @@ async def get_user_workloads_config_map( 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Gets an existing user workloads ConfigMap. @@ -2440,8 +2506,10 @@ async def sample_get_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -2505,7 +2573,7 @@ async def list_user_workloads_config_maps( 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.ListUserWorkloadsConfigMapsAsyncPager: r"""Lists user workloads ConfigMaps. @@ -2554,8 +2622,10 @@ async def sample_list_user_workloads_config_maps(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsConfigMapsAsyncPager: @@ -2632,7 +2702,7 @@ async def update_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Updates a user workloads ConfigMap. @@ -2678,8 +2748,10 @@ async def sample_update_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -2750,7 +2822,7 @@ async def delete_user_workloads_config_map( 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 user workloads ConfigMap. @@ -2795,8 +2867,10 @@ async def sample_delete_user_workloads_config_map(): 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 @@ -2847,7 +2921,7 @@ async def save_snapshot( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a snapshots of a Cloud Composer environment. @@ -2891,8 +2965,10 @@ async def sample_save_snapshot(): 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.api_core.operation_async.AsyncOperation: @@ -2951,7 +3027,7 @@ async def load_snapshot( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Loads a snapshot of a Cloud Composer environment. @@ -2995,8 +3071,10 @@ async def sample_load_snapshot(): 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.api_core.operation_async.AsyncOperation: @@ -3055,7 +3133,7 @@ async def database_failover( *, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Triggers database failover (only for highly resilient environments). @@ -3097,8 +3175,10 @@ async def sample_database_failover(): 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.api_core.operation_async.AsyncOperation: @@ -3159,7 +3239,7 @@ async def fetch_database_properties( *, 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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Fetches database properties. @@ -3196,8 +3276,10 @@ async def sample_fetch_database_properties(): 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.orchestration.airflow.service_v1beta1.types.FetchDatabasePropertiesResponse: @@ -3245,7 +3327,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3256,8 +3338,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3298,7 +3382,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3309,8 +3393,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3351,7 +3437,7 @@ async def delete_operation( *, 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 long-running operation. @@ -3367,8 +3453,10 @@ async def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py index bd06871bb6f0..5fd7a8248560 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 ( @@ -50,6 +51,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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -640,6 +650,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( @@ -702,6 +716,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.orchestration.airflow.service_v1beta1.EnvironmentsClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "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.orchestration.airflow.service.v1beta1.Environments", + "credentialsType": None, + }, + ) + def create_environment( self, request: Optional[Union[environments.CreateEnvironmentRequest, dict]] = None, @@ -710,7 +747,7 @@ def create_environment( environment: Optional[environments.Environment] = 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]]] = (), ) -> operation.Operation: r"""Create a new environment. @@ -761,8 +798,10 @@ def sample_create_environment(): 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.api_core.operation.Operation: @@ -833,7 +872,7 @@ def get_environment( 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]]] = (), ) -> environments.Environment: r"""Get an existing environment. @@ -876,8 +915,10 @@ def sample_get_environment(): 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.orchestration.airflow.service_v1beta1.types.Environment: @@ -935,7 +976,7 @@ def list_environments( 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.ListEnvironmentsPager: r"""List environments. @@ -980,8 +1021,10 @@ def sample_list_environments(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListEnvironmentsPager: @@ -1055,7 +1098,7 @@ def update_environment( 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]]] = (), ) -> operation.Operation: r"""Update an environment. @@ -1330,8 +1373,10 @@ def sample_update_environment(): 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.api_core.operation.Operation: @@ -1404,7 +1449,7 @@ def delete_environment( 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]]] = (), ) -> operation.Operation: r"""Delete an environment. @@ -1451,8 +1496,10 @@ def sample_delete_environment(): 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.api_core.operation.Operation: @@ -1527,7 +1574,7 @@ def restart_web_server( *, 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]]] = (), ) -> operation.Operation: r"""Restart Airflow web server. @@ -1566,8 +1613,10 @@ def sample_restart_web_server(): 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.api_core.operation.Operation: @@ -1622,7 +1671,7 @@ def check_upgrade( *, 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]]] = (), ) -> operation.Operation: r"""Check if an upgrade operation on the environment will succeed. @@ -1665,8 +1714,10 @@ def sample_check_upgrade(): 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.api_core.operation.Operation: @@ -1724,7 +1775,7 @@ def execute_airflow_command( *, 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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Executes Airflow CLI command. @@ -1759,8 +1810,10 @@ def sample_execute_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.ExecuteAirflowCommandResponse: @@ -1806,7 +1859,7 @@ def stop_airflow_command( *, 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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Stops Airflow CLI command execution. @@ -1841,8 +1894,10 @@ def sample_stop_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.StopAirflowCommandResponse: @@ -1888,7 +1943,7 @@ def poll_airflow_command( *, 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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Polls Airflow CLI command execution and fetches logs. @@ -1923,8 +1978,10 @@ def sample_poll_airflow_command(): 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.orchestration.airflow.service_v1beta1.types.PollAirflowCommandResponse: @@ -1971,7 +2028,7 @@ def list_workloads( 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.ListWorkloadsPager: r"""Lists workloads in a Cloud Composer environment. Workload is a unit that runs a single Composer component. @@ -2021,8 +2078,10 @@ def sample_list_workloads(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListWorkloadsPager: @@ -2097,7 +2156,7 @@ def create_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Creates a user workloads Secret. @@ -2151,8 +2210,10 @@ def sample_create_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -2217,7 +2278,7 @@ def get_user_workloads_secret( 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Gets an existing user workloads Secret. Values of the "data" field in the response are cleared. @@ -2265,8 +2326,10 @@ def sample_get_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -2329,7 +2392,7 @@ def list_user_workloads_secrets( 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.ListUserWorkloadsSecretsPager: r"""Lists user workloads Secrets. @@ -2377,8 +2440,10 @@ def sample_list_user_workloads_secrets(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsSecretsPager: @@ -2454,7 +2519,7 @@ def update_user_workloads_secret( user_workloads_secret: Optional[environments.UserWorkloadsSecret] = 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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Updates a user workloads Secret. @@ -2499,8 +2564,10 @@ def sample_update_user_workloads_secret(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret: @@ -2565,7 +2632,7 @@ def delete_user_workloads_secret( 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 user workloads Secret. @@ -2609,8 +2676,10 @@ def sample_delete_user_workloads_secret(): 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 @@ -2664,7 +2733,7 @@ def create_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Creates a user workloads ConfigMap. @@ -2719,8 +2788,10 @@ def sample_create_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -2785,7 +2856,7 @@ def get_user_workloads_config_map( 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Gets an existing user workloads ConfigMap. @@ -2832,8 +2903,10 @@ def sample_get_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -2896,7 +2969,7 @@ def list_user_workloads_config_maps( 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.ListUserWorkloadsConfigMapsPager: r"""Lists user workloads ConfigMaps. @@ -2945,8 +3018,10 @@ def sample_list_user_workloads_config_maps(): 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.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsConfigMapsPager: @@ -3022,7 +3097,7 @@ def update_user_workloads_config_map( user_workloads_config_map: Optional[environments.UserWorkloadsConfigMap] = 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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Updates a user workloads ConfigMap. @@ -3068,8 +3143,10 @@ def sample_update_user_workloads_config_map(): 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.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap: @@ -3139,7 +3216,7 @@ def delete_user_workloads_config_map( 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 user workloads ConfigMap. @@ -3184,8 +3261,10 @@ def sample_delete_user_workloads_config_map(): 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 @@ -3235,7 +3314,7 @@ def save_snapshot( *, 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]]] = (), ) -> operation.Operation: r"""Creates a snapshots of a Cloud Composer environment. @@ -3279,8 +3358,10 @@ def sample_save_snapshot(): 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.api_core.operation.Operation: @@ -3337,7 +3418,7 @@ def load_snapshot( *, 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]]] = (), ) -> operation.Operation: r"""Loads a snapshot of a Cloud Composer environment. @@ -3381,8 +3462,10 @@ def sample_load_snapshot(): 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.api_core.operation.Operation: @@ -3439,7 +3522,7 @@ def database_failover( *, 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]]] = (), ) -> operation.Operation: r"""Triggers database failover (only for highly resilient environments). @@ -3481,8 +3564,10 @@ def sample_database_failover(): 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.api_core.operation.Operation: @@ -3541,7 +3626,7 @@ def fetch_database_properties( *, 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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Fetches database properties. @@ -3578,8 +3663,10 @@ def sample_fetch_database_properties(): 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.orchestration.airflow.service_v1beta1.types.FetchDatabasePropertiesResponse: @@ -3640,7 +3727,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -3651,8 +3738,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -3693,7 +3782,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -3704,8 +3793,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -3746,7 +3837,7 @@ def delete_operation( *, 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 long-running operation. @@ -3762,8 +3853,10 @@ def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/pagers.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/pagers.py index 4f925319ea37..de79e4470786 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/pagers.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 = environments.ListEnvironmentsRequest(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 = environments.ListEnvironmentsRequest(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 = environments.ListWorkloadsRequest(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 = environments.ListWorkloadsRequest(request) @@ -373,7 +381,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. @@ -387,8 +395,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 = environments.ListUserWorkloadsSecretsRequest(request) @@ -447,7 +457,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. @@ -461,8 +471,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 = environments.ListUserWorkloadsSecretsRequest(request) @@ -527,7 +539,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. @@ -541,8 +553,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 = environments.ListUserWorkloadsConfigMapsRequest(request) @@ -603,7 +617,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. @@ -617,8 +631,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 = environments.ListUserWorkloadsConfigMapsRequest(request) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py index 6acb73c34b4e..e92d09f5d29f 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1beta1.types import environments from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport +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.orchestration.airflow.service.v1beta1.Environments", + "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.orchestration.airflow.service.v1beta1.Environments", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcTransport(EnvironmentsTransport): """gRPC backend transport for Environments. @@ -182,7 +263,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 @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateEnvironment", request_serializer=environments.CreateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -296,7 +384,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetEnvironment", request_serializer=environments.GetEnvironmentRequest.serialize, response_deserializer=environments.Environment.deserialize, @@ -324,7 +412,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListEnvironments", request_serializer=environments.ListEnvironmentsRequest.serialize, response_deserializer=environments.ListEnvironmentsResponse.deserialize, @@ -350,7 +438,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateEnvironment", request_serializer=environments.UpdateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteEnvironment", request_serializer=environments.DeleteEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +490,7 @@ def restart_web_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_web_server" not in self._stubs: - self._stubs["restart_web_server"] = self.grpc_channel.unary_unary( + self._stubs["restart_web_server"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/RestartWebServer", request_serializer=environments.RestartWebServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +519,7 @@ def check_upgrade( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_upgrade" not in self._stubs: - self._stubs["check_upgrade"] = self.grpc_channel.unary_unary( + self._stubs["check_upgrade"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CheckUpgrade", request_serializer=environments.CheckUpgradeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +548,7 @@ def execute_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_airflow_command" not in self._stubs: - self._stubs["execute_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["execute_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ExecuteAirflowCommand", request_serializer=environments.ExecuteAirflowCommandRequest.serialize, response_deserializer=environments.ExecuteAirflowCommandResponse.deserialize, @@ -489,7 +577,7 @@ def stop_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_airflow_command" not in self._stubs: - self._stubs["stop_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["stop_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/StopAirflowCommand", request_serializer=environments.StopAirflowCommandRequest.serialize, response_deserializer=environments.StopAirflowCommandResponse.deserialize, @@ -518,7 +606,7 @@ def poll_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "poll_airflow_command" not in self._stubs: - self._stubs["poll_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["poll_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/PollAirflowCommand", request_serializer=environments.PollAirflowCommandRequest.serialize, response_deserializer=environments.PollAirflowCommandResponse.deserialize, @@ -550,7 +638,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListWorkloads", request_serializer=environments.ListWorkloadsRequest.serialize, response_deserializer=environments.ListWorkloadsResponse.deserialize, @@ -582,7 +670,9 @@ def create_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user_workloads_secret" not in self._stubs: - self._stubs["create_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateUserWorkloadsSecret", request_serializer=environments.CreateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -614,7 +704,7 @@ def get_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user_workloads_secret" not in self._stubs: - self._stubs["get_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_user_workloads_secret"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetUserWorkloadsSecret", request_serializer=environments.GetUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -646,7 +736,9 @@ def list_user_workloads_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_workloads_secrets" not in self._stubs: - self._stubs["list_user_workloads_secrets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_user_workloads_secrets" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListUserWorkloadsSecrets", request_serializer=environments.ListUserWorkloadsSecretsRequest.serialize, response_deserializer=environments.ListUserWorkloadsSecretsResponse.deserialize, @@ -678,7 +770,9 @@ def update_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user_workloads_secret" not in self._stubs: - self._stubs["update_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateUserWorkloadsSecret", request_serializer=environments.UpdateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -707,7 +801,9 @@ def delete_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user_workloads_secret" not in self._stubs: - self._stubs["delete_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteUserWorkloadsSecret", request_serializer=environments.DeleteUserWorkloadsSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -742,7 +838,7 @@ def create_user_workloads_config_map( if "create_user_workloads_config_map" not in self._stubs: self._stubs[ "create_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateUserWorkloadsConfigMap", request_serializer=environments.CreateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -776,7 +872,7 @@ def get_user_workloads_config_map( if "get_user_workloads_config_map" not in self._stubs: self._stubs[ "get_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetUserWorkloadsConfigMap", request_serializer=environments.GetUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -811,7 +907,7 @@ def list_user_workloads_config_maps( if "list_user_workloads_config_maps" not in self._stubs: self._stubs[ "list_user_workloads_config_maps" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListUserWorkloadsConfigMaps", request_serializer=environments.ListUserWorkloadsConfigMapsRequest.serialize, response_deserializer=environments.ListUserWorkloadsConfigMapsResponse.deserialize, @@ -846,7 +942,7 @@ def update_user_workloads_config_map( if "update_user_workloads_config_map" not in self._stubs: self._stubs[ "update_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateUserWorkloadsConfigMap", request_serializer=environments.UpdateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -878,7 +974,7 @@ def delete_user_workloads_config_map( if "delete_user_workloads_config_map" not in self._stubs: self._stubs[ "delete_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteUserWorkloadsConfigMap", request_serializer=environments.DeleteUserWorkloadsConfigMapRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -908,7 +1004,7 @@ def save_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "save_snapshot" not in self._stubs: - self._stubs["save_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["save_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/SaveSnapshot", request_serializer=environments.SaveSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -938,7 +1034,7 @@ def load_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "load_snapshot" not in self._stubs: - self._stubs["load_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["load_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/LoadSnapshot", request_serializer=environments.LoadSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -965,7 +1061,7 @@ def database_failover( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "database_failover" not in self._stubs: - self._stubs["database_failover"] = self.grpc_channel.unary_unary( + self._stubs["database_failover"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DatabaseFailover", request_serializer=environments.DatabaseFailoverRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -994,7 +1090,7 @@ def fetch_database_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_database_properties" not in self._stubs: - self._stubs["fetch_database_properties"] = self.grpc_channel.unary_unary( + self._stubs["fetch_database_properties"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/FetchDatabaseProperties", request_serializer=environments.FetchDatabasePropertiesRequest.serialize, response_deserializer=environments.FetchDatabasePropertiesResponse.deserialize, @@ -1002,7 +1098,7 @@ def fetch_database_properties( return self._stubs["fetch_database_properties"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1014,7 +1110,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1031,7 +1127,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -1050,7 +1146,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py index a0c8bce711b5..77b0120283bc 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1beta1.types import environments from .base import DEFAULT_CLIENT_INFO, EnvironmentsTransport from .grpc import EnvironmentsGrpcTransport +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.orchestration.airflow.service.v1beta1.Environments", + "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.orchestration.airflow.service.v1beta1.Environments", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport): """gRPC AsyncIO backend transport for Environments. @@ -229,10 +311,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 @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def create_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_environment" not in self._stubs: - self._stubs["create_environment"] = self.grpc_channel.unary_unary( + self._stubs["create_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateEnvironment", request_serializer=environments.CreateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -310,7 +395,7 @@ def get_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_environment" not in self._stubs: - self._stubs["get_environment"] = self.grpc_channel.unary_unary( + self._stubs["get_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetEnvironment", request_serializer=environments.GetEnvironmentRequest.serialize, response_deserializer=environments.Environment.deserialize, @@ -339,7 +424,7 @@ def list_environments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_environments" not in self._stubs: - self._stubs["list_environments"] = self.grpc_channel.unary_unary( + self._stubs["list_environments"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListEnvironments", request_serializer=environments.ListEnvironmentsRequest.serialize, response_deserializer=environments.ListEnvironmentsResponse.deserialize, @@ -367,7 +452,7 @@ def update_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_environment" not in self._stubs: - self._stubs["update_environment"] = self.grpc_channel.unary_unary( + self._stubs["update_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateEnvironment", request_serializer=environments.UpdateEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -395,7 +480,7 @@ def delete_environment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_environment" not in self._stubs: - self._stubs["delete_environment"] = self.grpc_channel.unary_unary( + self._stubs["delete_environment"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteEnvironment", request_serializer=environments.DeleteEnvironmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -423,7 +508,7 @@ def restart_web_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_web_server" not in self._stubs: - self._stubs["restart_web_server"] = self.grpc_channel.unary_unary( + self._stubs["restart_web_server"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/RestartWebServer", request_serializer=environments.RestartWebServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -454,7 +539,7 @@ def check_upgrade( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_upgrade" not in self._stubs: - self._stubs["check_upgrade"] = self.grpc_channel.unary_unary( + self._stubs["check_upgrade"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CheckUpgrade", request_serializer=environments.CheckUpgradeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -483,7 +568,7 @@ def execute_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_airflow_command" not in self._stubs: - self._stubs["execute_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["execute_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ExecuteAirflowCommand", request_serializer=environments.ExecuteAirflowCommandRequest.serialize, response_deserializer=environments.ExecuteAirflowCommandResponse.deserialize, @@ -512,7 +597,7 @@ def stop_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_airflow_command" not in self._stubs: - self._stubs["stop_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["stop_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/StopAirflowCommand", request_serializer=environments.StopAirflowCommandRequest.serialize, response_deserializer=environments.StopAirflowCommandResponse.deserialize, @@ -541,7 +626,7 @@ def poll_airflow_command( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "poll_airflow_command" not in self._stubs: - self._stubs["poll_airflow_command"] = self.grpc_channel.unary_unary( + self._stubs["poll_airflow_command"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/PollAirflowCommand", request_serializer=environments.PollAirflowCommandRequest.serialize, response_deserializer=environments.PollAirflowCommandResponse.deserialize, @@ -574,7 +659,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListWorkloads", request_serializer=environments.ListWorkloadsRequest.serialize, response_deserializer=environments.ListWorkloadsResponse.deserialize, @@ -606,7 +691,9 @@ def create_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user_workloads_secret" not in self._stubs: - self._stubs["create_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateUserWorkloadsSecret", request_serializer=environments.CreateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -639,7 +726,7 @@ def get_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user_workloads_secret" not in self._stubs: - self._stubs["get_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs["get_user_workloads_secret"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetUserWorkloadsSecret", request_serializer=environments.GetUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -671,7 +758,9 @@ def list_user_workloads_secrets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_user_workloads_secrets" not in self._stubs: - self._stubs["list_user_workloads_secrets"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_user_workloads_secrets" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListUserWorkloadsSecrets", request_serializer=environments.ListUserWorkloadsSecretsRequest.serialize, response_deserializer=environments.ListUserWorkloadsSecretsResponse.deserialize, @@ -703,7 +792,9 @@ def update_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user_workloads_secret" not in self._stubs: - self._stubs["update_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateUserWorkloadsSecret", request_serializer=environments.UpdateUserWorkloadsSecretRequest.serialize, response_deserializer=environments.UserWorkloadsSecret.deserialize, @@ -734,7 +825,9 @@ def delete_user_workloads_secret( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user_workloads_secret" not in self._stubs: - self._stubs["delete_user_workloads_secret"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_user_workloads_secret" + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteUserWorkloadsSecret", request_serializer=environments.DeleteUserWorkloadsSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -769,7 +862,7 @@ def create_user_workloads_config_map( if "create_user_workloads_config_map" not in self._stubs: self._stubs[ "create_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateUserWorkloadsConfigMap", request_serializer=environments.CreateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -803,7 +896,7 @@ def get_user_workloads_config_map( if "get_user_workloads_config_map" not in self._stubs: self._stubs[ "get_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/GetUserWorkloadsConfigMap", request_serializer=environments.GetUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -838,7 +931,7 @@ def list_user_workloads_config_maps( if "list_user_workloads_config_maps" not in self._stubs: self._stubs[ "list_user_workloads_config_maps" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/ListUserWorkloadsConfigMaps", request_serializer=environments.ListUserWorkloadsConfigMapsRequest.serialize, response_deserializer=environments.ListUserWorkloadsConfigMapsResponse.deserialize, @@ -873,7 +966,7 @@ def update_user_workloads_config_map( if "update_user_workloads_config_map" not in self._stubs: self._stubs[ "update_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateUserWorkloadsConfigMap", request_serializer=environments.UpdateUserWorkloadsConfigMapRequest.serialize, response_deserializer=environments.UserWorkloadsConfigMap.deserialize, @@ -907,7 +1000,7 @@ def delete_user_workloads_config_map( if "delete_user_workloads_config_map" not in self._stubs: self._stubs[ "delete_user_workloads_config_map" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteUserWorkloadsConfigMap", request_serializer=environments.DeleteUserWorkloadsConfigMapRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -939,7 +1032,7 @@ def save_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "save_snapshot" not in self._stubs: - self._stubs["save_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["save_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/SaveSnapshot", request_serializer=environments.SaveSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -971,7 +1064,7 @@ def load_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "load_snapshot" not in self._stubs: - self._stubs["load_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["load_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/LoadSnapshot", request_serializer=environments.LoadSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1000,7 +1093,7 @@ def database_failover( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "database_failover" not in self._stubs: - self._stubs["database_failover"] = self.grpc_channel.unary_unary( + self._stubs["database_failover"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/DatabaseFailover", request_serializer=environments.DatabaseFailoverRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1029,7 +1122,7 @@ def fetch_database_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_database_properties" not in self._stubs: - self._stubs["fetch_database_properties"] = self.grpc_channel.unary_unary( + self._stubs["fetch_database_properties"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.Environments/FetchDatabaseProperties", request_serializer=environments.FetchDatabasePropertiesRequest.serialize, response_deserializer=environments.FetchDatabasePropertiesResponse.deserialize, @@ -1187,7 +1280,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: @@ -1203,7 +1296,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -1220,7 +1313,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -1239,7 +1332,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/rest.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/rest.py index e3100b9358d8..213d8286c44a 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/rest.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 @@ -39,6 +39,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, @@ -263,8 +271,10 @@ def post_update_user_workloads_secret(self, response): def pre_check_upgrade( self, request: environments.CheckUpgradeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.CheckUpgradeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.CheckUpgradeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for check_upgrade Override in a subclass to manipulate the request or metadata @@ -286,8 +296,10 @@ def post_check_upgrade( def pre_create_environment( self, request: environments.CreateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.CreateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.CreateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_environment Override in a subclass to manipulate the request or metadata @@ -309,9 +321,10 @@ def post_create_environment( def pre_create_user_workloads_config_map( self, request: environments.CreateUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.CreateUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.CreateUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_user_workloads_config_map @@ -334,9 +347,10 @@ def post_create_user_workloads_config_map( def pre_create_user_workloads_secret( self, request: environments.CreateUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.CreateUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.CreateUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_user_workloads_secret @@ -359,8 +373,10 @@ def post_create_user_workloads_secret( def pre_database_failover( self, request: environments.DatabaseFailoverRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.DatabaseFailoverRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.DatabaseFailoverRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for database_failover Override in a subclass to manipulate the request or metadata @@ -382,8 +398,10 @@ def post_database_failover( def pre_delete_environment( self, request: environments.DeleteEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.DeleteEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.DeleteEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_environment Override in a subclass to manipulate the request or metadata @@ -405,9 +423,10 @@ def post_delete_environment( def pre_delete_user_workloads_config_map( self, request: environments.DeleteUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.DeleteUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.DeleteUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_user_workloads_config_map @@ -419,9 +438,10 @@ def pre_delete_user_workloads_config_map( def pre_delete_user_workloads_secret( self, request: environments.DeleteUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.DeleteUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.DeleteUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_user_workloads_secret @@ -433,8 +453,11 @@ def pre_delete_user_workloads_secret( def pre_execute_airflow_command( self, request: environments.ExecuteAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ExecuteAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ExecuteAirflowCommandRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for execute_airflow_command Override in a subclass to manipulate the request or metadata @@ -456,8 +479,11 @@ def post_execute_airflow_command( def pre_fetch_database_properties( self, request: environments.FetchDatabasePropertiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.FetchDatabasePropertiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.FetchDatabasePropertiesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_database_properties Override in a subclass to manipulate the request or metadata @@ -479,8 +505,10 @@ def post_fetch_database_properties( def pre_get_environment( self, request: environments.GetEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.GetEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_environment Override in a subclass to manipulate the request or metadata @@ -502,9 +530,10 @@ def post_get_environment( def pre_get_user_workloads_config_map( self, request: environments.GetUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.GetUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.GetUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_user_workloads_config_map @@ -527,8 +556,11 @@ def post_get_user_workloads_config_map( def pre_get_user_workloads_secret( self, request: environments.GetUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.GetUserWorkloadsSecretRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.GetUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_user_workloads_secret Override in a subclass to manipulate the request or metadata @@ -550,8 +582,10 @@ def post_get_user_workloads_secret( def pre_list_environments( self, request: environments.ListEnvironmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListEnvironmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListEnvironmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_environments Override in a subclass to manipulate the request or metadata @@ -573,9 +607,10 @@ def post_list_environments( def pre_list_user_workloads_config_maps( self, request: environments.ListUserWorkloadsConfigMapsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.ListUserWorkloadsConfigMapsRequest, Sequence[Tuple[str, str]] + environments.ListUserWorkloadsConfigMapsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_user_workloads_config_maps @@ -598,8 +633,11 @@ def post_list_user_workloads_config_maps( def pre_list_user_workloads_secrets( self, request: environments.ListUserWorkloadsSecretsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListUserWorkloadsSecretsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListUserWorkloadsSecretsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_user_workloads_secrets Override in a subclass to manipulate the request or metadata @@ -621,8 +659,10 @@ def post_list_user_workloads_secrets( def pre_list_workloads( self, request: environments.ListWorkloadsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.ListWorkloadsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.ListWorkloadsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workloads Override in a subclass to manipulate the request or metadata @@ -644,8 +684,10 @@ def post_list_workloads( def pre_load_snapshot( self, request: environments.LoadSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.LoadSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.LoadSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for load_snapshot Override in a subclass to manipulate the request or metadata @@ -667,8 +709,10 @@ def post_load_snapshot( def pre_poll_airflow_command( self, request: environments.PollAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.PollAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.PollAirflowCommandRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for poll_airflow_command Override in a subclass to manipulate the request or metadata @@ -690,8 +734,10 @@ def post_poll_airflow_command( def pre_restart_web_server( self, request: environments.RestartWebServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.RestartWebServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.RestartWebServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for restart_web_server Override in a subclass to manipulate the request or metadata @@ -713,8 +759,10 @@ def post_restart_web_server( def pre_save_snapshot( self, request: environments.SaveSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.SaveSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.SaveSnapshotRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for save_snapshot Override in a subclass to manipulate the request or metadata @@ -736,8 +784,10 @@ def post_save_snapshot( def pre_stop_airflow_command( self, request: environments.StopAirflowCommandRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.StopAirflowCommandRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.StopAirflowCommandRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for stop_airflow_command Override in a subclass to manipulate the request or metadata @@ -759,8 +809,10 @@ def post_stop_airflow_command( def pre_update_environment( self, request: environments.UpdateEnvironmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[environments.UpdateEnvironmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + environments.UpdateEnvironmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_environment Override in a subclass to manipulate the request or metadata @@ -782,9 +834,10 @@ def post_update_environment( def pre_update_user_workloads_config_map( self, request: environments.UpdateUserWorkloadsConfigMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.UpdateUserWorkloadsConfigMapRequest, Sequence[Tuple[str, str]] + environments.UpdateUserWorkloadsConfigMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_user_workloads_config_map @@ -807,9 +860,10 @@ def post_update_user_workloads_config_map( def pre_update_user_workloads_secret( self, request: environments.UpdateUserWorkloadsSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - environments.UpdateUserWorkloadsSecretRequest, Sequence[Tuple[str, str]] + environments.UpdateUserWorkloadsSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_user_workloads_secret @@ -832,8 +886,10 @@ def post_update_user_workloads_secret( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -853,8 +909,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -876,8 +934,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -1065,7 +1125,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]]] = (), ) -> operations_pb2.Operation: r"""Call the check upgrade method over HTTP. @@ -1076,8 +1136,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: ~.operations_pb2.Operation: @@ -1090,6 +1152,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCheckUpgrade._get_http_options() ) + request, metadata = self._interceptor.pre_check_upgrade(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseCheckUpgrade._get_transcoded_request( http_options, request @@ -1108,6 +1171,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.CheckUpgrade", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CheckUpgrade", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CheckUpgrade._get_response( self._host, @@ -1127,7 +1217,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_upgrade(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.check_upgrade", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CheckUpgrade", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEnvironment( @@ -1165,7 +1277,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create environment method over HTTP. @@ -1175,8 +1287,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: ~.operations_pb2.Operation: @@ -1189,6 +1303,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_create_environment( request, metadata ) @@ -1205,6 +1320,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.CreateEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._CreateEnvironment._get_response( self._host, @@ -1224,7 +1366,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_environment(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.create_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUserWorkloadsConfigMap( @@ -1263,7 +1427,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the create user workloads config map method over HTTP. @@ -1275,8 +1439,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: ~.environments.UserWorkloadsConfigMap: @@ -1289,6 +1455,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_create_user_workloads_config_map( request, metadata ) @@ -1305,6 +1472,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.CreateUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._CreateUserWorkloadsConfigMap._get_response( @@ -1328,7 +1522,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.create_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUserWorkloadsSecret( @@ -1367,7 +1585,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the create user workloads secret method over HTTP. @@ -1378,8 +1596,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: ~.environments.UserWorkloadsSecret: @@ -1392,6 +1612,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseCreateUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_create_user_workloads_secret( request, metadata ) @@ -1408,6 +1629,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.CreateUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._CreateUserWorkloadsSecret._get_response( @@ -1431,7 +1679,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.create_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "CreateUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DatabaseFailover( @@ -1469,7 +1741,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]]] = (), ) -> operations_pb2.Operation: r"""Call the database failover method over HTTP. @@ -1481,8 +1753,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: ~.operations_pb2.Operation: @@ -1495,6 +1769,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseDatabaseFailover._get_http_options() ) + request, metadata = self._interceptor.pre_database_failover( request, metadata ) @@ -1511,6 +1786,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.DatabaseFailover", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DatabaseFailover", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DatabaseFailover._get_response( self._host, @@ -1530,7 +1832,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_database_failover(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.database_failover", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DatabaseFailover", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteEnvironment( @@ -1567,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete environment method over HTTP. @@ -1577,8 +1901,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: ~.operations_pb2.Operation: @@ -1591,6 +1917,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseDeleteEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_environment( request, metadata ) @@ -1603,6 +1930,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.DeleteEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DeleteEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteEnvironment._get_response( self._host, @@ -1621,7 +1975,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_environment(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.delete_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DeleteEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUserWorkloadsConfigMap( @@ -1659,7 +2035,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 user workloads config map method over HTTP. @@ -1671,13 +2047,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user_workloads_config_map( request, metadata ) @@ -1690,6 +2069,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.DeleteUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DeleteUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._DeleteUserWorkloadsConfigMap._get_response( @@ -1742,7 +2148,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 user workloads secret method over HTTP. @@ -1753,13 +2159,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user_workloads_secret( request, metadata ) @@ -1772,6 +2181,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.DeleteUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DeleteUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._DeleteUserWorkloadsSecret._get_response( @@ -1824,7 +2260,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]]] = (), ) -> environments.ExecuteAirflowCommandResponse: r"""Call the execute airflow command method over HTTP. @@ -1834,8 +2270,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: ~.environments.ExecuteAirflowCommandResponse: @@ -1847,6 +2285,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseExecuteAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_execute_airflow_command( request, metadata ) @@ -1863,6 +2302,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ExecuteAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ExecuteAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ExecuteAirflowCommand._get_response( self._host, @@ -1884,7 +2350,31 @@ def __call__( pb_resp = environments.ExecuteAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ExecuteAirflowCommandResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.execute_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ExecuteAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchDatabaseProperties( @@ -1922,7 +2412,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]]] = (), ) -> environments.FetchDatabasePropertiesResponse: r"""Call the fetch database properties method over HTTP. @@ -1933,8 +2423,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: ~.environments.FetchDatabasePropertiesResponse: @@ -1946,6 +2438,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseFetchDatabaseProperties._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_database_properties( request, metadata ) @@ -1958,6 +2451,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.FetchDatabaseProperties", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "FetchDatabaseProperties", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._FetchDatabaseProperties._get_response( self._host, @@ -1978,7 +2498,31 @@ def __call__( pb_resp = environments.FetchDatabasePropertiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_database_properties(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.FetchDatabasePropertiesResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.fetch_database_properties", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "FetchDatabaseProperties", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnvironment( @@ -2015,7 +2559,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]]] = (), ) -> environments.Environment: r"""Call the get environment method over HTTP. @@ -2025,8 +2569,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: ~.environments.Environment: @@ -2038,6 +2584,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_get_environment(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetEnvironment._get_transcoded_request( http_options, request @@ -2048,6 +2595,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.GetEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetEnvironment._get_response( self._host, @@ -2068,7 +2642,29 @@ def __call__( pb_resp = environments.Environment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_environment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.Environment.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.get_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUserWorkloadsConfigMap( @@ -2106,7 +2702,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the get user workloads config map method over HTTP. @@ -2117,8 +2713,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: ~.environments.UserWorkloadsConfigMap: @@ -2131,6 +2729,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_get_user_workloads_config_map( request, metadata ) @@ -2143,6 +2742,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.GetUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._GetUserWorkloadsConfigMap._get_response( @@ -2165,7 +2791,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.get_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUserWorkloadsSecret( @@ -2202,7 +2852,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the get user workloads secret method over HTTP. @@ -2212,8 +2862,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: ~.environments.UserWorkloadsSecret: @@ -2226,6 +2878,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_user_workloads_secret( request, metadata ) @@ -2238,6 +2891,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.GetUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetUserWorkloadsSecret._get_response( self._host, @@ -2258,7 +2938,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.get_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEnvironments( @@ -2295,7 +2999,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]]] = (), ) -> environments.ListEnvironmentsResponse: r"""Call the list environments method over HTTP. @@ -2306,8 +3010,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: ~.environments.ListEnvironmentsResponse: @@ -2319,6 +3025,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListEnvironments._get_http_options() ) + request, metadata = self._interceptor.pre_list_environments( request, metadata ) @@ -2331,6 +3038,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ListEnvironments", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListEnvironments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListEnvironments._get_response( self._host, @@ -2351,7 +3085,31 @@ def __call__( pb_resp = environments.ListEnvironmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_environments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.ListEnvironmentsResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.list_environments", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListEnvironments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUserWorkloadsConfigMaps( @@ -2389,7 +3147,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]]] = (), ) -> environments.ListUserWorkloadsConfigMapsResponse: r"""Call the list user workloads config maps method over HTTP. @@ -2401,8 +3159,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: ~.environments.ListUserWorkloadsConfigMapsResponse: @@ -2414,6 +3174,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListUserWorkloadsConfigMaps._get_http_options() ) + request, metadata = self._interceptor.pre_list_user_workloads_config_maps( request, metadata ) @@ -2426,6 +3187,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ListUserWorkloadsConfigMaps", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListUserWorkloadsConfigMaps", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._ListUserWorkloadsConfigMaps._get_response( @@ -2448,7 +3236,33 @@ def __call__( pb_resp = environments.ListUserWorkloadsConfigMapsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_user_workloads_config_maps(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ListUserWorkloadsConfigMapsResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.list_user_workloads_config_maps", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListUserWorkloadsConfigMaps", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUserWorkloadsSecrets( @@ -2486,7 +3300,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]]] = (), ) -> environments.ListUserWorkloadsSecretsResponse: r"""Call the list user workloads secrets method over HTTP. @@ -2497,8 +3311,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: ~.environments.ListUserWorkloadsSecretsResponse: @@ -2510,6 +3326,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListUserWorkloadsSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_user_workloads_secrets( request, metadata ) @@ -2522,6 +3339,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ListUserWorkloadsSecrets", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListUserWorkloadsSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._ListUserWorkloadsSecrets._get_response( @@ -2544,7 +3388,31 @@ def __call__( pb_resp = environments.ListUserWorkloadsSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_user_workloads_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + environments.ListUserWorkloadsSecretsResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.list_user_workloads_secrets", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListUserWorkloadsSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkloads( @@ -2581,7 +3449,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]]] = (), ) -> environments.ListWorkloadsResponse: r"""Call the list workloads method over HTTP. @@ -2592,8 +3460,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: ~.environments.ListWorkloadsResponse: @@ -2603,6 +3473,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListWorkloads._get_http_options() ) + request, metadata = self._interceptor.pre_list_workloads(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListWorkloads._get_transcoded_request( http_options, request @@ -2613,6 +3484,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ListWorkloads", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListWorkloads", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListWorkloads._get_response( self._host, @@ -2633,7 +3531,31 @@ def __call__( pb_resp = environments.ListWorkloadsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workloads(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.ListWorkloadsResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.list_workloads", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListWorkloads", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LoadSnapshot( @@ -2671,7 +3593,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]]] = (), ) -> operations_pb2.Operation: r"""Call the load snapshot method over HTTP. @@ -2682,8 +3604,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: ~.operations_pb2.Operation: @@ -2696,6 +3620,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseLoadSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_load_snapshot(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseLoadSnapshot._get_transcoded_request( http_options, request @@ -2714,6 +3639,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.LoadSnapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "LoadSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._LoadSnapshot._get_response( self._host, @@ -2733,7 +3685,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_load_snapshot(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.load_snapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "LoadSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PollAirflowCommand( @@ -2771,7 +3745,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]]] = (), ) -> environments.PollAirflowCommandResponse: r"""Call the poll airflow command method over HTTP. @@ -2781,8 +3755,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: ~.environments.PollAirflowCommandResponse: @@ -2794,6 +3770,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BasePollAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_poll_airflow_command( request, metadata ) @@ -2810,6 +3787,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.PollAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "PollAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._PollAirflowCommand._get_response( self._host, @@ -2831,7 +3835,31 @@ def __call__( pb_resp = environments.PollAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_poll_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.PollAirflowCommandResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.poll_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "PollAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestartWebServer( @@ -2869,7 +3897,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]]] = (), ) -> operations_pb2.Operation: r"""Call the restart web server method over HTTP. @@ -2879,8 +3907,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: ~.operations_pb2.Operation: @@ -2893,6 +3923,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseRestartWebServer._get_http_options() ) + request, metadata = self._interceptor.pre_restart_web_server( request, metadata ) @@ -2909,6 +3940,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.RestartWebServer", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "RestartWebServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._RestartWebServer._get_response( self._host, @@ -2928,7 +3986,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restart_web_server(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.restart_web_server", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "RestartWebServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SaveSnapshot( @@ -2966,7 +4046,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]]] = (), ) -> operations_pb2.Operation: r"""Call the save snapshot method over HTTP. @@ -2977,8 +4057,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: ~.operations_pb2.Operation: @@ -2991,6 +4073,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseSaveSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_save_snapshot(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseSaveSnapshot._get_transcoded_request( http_options, request @@ -3009,6 +4092,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.SaveSnapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "SaveSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._SaveSnapshot._get_response( self._host, @@ -3028,7 +4138,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_save_snapshot(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.save_snapshot", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "SaveSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopAirflowCommand( @@ -3066,7 +4198,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]]] = (), ) -> environments.StopAirflowCommandResponse: r"""Call the stop airflow command method over HTTP. @@ -3076,8 +4208,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: ~.environments.StopAirflowCommandResponse: @@ -3089,6 +4223,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseStopAirflowCommand._get_http_options() ) + request, metadata = self._interceptor.pre_stop_airflow_command( request, metadata ) @@ -3105,6 +4240,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.StopAirflowCommand", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "StopAirflowCommand", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._StopAirflowCommand._get_response( self._host, @@ -3126,7 +4288,31 @@ def __call__( pb_resp = environments.StopAirflowCommandResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_airflow_command(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.StopAirflowCommandResponse.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.stop_airflow_command", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "StopAirflowCommand", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEnvironment( @@ -3164,7 +4350,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update environment method over HTTP. @@ -3174,8 +4360,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: ~.operations_pb2.Operation: @@ -3188,6 +4376,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateEnvironment._get_http_options() ) + request, metadata = self._interceptor.pre_update_environment( request, metadata ) @@ -3204,6 +4393,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.UpdateEnvironment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateEnvironment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._UpdateEnvironment._get_response( self._host, @@ -3223,7 +4439,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_environment(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.orchestration.airflow.service_v1beta1.EnvironmentsClient.update_environment", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateEnvironment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUserWorkloadsConfigMap( @@ -3262,7 +4500,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]]] = (), ) -> environments.UserWorkloadsConfigMap: r"""Call the update user workloads config map method over HTTP. @@ -3274,8 +4512,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: ~.environments.UserWorkloadsConfigMap: @@ -3288,6 +4528,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateUserWorkloadsConfigMap._get_http_options() ) + request, metadata = self._interceptor.pre_update_user_workloads_config_map( request, metadata ) @@ -3304,6 +4545,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.UpdateUserWorkloadsConfigMap", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateUserWorkloadsConfigMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._UpdateUserWorkloadsConfigMap._get_response( @@ -3327,7 +4595,31 @@ def __call__( pb_resp = environments.UserWorkloadsConfigMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user_workloads_config_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsConfigMap.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.update_user_workloads_config_map", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateUserWorkloadsConfigMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUserWorkloadsSecret( @@ -3366,7 +4658,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]]] = (), ) -> environments.UserWorkloadsSecret: r"""Call the update user workloads secret method over HTTP. @@ -3377,8 +4669,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: ~.environments.UserWorkloadsSecret: @@ -3391,6 +4685,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseUpdateUserWorkloadsSecret._get_http_options() ) + request, metadata = self._interceptor.pre_update_user_workloads_secret( request, metadata ) @@ -3407,6 +4702,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 = 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.orchestration.airflow.service_v1beta1.EnvironmentsClient.UpdateUserWorkloadsSecret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateUserWorkloadsSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EnvironmentsRestTransport._UpdateUserWorkloadsSecret._get_response( @@ -3430,7 +4752,31 @@ def __call__( pb_resp = environments.UserWorkloadsSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user_workloads_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = environments.UserWorkloadsSecret.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.orchestration.airflow.service_v1beta1.EnvironmentsClient.update_user_workloads_secret", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "UpdateUserWorkloadsSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3710,7 +5056,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -3720,13 +5066,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 = ( _BaseEnvironmentsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -3739,6 +5088,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._DeleteOperation._get_response( self._host, @@ -3794,7 +5170,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -3804,8 +5180,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: operations_pb2.Operation: Response from GetOperation method. @@ -3814,6 +5192,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3826,6 +5205,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._GetOperation._get_response( self._host, @@ -3845,6 +5251,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.orchestration.airflow.service_v1beta1.EnvironmentsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3885,7 +5312,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -3895,8 +5322,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -3905,6 +5334,7 @@ def __call__( http_options = ( _BaseEnvironmentsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseEnvironmentsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -3915,6 +5345,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.orchestration.airflow.service_v1beta1.EnvironmentsClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EnvironmentsRestTransport._ListOperations._get_response( self._host, @@ -3934,6 +5391,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.orchestration.airflow.service_v1beta1.EnvironmentsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.Environments", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py index c89f96ab534a..9bc7c1b63d26 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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, @@ -55,6 +56,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ImageVersionsTransport from .transports.grpc_asyncio import ImageVersionsGrpcAsyncIOTransport +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 ImageVersionsAsyncClient: """Readonly service to query available ImageVersions.""" @@ -258,6 +268,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.orchestration.airflow.service_v1beta1.ImageVersionsAsyncClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "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.orchestration.airflow.service.v1beta1.ImageVersions", + "credentialsType": None, + }, + ) + async def list_image_versions( self, request: Optional[Union[image_versions.ListImageVersionsRequest, dict]] = None, @@ -265,7 +297,7 @@ async def list_image_versions( 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.ListImageVersionsAsyncPager: r"""List ImageVersions for provided location. @@ -310,8 +342,10 @@ async def sample_list_image_versions(): 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.orchestration.airflow.service_v1beta1.services.image_versions.pagers.ListImageVersionsAsyncPager: @@ -385,7 +419,7 @@ async def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -396,8 +430,10 @@ async def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -438,7 +474,7 @@ async def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -449,8 +485,10 @@ async def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -491,7 +529,7 @@ async def delete_operation( *, 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 long-running operation. @@ -507,8 +545,10 @@ async def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py index 04ec1d5c5765..6b65b642f178 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 ( @@ -50,6 +51,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.longrunning import operations_pb2 # type: ignore from google.cloud.orchestration.airflow.service_v1beta1.services.image_versions import ( @@ -560,6 +570,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( @@ -625,6 +639,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.orchestration.airflow.service_v1beta1.ImageVersionsClient`.", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "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.orchestration.airflow.service.v1beta1.ImageVersions", + "credentialsType": None, + }, + ) + def list_image_versions( self, request: Optional[Union[image_versions.ListImageVersionsRequest, dict]] = None, @@ -632,7 +669,7 @@ def list_image_versions( 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.ListImageVersionsPager: r"""List ImageVersions for provided location. @@ -677,8 +714,10 @@ def sample_list_image_versions(): 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.orchestration.airflow.service_v1beta1.services.image_versions.pagers.ListImageVersionsPager: @@ -762,7 +801,7 @@ def list_operations( *, 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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -773,8 +812,10 @@ def list_operations( 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: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -815,7 +856,7 @@ def get_operation( *, 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]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -826,8 +867,10 @@ def get_operation( 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: ~.operations_pb2.Operation: An ``Operation`` object. @@ -868,7 +911,7 @@ def delete_operation( *, 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 long-running operation. @@ -884,8 +927,10 @@ def delete_operation( 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: None """ diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/pagers.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/pagers.py index 4377946da22d..8c887d742e9d 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/pagers.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 = image_versions.ListImageVersionsRequest(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 = image_versions.ListImageVersionsRequest(request) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py index fdb8735fc30e..5d95a82d8224 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1beta1.types import image_versions from .base import DEFAULT_CLIENT_INFO, ImageVersionsTransport +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.orchestration.airflow.service.v1beta1.ImageVersions", + "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.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageVersionsGrpcTransport(ImageVersionsTransport): """gRPC backend transport for ImageVersions. @@ -180,7 +261,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 @@ -257,7 +343,7 @@ def list_image_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_image_versions" not in self._stubs: - self._stubs["list_image_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_image_versions"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.ImageVersions/ListImageVersions", request_serializer=image_versions.ListImageVersionsRequest.serialize, response_deserializer=image_versions.ListImageVersionsResponse.deserialize, @@ -265,7 +351,7 @@ def list_image_versions( return self._stubs["list_image_versions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -277,7 +363,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -294,7 +380,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -313,7 +399,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py index 99288a480590..20ac65618806 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_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.orchestration.airflow.service_v1beta1.types import image_versions from .base import DEFAULT_CLIENT_INFO, ImageVersionsTransport from .grpc import ImageVersionsGrpcTransport +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.orchestration.airflow.service.v1beta1.ImageVersions", + "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.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ImageVersionsGrpcAsyncIOTransport(ImageVersionsTransport): """gRPC AsyncIO backend transport for ImageVersions. @@ -227,10 +309,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 @@ -265,7 +350,7 @@ def list_image_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_image_versions" not in self._stubs: - self._stubs["list_image_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_image_versions"] = self._logged_channel.unary_unary( "/google.cloud.orchestration.airflow.service.v1beta1.ImageVersions/ListImageVersions", request_serializer=image_versions.ListImageVersionsRequest.serialize, response_deserializer=image_versions.ListImageVersionsResponse.deserialize, @@ -303,7 +388,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: @@ -319,7 +404,7 @@ def delete_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self.grpc_channel.unary_unary( + self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, @@ -336,7 +421,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +440,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/rest.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/rest.py index 9c3cabd25624..f8048b38bdb2 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/rest.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 @@ -38,6 +38,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, @@ -78,8 +86,10 @@ def post_list_image_versions(self, response): def pre_list_image_versions( self, request: image_versions.ListImageVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[image_versions.ListImageVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + image_versions.ListImageVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_image_versions Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_list_image_versions( def pre_delete_operation( self, request: operations_pb2.DeleteOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_operation Override in a subclass to manipulate the request or metadata @@ -122,8 +134,10 @@ def post_delete_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -145,8 +159,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -286,7 +302,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]]] = (), ) -> image_versions.ListImageVersionsResponse: r"""Call the list image versions method over HTTP. @@ -297,8 +313,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: ~.image_versions.ListImageVersionsResponse: @@ -310,6 +328,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseListImageVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_image_versions( request, metadata ) @@ -322,6 +341,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 = 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.orchestration.airflow.service_v1beta1.ImageVersionsClient.ListImageVersions", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "ListImageVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._ListImageVersions._get_response( self._host, @@ -342,7 +388,31 @@ def __call__( pb_resp = image_versions.ListImageVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_image_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = image_versions.ListImageVersionsResponse.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.orchestration.airflow.service_v1beta1.ImageVersionsClient.list_image_versions", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "ListImageVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -394,7 +464,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -404,13 +474,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 = ( _BaseImageVersionsRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -423,6 +496,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.orchestration.airflow.service_v1beta1.ImageVersionsClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._DeleteOperation._get_response( self._host, @@ -478,7 +578,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -488,8 +588,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: operations_pb2.Operation: Response from GetOperation method. @@ -498,6 +600,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseImageVersionsRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -508,6 +611,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.orchestration.airflow.service_v1beta1.ImageVersionsClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._GetOperation._get_response( self._host, @@ -527,6 +657,27 @@ def __call__( resp = operations_pb2.Operation() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_operation(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.orchestration.airflow.service_v1beta1.ImageVersionsAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -567,7 +718,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]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -577,8 +728,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: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -587,6 +740,7 @@ def __call__( http_options = ( _BaseImageVersionsRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseImageVersionsRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -597,6 +751,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.orchestration.airflow.service_v1beta1.ImageVersionsClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ImageVersionsRestTransport._ListOperations._get_response( self._host, @@ -616,6 +797,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(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.orchestration.airflow.service_v1beta1.ImageVersionsAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py index a7d029a3a945..9ec1b54524ac 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py @@ -915,6 +915,13 @@ class UserWorkloadsSecret(proto.Message): token, or a key. The values for all keys have to be base64-encoded strings. For details see: https://kubernetes.io/docs/concepts/configuration/secret/ + + Example: + + { + "example": "ZXhhbXBsZV92YWx1ZQ==", + "another-example": + "YW5vdGhlcl9leGFtcGxlX3ZhbHVl" } """ name: str = proto.Field( @@ -967,11 +974,14 @@ class UserWorkloadsConfigMap(proto.Message): ConfigMap, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}/userWorkloadsConfigMaps/{userWorkloadsConfigMapId}". data (MutableMapping[str, str]): - Optional. The "data" field of Kubernetes - ConfigMap, organized in key-value pairs. For - details see: - + Optional. The "data" field of Kubernetes ConfigMap, + organized in key-value pairs. For details see: https://kubernetes.io/docs/concepts/configuration/configmap/ + + Example: + + { "example_key": "example_value", "another_key": + "another_value" } """ name: str = proto.Field( @@ -1389,14 +1399,14 @@ class EnvironmentConfig(proto.Message): This field is supported for Cloud Composer environments in versions composer-1.\ *.*-airflow-*.*.*. software_config (google.cloud.orchestration.airflow.service_v1beta1.types.SoftwareConfig): - The configuration settings for software - inside the environment. + Optional. The configuration settings for + software inside the environment. node_config (google.cloud.orchestration.airflow.service_v1beta1.types.NodeConfig): - The configuration used for the Kubernetes - Engine cluster. + Optional. The configuration used for the + Kubernetes Engine cluster. private_environment_config (google.cloud.orchestration.airflow.service_v1beta1.types.PrivateEnvironmentConfig): - The configuration used for the Private IP - Cloud Composer environment. + Optional. The configuration used for the + Private IP Cloud Composer environment. web_server_network_access_control (google.cloud.orchestration.airflow.service_v1beta1.types.WebServerNetworkAccessControl): Optional. The network-level access control policy for the Airflow web server. If @@ -1661,10 +1671,10 @@ class SoftwareConfig(proto.Message): Attributes: image_version (str): - The version of the software running in the environment. This - encapsulates both the version of Cloud Composer - functionality and the version of Apache Airflow. It must - match the regular expression + Optional. The version of the software running in the + environment. This encapsulates both the version of Cloud + Composer functionality and the version of Apache Airflow. It + must match the regular expression ``composer-([0-9]+(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-([0-9]+(\.[0-9]+(\.[0-9]+)?)?)``. When used as input, the server also checks if the provided version is supported and denies the request for an @@ -2920,15 +2930,15 @@ class Environment(proto.Message): Attributes: name (str): - The resource name of the environment, in the - form: + Identifier. The resource name of the + environment, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}" EnvironmentId must start with a lowercase letter followed by up to 63 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. config (google.cloud.orchestration.airflow.service_v1beta1.types.EnvironmentConfig): - Configuration parameters for this + Optional. Configuration parameters for this environment. uuid (str): Output only. The UUID (Universally Unique diff --git a/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json b/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json index 39f21143bdf4..37f3c1f31434 100644 --- a/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json +++ b/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-orchestration-airflow", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -542,7 +542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -779,7 +779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -860,7 +860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1021,7 +1021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_config_map" @@ -1098,7 +1098,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_config_map" @@ -1176,7 +1176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_secret" @@ -1253,7 +1253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_secret" @@ -1327,7 +1327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.ExecuteAirflowCommandResponse", @@ -1403,7 +1403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.ExecuteAirflowCommandResponse", @@ -1480,7 +1480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.FetchDatabasePropertiesResponse", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.FetchDatabasePropertiesResponse", @@ -1637,7 +1637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.Environment", @@ -1717,7 +1717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.Environment", @@ -1798,7 +1798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -1878,7 +1878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -1959,7 +1959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -2039,7 +2039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -2120,7 +2120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListEnvironmentsAsyncPager", @@ -2200,7 +2200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListEnvironmentsPager", @@ -2281,7 +2281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsConfigMapsAsyncPager", @@ -2361,7 +2361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsConfigMapsPager", @@ -2442,7 +2442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsSecretsAsyncPager", @@ -2522,7 +2522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListUserWorkloadsSecretsPager", @@ -2603,7 +2603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListWorkloadsAsyncPager", @@ -2683,7 +2683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.environments.pagers.ListWorkloadsPager", @@ -2760,7 +2760,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2913,7 +2913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.PollAirflowCommandResponse", @@ -2989,7 +2989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.PollAirflowCommandResponse", @@ -3066,7 +3066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3142,7 +3142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3219,7 +3219,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.StopAirflowCommandResponse", @@ -3295,7 +3295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.StopAirflowCommandResponse", @@ -3384,7 +3384,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3472,7 +3472,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3553,7 +3553,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -3633,7 +3633,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsConfigMap", @@ -3714,7 +3714,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -3794,7 +3794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.types.UserWorkloadsSecret", @@ -3875,7 +3875,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.image_versions.pagers.ListImageVersionsAsyncPager", @@ -3955,7 +3955,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1.services.image_versions.pagers.ListImageVersionsPager", diff --git a/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json b/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json index 67179ecd614e..5dde9a47fdfc 100644 --- a/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json +++ b/packages/google-cloud-orchestration-airflow/samples/generated_samples/snippet_metadata_google.cloud.orchestration.airflow.service.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-orchestration-airflow-service", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -373,7 +373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -542,7 +542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -779,7 +779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -860,7 +860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1021,7 +1021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_config_map" @@ -1098,7 +1098,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_config_map" @@ -1176,7 +1176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_secret" @@ -1253,7 +1253,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user_workloads_secret" @@ -1327,7 +1327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.ExecuteAirflowCommandResponse", @@ -1403,7 +1403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.ExecuteAirflowCommandResponse", @@ -1480,7 +1480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.FetchDatabasePropertiesResponse", @@ -1556,7 +1556,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.FetchDatabasePropertiesResponse", @@ -1637,7 +1637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.Environment", @@ -1717,7 +1717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.Environment", @@ -1798,7 +1798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -1878,7 +1878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -1959,7 +1959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -2039,7 +2039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -2120,7 +2120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListEnvironmentsAsyncPager", @@ -2200,7 +2200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListEnvironmentsPager", @@ -2281,7 +2281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsConfigMapsAsyncPager", @@ -2361,7 +2361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsConfigMapsPager", @@ -2442,7 +2442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsSecretsAsyncPager", @@ -2522,7 +2522,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListUserWorkloadsSecretsPager", @@ -2603,7 +2603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListWorkloadsAsyncPager", @@ -2683,7 +2683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.environments.pagers.ListWorkloadsPager", @@ -2760,7 +2760,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2913,7 +2913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.PollAirflowCommandResponse", @@ -2989,7 +2989,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.PollAirflowCommandResponse", @@ -3066,7 +3066,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3142,7 +3142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3219,7 +3219,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3295,7 +3295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3372,7 +3372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.StopAirflowCommandResponse", @@ -3448,7 +3448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.StopAirflowCommandResponse", @@ -3537,7 +3537,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3625,7 +3625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3706,7 +3706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -3786,7 +3786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsConfigMap", @@ -3867,7 +3867,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -3947,7 +3947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.types.UserWorkloadsSecret", @@ -4028,7 +4028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.image_versions.pagers.ListImageVersionsAsyncPager", @@ -4108,7 +4108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.orchestration.airflow.service_v1beta1.services.image_versions.pagers.ListImageVersionsPager", diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py index faf173901c01..9591f6ae290d 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py @@ -9505,6 +9505,7 @@ def test_create_environment_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_environment(**mock_args) @@ -9601,6 +9602,7 @@ def test_get_environment_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_environment(**mock_args) @@ -9696,6 +9698,7 @@ def test_list_environments_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_environments(**mock_args) @@ -9862,6 +9865,7 @@ def test_update_environment_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_environment(**mock_args) @@ -9965,6 +9969,7 @@ def test_delete_environment_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.delete_environment(**mock_args) @@ -10225,6 +10230,7 @@ def test_list_workloads_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.list_workloads(request) @@ -10281,6 +10287,7 @@ def test_list_workloads_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_workloads(**mock_args) @@ -10482,6 +10489,7 @@ def test_check_upgrade_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.check_upgrade(request) @@ -10607,6 +10615,7 @@ def test_create_user_workloads_secret_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.create_user_workloads_secret(request) @@ -10663,6 +10672,7 @@ def test_create_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -10800,6 +10810,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) @@ -10847,6 +10858,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -10992,6 +11004,7 @@ def test_list_user_workloads_secrets_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.list_user_workloads_secrets(request) @@ -11047,6 +11060,7 @@ def test_list_user_workloads_secrets_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_user_workloads_secrets(**mock_args) @@ -11214,6 +11228,7 @@ def test_update_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11347,6 +11362,7 @@ def test_delete_user_workloads_secret_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.delete_user_workloads_secret(request) @@ -11392,6 +11408,7 @@ def test_delete_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11529,6 +11546,7 @@ def test_create_user_workloads_config_map_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.create_user_workloads_config_map(request) @@ -11589,6 +11607,7 @@ def test_create_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -11728,6 +11747,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) @@ -11777,6 +11797,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -11922,6 +11943,7 @@ def test_list_user_workloads_config_maps_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.list_user_workloads_config_maps(request) @@ -11979,6 +12001,7 @@ def test_list_user_workloads_config_maps_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_user_workloads_config_maps(**mock_args) @@ -12151,6 +12174,7 @@ def test_update_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12286,6 +12310,7 @@ def test_delete_user_workloads_config_map_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.delete_user_workloads_config_map(request) @@ -12333,6 +12358,7 @@ def test_delete_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12591,6 +12617,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) @@ -13972,6 +13999,7 @@ def test_create_environment_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.create_environment(request) @@ -14199,6 +14227,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_environment(request) # Establish that the response is the type that we expect. @@ -14240,6 +14269,7 @@ def test_create_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14284,6 +14314,7 @@ def test_get_environment_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_environment(request) @@ -14323,6 +14354,7 @@ def test_get_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -14367,6 +14399,7 @@ def test_get_environment_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 = environments.Environment.to_json(environments.Environment()) req.return_value.content = return_value @@ -14411,6 +14444,7 @@ def test_list_environments_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.list_environments(request) @@ -14446,6 +14480,7 @@ def test_list_environments_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_environments(request) # Establish that the response is the type that we expect. @@ -14486,6 +14521,7 @@ def test_list_environments_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 = environments.ListEnvironmentsResponse.to_json( environments.ListEnvironmentsResponse() ) @@ -14532,6 +14568,7 @@ def test_update_environment_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.update_environment(request) @@ -14759,6 +14796,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_environment(request) # Establish that the response is the type that we expect. @@ -14800,6 +14838,7 @@ def test_update_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14844,6 +14883,7 @@ def test_delete_environment_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.delete_environment(request) @@ -14874,6 +14914,7 @@ def test_delete_environment_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.delete_environment(request) # Establish that the response is the type that we expect. @@ -14915,6 +14956,7 @@ def test_delete_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14961,6 +15003,7 @@ def test_execute_airflow_command_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.execute_airflow_command(request) @@ -15001,6 +15044,7 @@ def test_execute_airflow_command_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.execute_airflow_command(request) # Establish that the response is the type that we expect. @@ -15044,6 +15088,7 @@ def test_execute_airflow_command_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 = environments.ExecuteAirflowCommandResponse.to_json( environments.ExecuteAirflowCommandResponse() ) @@ -15092,6 +15137,7 @@ def test_stop_airflow_command_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.stop_airflow_command(request) @@ -15130,6 +15176,7 @@ def test_stop_airflow_command_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.stop_airflow_command(request) # Establish that the response is the type that we expect. @@ -15171,6 +15218,7 @@ def test_stop_airflow_command_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 = environments.StopAirflowCommandResponse.to_json( environments.StopAirflowCommandResponse() ) @@ -15219,6 +15267,7 @@ def test_poll_airflow_command_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.poll_airflow_command(request) @@ -15256,6 +15305,7 @@ def test_poll_airflow_command_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.poll_airflow_command(request) # Establish that the response is the type that we expect. @@ -15296,6 +15346,7 @@ def test_poll_airflow_command_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 = environments.PollAirflowCommandResponse.to_json( environments.PollAirflowCommandResponse() ) @@ -15342,6 +15393,7 @@ def test_list_workloads_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.list_workloads(request) @@ -15377,6 +15429,7 @@ def test_list_workloads_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_workloads(request) # Establish that the response is the type that we expect. @@ -15417,6 +15470,7 @@ def test_list_workloads_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 = environments.ListWorkloadsResponse.to_json( environments.ListWorkloadsResponse() ) @@ -15463,6 +15517,7 @@ def test_check_upgrade_rest_bad_request(request_type=environments.CheckUpgradeRe 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.check_upgrade(request) @@ -15495,6 +15550,7 @@ def test_check_upgrade_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.check_upgrade(request) # Establish that the response is the type that we expect. @@ -15536,6 +15592,7 @@ def test_check_upgrade_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15580,6 +15637,7 @@ def test_create_user_workloads_secret_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.create_user_workloads_secret(request) @@ -15687,6 +15745,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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -15727,6 +15786,7 @@ def test_create_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -15775,6 +15835,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) @@ -15812,6 +15873,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -15852,6 +15914,7 @@ def test_get_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -15898,6 +15961,7 @@ def test_list_user_workloads_secrets_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.list_user_workloads_secrets(request) @@ -15933,6 +15997,7 @@ def test_list_user_workloads_secrets_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_user_workloads_secrets(request) # Establish that the response is the type that we expect. @@ -15973,6 +16038,7 @@ def test_list_user_workloads_secrets_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 = environments.ListUserWorkloadsSecretsResponse.to_json( environments.ListUserWorkloadsSecretsResponse() ) @@ -16023,6 +16089,7 @@ def test_update_user_workloads_secret_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.update_user_workloads_secret(request) @@ -16137,6 +16204,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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16177,6 +16245,7 @@ def test_update_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -16225,6 +16294,7 @@ def test_delete_user_workloads_secret_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.delete_user_workloads_secret(request) @@ -16257,6 +16327,7 @@ def test_delete_user_workloads_secret_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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16293,6 +16364,7 @@ def test_delete_user_workloads_secret_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 = environments.DeleteUserWorkloadsSecretRequest() metadata = [ @@ -16333,6 +16405,7 @@ def test_create_user_workloads_config_map_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.create_user_workloads_config_map(request) @@ -16442,6 +16515,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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -16482,6 +16556,7 @@ def test_create_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -16530,6 +16605,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) @@ -16567,6 +16643,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -16607,6 +16684,7 @@ def test_get_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -16653,6 +16731,7 @@ def test_list_user_workloads_config_maps_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.list_user_workloads_config_maps(request) @@ -16688,6 +16767,7 @@ def test_list_user_workloads_config_maps_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_user_workloads_config_maps(request) # Establish that the response is the type that we expect. @@ -16728,6 +16808,7 @@ def test_list_user_workloads_config_maps_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 = environments.ListUserWorkloadsConfigMapsResponse.to_json( environments.ListUserWorkloadsConfigMapsResponse() ) @@ -16778,6 +16859,7 @@ def test_update_user_workloads_config_map_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.update_user_workloads_config_map(request) @@ -16894,6 +16976,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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -16934,6 +17017,7 @@ def test_update_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -16982,6 +17066,7 @@ def test_delete_user_workloads_config_map_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.delete_user_workloads_config_map(request) @@ -17014,6 +17099,7 @@ def test_delete_user_workloads_config_map_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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -17050,6 +17136,7 @@ def test_delete_user_workloads_config_map_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 = environments.DeleteUserWorkloadsConfigMapRequest() metadata = [ @@ -17090,6 +17177,7 @@ def test_save_snapshot_rest_bad_request(request_type=environments.SaveSnapshotRe 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.save_snapshot(request) @@ -17122,6 +17210,7 @@ def test_save_snapshot_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.save_snapshot(request) # Establish that the response is the type that we expect. @@ -17163,6 +17252,7 @@ def test_save_snapshot_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17207,6 +17297,7 @@ def test_load_snapshot_rest_bad_request(request_type=environments.LoadSnapshotRe 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.load_snapshot(request) @@ -17239,6 +17330,7 @@ def test_load_snapshot_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.load_snapshot(request) # Establish that the response is the type that we expect. @@ -17280,6 +17372,7 @@ def test_load_snapshot_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17326,6 +17419,7 @@ def test_database_failover_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.database_failover(request) @@ -17358,6 +17452,7 @@ def test_database_failover_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.database_failover(request) # Establish that the response is the type that we expect. @@ -17399,6 +17494,7 @@ def test_database_failover_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17445,6 +17541,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) @@ -17484,6 +17581,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) # Establish that the response is the type that we expect. @@ -17526,6 +17624,7 @@ def test_fetch_database_properties_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 = environments.FetchDatabasePropertiesResponse.to_json( environments.FetchDatabasePropertiesResponse() ) @@ -17574,6 +17673,7 @@ def test_delete_operation_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.delete_operation(request) @@ -17604,6 +17704,7 @@ def test_delete_operation_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.delete_operation(request) @@ -17634,6 +17735,7 @@ def test_get_operation_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.get_operation(request) @@ -17664,6 +17766,7 @@ def test_get_operation_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_operation(request) @@ -17694,6 +17797,7 @@ def test_list_operations_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_operations(request) @@ -17724,6 +17828,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py index 3b558940d7bd..f08412322564 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py @@ -1671,6 +1671,7 @@ def test_list_image_versions_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_image_versions(**mock_args) @@ -1963,6 +1964,7 @@ def test_list_image_versions_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.list_image_versions(request) @@ -1998,6 +2000,7 @@ def test_list_image_versions_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_image_versions(request) # Establish that the response is the type that we expect. @@ -2038,6 +2041,7 @@ def test_list_image_versions_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 = image_versions.ListImageVersionsResponse.to_json( image_versions.ListImageVersionsResponse() ) @@ -2086,6 +2090,7 @@ def test_delete_operation_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.delete_operation(request) @@ -2116,6 +2121,7 @@ def test_delete_operation_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.delete_operation(request) @@ -2146,6 +2152,7 @@ def test_get_operation_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.get_operation(request) @@ -2176,6 +2183,7 @@ def test_get_operation_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_operation(request) @@ -2206,6 +2214,7 @@ def test_list_operations_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_operations(request) @@ -2236,6 +2245,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py index 42b085dc030a..bbbb1b5bc782 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py @@ -9767,6 +9767,7 @@ def test_create_environment_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_environment(**mock_args) @@ -9863,6 +9864,7 @@ def test_get_environment_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_environment(**mock_args) @@ -9958,6 +9960,7 @@ def test_list_environments_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_environments(**mock_args) @@ -10155,6 +10158,7 @@ def test_update_environment_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.update_environment(request) @@ -10202,6 +10206,7 @@ def test_update_environment_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_environment(**mock_args) @@ -10305,6 +10310,7 @@ def test_delete_environment_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.delete_environment(**mock_args) @@ -10649,6 +10655,7 @@ def test_list_workloads_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.list_workloads(request) @@ -10705,6 +10712,7 @@ def test_list_workloads_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_workloads(**mock_args) @@ -10910,6 +10918,7 @@ def test_create_user_workloads_secret_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.create_user_workloads_secret(request) @@ -10966,6 +10975,7 @@ def test_create_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11103,6 +11113,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) @@ -11150,6 +11161,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11295,6 +11307,7 @@ def test_list_user_workloads_secrets_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.list_user_workloads_secrets(request) @@ -11350,6 +11363,7 @@ def test_list_user_workloads_secrets_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_user_workloads_secrets(**mock_args) @@ -11517,6 +11531,7 @@ def test_update_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11650,6 +11665,7 @@ def test_delete_user_workloads_secret_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.delete_user_workloads_secret(request) @@ -11695,6 +11711,7 @@ def test_delete_user_workloads_secret_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_user_workloads_secret(**mock_args) @@ -11832,6 +11849,7 @@ def test_create_user_workloads_config_map_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.create_user_workloads_config_map(request) @@ -11892,6 +11910,7 @@ def test_create_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12031,6 +12050,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) @@ -12080,6 +12100,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12225,6 +12246,7 @@ def test_list_user_workloads_config_maps_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.list_user_workloads_config_maps(request) @@ -12282,6 +12304,7 @@ def test_list_user_workloads_config_maps_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_user_workloads_config_maps(**mock_args) @@ -12454,6 +12477,7 @@ def test_update_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12589,6 +12613,7 @@ def test_delete_user_workloads_config_map_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.delete_user_workloads_config_map(request) @@ -12636,6 +12661,7 @@ def test_delete_user_workloads_config_map_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_user_workloads_config_map(**mock_args) @@ -12894,6 +12920,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) @@ -14325,6 +14352,7 @@ def test_create_environment_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.create_environment(request) @@ -14554,6 +14582,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_environment(request) # Establish that the response is the type that we expect. @@ -14595,6 +14624,7 @@ def test_create_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -14639,6 +14669,7 @@ def test_get_environment_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_environment(request) @@ -14678,6 +14709,7 @@ def test_get_environment_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_environment(request) # Establish that the response is the type that we expect. @@ -14722,6 +14754,7 @@ def test_get_environment_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 = environments.Environment.to_json(environments.Environment()) req.return_value.content = return_value @@ -14766,6 +14799,7 @@ def test_list_environments_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.list_environments(request) @@ -14801,6 +14835,7 @@ def test_list_environments_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_environments(request) # Establish that the response is the type that we expect. @@ -14841,6 +14876,7 @@ def test_list_environments_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 = environments.ListEnvironmentsResponse.to_json( environments.ListEnvironmentsResponse() ) @@ -14887,6 +14923,7 @@ def test_update_environment_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.update_environment(request) @@ -15116,6 +15153,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_environment(request) # Establish that the response is the type that we expect. @@ -15157,6 +15195,7 @@ def test_update_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15201,6 +15240,7 @@ def test_delete_environment_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.delete_environment(request) @@ -15231,6 +15271,7 @@ def test_delete_environment_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.delete_environment(request) # Establish that the response is the type that we expect. @@ -15272,6 +15313,7 @@ def test_delete_environment_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15316,6 +15358,7 @@ def test_restart_web_server_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.restart_web_server(request) @@ -15346,6 +15389,7 @@ def test_restart_web_server_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.restart_web_server(request) # Establish that the response is the type that we expect. @@ -15387,6 +15431,7 @@ def test_restart_web_server_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15431,6 +15476,7 @@ def test_check_upgrade_rest_bad_request(request_type=environments.CheckUpgradeRe 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.check_upgrade(request) @@ -15463,6 +15509,7 @@ def test_check_upgrade_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.check_upgrade(request) # Establish that the response is the type that we expect. @@ -15504,6 +15551,7 @@ def test_check_upgrade_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -15550,6 +15598,7 @@ def test_execute_airflow_command_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.execute_airflow_command(request) @@ -15590,6 +15639,7 @@ def test_execute_airflow_command_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.execute_airflow_command(request) # Establish that the response is the type that we expect. @@ -15633,6 +15683,7 @@ def test_execute_airflow_command_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 = environments.ExecuteAirflowCommandResponse.to_json( environments.ExecuteAirflowCommandResponse() ) @@ -15681,6 +15732,7 @@ def test_stop_airflow_command_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.stop_airflow_command(request) @@ -15719,6 +15771,7 @@ def test_stop_airflow_command_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.stop_airflow_command(request) # Establish that the response is the type that we expect. @@ -15760,6 +15813,7 @@ def test_stop_airflow_command_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 = environments.StopAirflowCommandResponse.to_json( environments.StopAirflowCommandResponse() ) @@ -15808,6 +15862,7 @@ def test_poll_airflow_command_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.poll_airflow_command(request) @@ -15845,6 +15900,7 @@ def test_poll_airflow_command_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.poll_airflow_command(request) # Establish that the response is the type that we expect. @@ -15885,6 +15941,7 @@ def test_poll_airflow_command_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 = environments.PollAirflowCommandResponse.to_json( environments.PollAirflowCommandResponse() ) @@ -15931,6 +15988,7 @@ def test_list_workloads_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.list_workloads(request) @@ -15966,6 +16024,7 @@ def test_list_workloads_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_workloads(request) # Establish that the response is the type that we expect. @@ -16006,6 +16065,7 @@ def test_list_workloads_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 = environments.ListWorkloadsResponse.to_json( environments.ListWorkloadsResponse() ) @@ -16052,6 +16112,7 @@ def test_create_user_workloads_secret_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.create_user_workloads_secret(request) @@ -16159,6 +16220,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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16199,6 +16261,7 @@ def test_create_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -16247,6 +16310,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) @@ -16284,6 +16348,7 @@ def test_get_user_workloads_secret_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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16324,6 +16389,7 @@ def test_get_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -16370,6 +16436,7 @@ def test_list_user_workloads_secrets_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.list_user_workloads_secrets(request) @@ -16405,6 +16472,7 @@ def test_list_user_workloads_secrets_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_user_workloads_secrets(request) # Establish that the response is the type that we expect. @@ -16445,6 +16513,7 @@ def test_list_user_workloads_secrets_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 = environments.ListUserWorkloadsSecretsResponse.to_json( environments.ListUserWorkloadsSecretsResponse() ) @@ -16495,6 +16564,7 @@ def test_update_user_workloads_secret_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.update_user_workloads_secret(request) @@ -16609,6 +16679,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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16649,6 +16720,7 @@ def test_update_user_workloads_secret_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 = environments.UserWorkloadsSecret.to_json( environments.UserWorkloadsSecret() ) @@ -16697,6 +16769,7 @@ def test_delete_user_workloads_secret_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.delete_user_workloads_secret(request) @@ -16729,6 +16802,7 @@ def test_delete_user_workloads_secret_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_user_workloads_secret(request) # Establish that the response is the type that we expect. @@ -16765,6 +16839,7 @@ def test_delete_user_workloads_secret_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 = environments.DeleteUserWorkloadsSecretRequest() metadata = [ @@ -16805,6 +16880,7 @@ def test_create_user_workloads_config_map_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.create_user_workloads_config_map(request) @@ -16914,6 +16990,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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -16954,6 +17031,7 @@ def test_create_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -17002,6 +17080,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) @@ -17039,6 +17118,7 @@ def test_get_user_workloads_config_map_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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -17079,6 +17159,7 @@ def test_get_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -17125,6 +17206,7 @@ def test_list_user_workloads_config_maps_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.list_user_workloads_config_maps(request) @@ -17160,6 +17242,7 @@ def test_list_user_workloads_config_maps_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_user_workloads_config_maps(request) # Establish that the response is the type that we expect. @@ -17200,6 +17283,7 @@ def test_list_user_workloads_config_maps_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 = environments.ListUserWorkloadsConfigMapsResponse.to_json( environments.ListUserWorkloadsConfigMapsResponse() ) @@ -17250,6 +17334,7 @@ def test_update_user_workloads_config_map_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.update_user_workloads_config_map(request) @@ -17366,6 +17451,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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -17406,6 +17492,7 @@ def test_update_user_workloads_config_map_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 = environments.UserWorkloadsConfigMap.to_json( environments.UserWorkloadsConfigMap() ) @@ -17454,6 +17541,7 @@ def test_delete_user_workloads_config_map_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.delete_user_workloads_config_map(request) @@ -17486,6 +17574,7 @@ def test_delete_user_workloads_config_map_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_user_workloads_config_map(request) # Establish that the response is the type that we expect. @@ -17522,6 +17611,7 @@ def test_delete_user_workloads_config_map_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 = environments.DeleteUserWorkloadsConfigMapRequest() metadata = [ @@ -17562,6 +17652,7 @@ def test_save_snapshot_rest_bad_request(request_type=environments.SaveSnapshotRe 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.save_snapshot(request) @@ -17594,6 +17685,7 @@ def test_save_snapshot_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.save_snapshot(request) # Establish that the response is the type that we expect. @@ -17635,6 +17727,7 @@ def test_save_snapshot_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17679,6 +17772,7 @@ def test_load_snapshot_rest_bad_request(request_type=environments.LoadSnapshotRe 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.load_snapshot(request) @@ -17711,6 +17805,7 @@ def test_load_snapshot_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.load_snapshot(request) # Establish that the response is the type that we expect. @@ -17752,6 +17847,7 @@ def test_load_snapshot_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17798,6 +17894,7 @@ def test_database_failover_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.database_failover(request) @@ -17830,6 +17927,7 @@ def test_database_failover_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.database_failover(request) # Establish that the response is the type that we expect. @@ -17871,6 +17969,7 @@ def test_database_failover_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(operations_pb2.Operation()) req.return_value.content = return_value @@ -17917,6 +18016,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) @@ -17956,6 +18056,7 @@ def test_fetch_database_properties_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.fetch_database_properties(request) # Establish that the response is the type that we expect. @@ -17998,6 +18099,7 @@ def test_fetch_database_properties_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 = environments.FetchDatabasePropertiesResponse.to_json( environments.FetchDatabasePropertiesResponse() ) @@ -18046,6 +18148,7 @@ def test_delete_operation_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.delete_operation(request) @@ -18076,6 +18179,7 @@ def test_delete_operation_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.delete_operation(request) @@ -18106,6 +18210,7 @@ def test_get_operation_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.get_operation(request) @@ -18136,6 +18241,7 @@ def test_get_operation_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_operation(request) @@ -18166,6 +18272,7 @@ def test_list_operations_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_operations(request) @@ -18196,6 +18303,7 @@ def test_list_operations_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_operations(request) diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py index 7f9f7640cf24..f0db504f22fe 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py @@ -1671,6 +1671,7 @@ def test_list_image_versions_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_image_versions(**mock_args) @@ -1963,6 +1964,7 @@ def test_list_image_versions_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.list_image_versions(request) @@ -1998,6 +2000,7 @@ def test_list_image_versions_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_image_versions(request) # Establish that the response is the type that we expect. @@ -2038,6 +2041,7 @@ def test_list_image_versions_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 = image_versions.ListImageVersionsResponse.to_json( image_versions.ListImageVersionsResponse() ) @@ -2086,6 +2090,7 @@ def test_delete_operation_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.delete_operation(request) @@ -2116,6 +2121,7 @@ def test_delete_operation_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.delete_operation(request) @@ -2146,6 +2152,7 @@ def test_get_operation_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.get_operation(request) @@ -2176,6 +2183,7 @@ def test_get_operation_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_operation(request) @@ -2206,6 +2214,7 @@ def test_list_operations_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_operations(request) @@ -2236,6 +2245,7 @@ def test_list_operations_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_operations(request)